Your project uses non-strict array lookups 120

More information: https://insight.symfony.com/what-we-analyse/php.strict_array_lookup

New rule! We've recently added this rule to Insight. Don't be surprised to see new suggestions even though the codebase didn't change.
  1. foreach ($words as $word) {
  2. // Clean word (remove punctuation)
  3. $cleanWord = preg_replace('/[^\w\-]/', '', $word);
  4. // Ignore short words or stop words
  5. if (strlen($cleanWord) > 2 && !in_array($cleanWord, $stopWords)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $keywords[] = $cleanWord;
  7. }
  8. }
  9. return array_unique($keywords);
  1. ]
  2. );
  3. // Map detection_method to valid ENUM value
  4. $detectionMethod = $context['detection_method'] ?? 'pattern_based';
  5. if (!in_array($detectionMethod, ['llm_semantic', 'pattern_based', 'response_validation', 'hybrid'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $detectionMethod = 'pattern_based'; // default for fallback
  7. }
  8. $safeContext = $context;
  9. unset($safeContext['detection_method']);
  1. // Insert into database
  2. $this->db->save($table, $data);
  3. // Check if we should trigger alerts (for threat events)
  4. if (in_array($eventType, ['threat_detected', 'threat_blocked']) && isset($details['blocked']) && $details['blocked']) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $this->checkAndTriggerAlerts();
  6. }
  7. return true;
  8. } catch (\Exception $e) {
  1. $severity = 'medium';
  2. }
  3. // Map detection_method to valid ENUM value
  4. $detectionMethod = $context['detection_method'] ?? 'llm_semantic';
  5. if (!in_array($detectionMethod, ['llm_semantic', 'pattern_based', 'response_validation', 'hybrid'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $detectionMethod = 'llm_semantic'; // default
  7. }
  8. $safeContext = $context;
  9. unset($safeContext['detection_method']);
  1. if (in_array($model, ['gpt-5.2', 'gpt-5.2-pro', 'gpt-5-mini'])) {
  2. $response = $this->handleGpt5Truncation($response);
  3. }
  4. // Local models (GPT-OSS, Phi-4, Mistral): May have formatting variations
  5. if (in_array($model, ['gpt-oss', 'phi-4', 'mistral-large', 'mistral-medium'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $response = $this->handleLocalModelVariations($response);
  7. }
  8. return $response;
  9. }
  1. if (isset($response['interpretation'])) {
  2. $interpretation = $response['interpretation'];
  3. $lastChar = substr($interpretation, -1);
  4. // If doesn't end with punctuation, may be truncated
  5. if (!in_array($lastChar, ['.', '!', '?', ')', ']', '}'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $response['interpretation'] .= ' [Response may be truncated due to context limit]';
  7. $response['truncated'] = true;
  8. }
  9. }
  1. {
  2. if (isset($response['interpretation'])) {
  3. $interpretation = $response['interpretation'];
  4. $lastChar = substr($interpretation, -1);
  5. if (!in_array($lastChar, ['.', '!', '?', ')', ']', '}'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $response['interpretation'] .= ' [Response may be truncated due to context limit]';
  7. $response['truncated'] = true;
  8. }
  9. }
  1. * @return array Adjusted response
  2. */
  3. private function applyModelSpecificAdjustments(array $response, string $model): array
  4. {
  5. // GPT-4.x series: May have truncated responses due to context limits
  6. if (in_array($model, ['gpt-4', 'gpt-4.1', 'gpt-4.1-mini', 'gpt-4.1-nano'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $response = $this->handleGpt4Truncation($response);
  8. }
  9. // GPT-5.x series: Newer models may also hit limits; handle truncation similarly
  10. if (in_array($model, ['gpt-5.2', 'gpt-5.2-pro', 'gpt-5-mini'])) {
  1. if (in_array($model, ['gpt-4', 'gpt-4.1', 'gpt-4.1-mini', 'gpt-4.1-nano'])) {
  2. $response = $this->handleGpt4Truncation($response);
  3. }
  4. // GPT-5.x series: Newer models may also hit limits; handle truncation similarly
  5. if (in_array($model, ['gpt-5.2', 'gpt-5.2-pro', 'gpt-5-mini'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $response = $this->handleGpt5Truncation($response);
  7. }
  8. // Local models (GPT-OSS, Phi-4, Mistral): May have formatting variations
  9. if (in_array($model, ['gpt-oss', 'phi-4', 'mistral-large', 'mistral-medium'])) {
  1. * @return bool True if analytics response
  2. */
  3. private function isAnalyticsResponse(array $response): bool
  4. {
  5. $type = $response['response_type'] ?? '';
  6. return in_array($type, ['analytics_response', 'analytics_results', 'analytics']);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Ensure SQL is extracted for analytics responses
  10. *
  1. * @return void
  2. */
  3. public function registerEntityTable(string $tableName, string $idColumn, ?string $entityType = null): void
  4. {
  5. // Add to entity table cache (IN-MEMORY ONLY)
  6. if (!in_array($tableName, $this->entityTableCache)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $this->entityTableCache[] = $tableName;
  8. }
  9. // Add to ID column cache (IN-MEMORY ONLY)
  10. $this->idColumnCache[$tableName] = $idColumn;
  1. * @return bool True if it's a memory table
  2. */
  3. public function isMemoryTable(string $tableName): bool
  4. {
  5. $memoryTables = $this->getMemoryTables();
  6. return in_array($tableName, $memoryTables);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Get table metadata
  10. *
  1. * @return bool True if it's an entity table
  2. */
  3. public function isEntityTable(string $tableName): bool
  4. {
  5. $allTables = $this->getAllEntityTables();
  6. return in_array($tableName, $allTables);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Check if a table is an embedding table
  10. *
  1. * @throws NoCapableActorException If no alternative actor available
  2. */
  3. private function selectAlternativeActor(Action $action, array $excludeActorIds): ActorAgentInterface
  4. {
  5. $capableActors = $this->actorRegistry->getCapableActors($action->getType());
  6. $alternatives = array_filter($capableActors, fn($a) => !in_array($a->getActorId(), $excludeActorIds));
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. if (empty($alternatives)) {
  8. throw new NoCapableActorException("No alternative actor available for action type: {$action->getType()}");
  9. }
  1. ActionResult $result,
  2. int $count,
  3. array $excludeCriticIds
  4. ): array {
  5. $qualifiedCritics = $this->criticRegistry->getQualifiedCritics($result->getOutputType());
  6. $validCritics = array_filter($qualifiedCritics, fn($c) => !in_array($c->getCriticId(), $excludeCriticIds));
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. if (count($validCritics) < $count) {
  8. throw new InsufficientCriticsException(
  9. "Insufficient additional critics available. Needed: {$count}, Available: " . count($validCritics)
  10. );
  1. // Get all capable evaluators
  2. $capableEvaluators = $this->capabilityRegistry->getCapableEvaluators($outputType, 'competent');
  3. // Filter out excluded evaluators
  4. $availableEvaluators = array_filter($capableEvaluators, function($evaluator) use ($excludedEvaluators) {
  5. return !in_array($evaluator['agent_id'], $excludedEvaluators);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. });
  7. // If no competent evaluators available, try novice level
  8. if (empty($availableEvaluators)) {
  9. $capableEvaluators = $this->capabilityRegistry->getCapableEvaluators($outputType, 'novice');
  1. // If no competent evaluators available, try novice level
  2. if (empty($availableEvaluators)) {
  3. $capableEvaluators = $this->capabilityRegistry->getCapableEvaluators($outputType, 'novice');
  4. $availableEvaluators = array_filter($capableEvaluators, function($evaluator) use ($excludedEvaluators) {
  5. return !in_array($evaluator['agent_id'], $excludedEvaluators);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. });
  7. }
  8. // Return first available evaluator or null
  9. if (!empty($availableEvaluators)) {
  1. $hasWarnings = true;
  2. }
  3. // Check for flagged or rejected grounding decision
  4. if (isset($groundingMetadata['grounding_decision']) &&
  5. in_array($groundingMetadata['grounding_decision'], ['FLAG', 'REJECT'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $hasWarnings = true;
  7. }
  8. if (!$hasWarnings) {
  9. return '';
  1. $this->performanceMetrics = array_merge($this->performanceMetrics, $metrics);
  2. }
  3. public function supportsParameter(string $parameter): bool
  4. {
  5. return in_array($parameter, $this->supportedParameters);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. public function getPerformanceMetric(string $metric): mixed
  8. {
  9. return $this->performanceMetrics[$metric] ?? null;
  1. $weightedSum = 0.0;
  2. $totalWeight = 0.0;
  3. foreach ($evaluations as $evaluation) {
  4. $weight = in_array($evaluation->getEvaluatorAgentId(), $outlierAgents) ? 0.5 : 1.0;
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $weightedSum += $evaluation->getOverallScore() * $weight;
  6. $totalWeight += $weight;
  7. }
  8. $proposedScore = $totalWeight > 0 ? $weightedSum / $totalWeight : array_sum($scores) / count($scores);
  1. $outlierScores = array_column($outliers, 'score');
  2. $weightedSum = 0.0;
  3. $totalWeight = 0.0;
  4. foreach ($scores as $score) {
  5. $weight = in_array($score, $outlierScores) ? 0.5 : 1.0;
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $weightedSum += $score * $weight;
  7. $totalWeight += $weight;
  8. }
  9. return $totalWeight > 0 ? $weightedSum / $totalWeight : array_sum($scores) / count($scores);
  1. return $left;
  2. };
  3. $parseAddSub = function() use (&$parseMulDiv, $expr, &$pos) {
  4. $left = $parseMulDiv();
  5. while ($pos < strlen($expr) && in_array($expr[$pos], ['+', '-'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $op = $expr[$pos++];
  7. $right = $parseMulDiv();
  8. $left = $op === '+' ? $left + $right : $left - $right;
  9. }
  10. return $left;
  1. return $left;
  2. };
  3. $parseMulDiv = function() use (&$parsePower, $expr, &$pos) {
  4. $left = $parsePower();
  5. while ($pos < strlen($expr) && in_array($expr[$pos], ['*', '/', '%'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $op = $expr[$pos++];
  7. $right = $parsePower();
  8. $left = match($op) {
  9. '*' => $left * $right,
  10. '/' => $right != 0 ? $left / $right : throw new \Exception('Division by zero'),
  1. }
  2. // Additional URL validation for allowed schemes
  3. if (isset($options['allowedSchemes'])) {
  4. $scheme = parse_url($input, PHP_URL_SCHEME);
  5. if (!in_array($scheme, $options['allowedSchemes'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. self::logSecurityEvent("URL scheme not allowed: $scheme");
  7. return $default ?? '';
  8. }
  9. }
  1. }
  2. // Check file extension if extensions are specified
  3. if (!empty($allowedExtensions)) {
  4. $extension = strtolower(pathinfo($realPath, PATHINFO_EXTENSION));
  5. if (!in_array($extension, array_map('strtolower', $allowedExtensions))) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. self::logSecurityEvent("File has disallowed extension: $extension");
  7. return false;
  8. }
  9. }
  1. // Check if permission level allows the action
  2. switch ($permissionLevel) {
  3. case 'full':
  4. return true;
  5. case 'write':
  6. return in_array($action, ['create', 'read', 'update']);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. case 'read':
  8. return $action === 'read';
  9. default:
  10. return false;
  11. }
  1. */
  2. public function grantDomainPermission(string $agentId, string $domain, string $permissionLevel): bool
  3. {
  4. try {
  5. $validLevels = ['read', 'write', 'full'];
  6. if (!in_array($permissionLevel, $validLevels)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. throw new Exception("Invalid permission level: $permissionLevel");
  8. }
  9. // Check if permission already exists
  10. $Qcheck = $this->db->prepare('
  1. foreach ($allEntityTypes as $entityType) {
  2. // Skip system tables that shouldn't be included in context resolution
  3. // IMPORTANT: Use correct table names with '_embedding' suffix for embedding tables
  4. // See docs/RAG_TABLE_NAMING_CONVENTION.md for complete documentation
  5. if (in_array($entityType, [
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. 'rag_conversation_memory_embedding', // Embedding table: conversation history
  7. 'rag_correction_patterns_embedding', // Embedding table: correction patterns
  8. 'rag_web_cache_embedding', // Embedding table: web cache
  9. 'rag_memory_retention_log' // System table: retention logs (no embedding)
  10. ])) {
  1. }
  2. }
  3. // Also try with entity type name directly
  4. // Matches: "supplier ABC Corp", "manufacturer XYZ Inc"
  5. if (in_array($entityType, ['suppliers', 'manufacturers', 'categories'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $namePattern = '/\b(?:' . preg_quote($singularType, '/') . ')\s+(["\']?)([^"\']+)\1/i';
  7. if (preg_match_all($namePattern, $content, $matches)) {
  8. if (!isset($entities[$entityType])) {
  9. $entities[$entityType] = [];
  1. $type = 'web';
  2. }
  3. // Validate response (supports 4 categories)
  4. $validTypes = ['analytic', 'semantic', 'web', 'hybrid'];
  5. if (!in_array($type, $validTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. if ($this->debug) {
  7. $this->logWarning("LLM returned invalid type", [
  8. 'type' => $type,
  9. 'defaulting_to' => 'semantic'
  10. ]);
  1. {
  2. $validTypes = ['low_reputation', 'rapid_change', 'gaming_detected', 'anomaly'];
  3. $validSeverities = ['low', 'medium', 'high', 'critical'];
  4. return !empty($this->criticId)
  5. && in_array($this->alertType, $validTypes)
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. && in_array($this->severity, $validSeverities)
  7. && !empty($this->message);
  8. }
  9. /**
  1. $validTypes = ['low_reputation', 'rapid_change', 'gaming_detected', 'anomaly'];
  2. $validSeverities = ['low', 'medium', 'high', 'critical'];
  3. return !empty($this->criticId)
  4. && in_array($this->alertType, $validTypes)
  5. && in_array($this->severity, $validSeverities)
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. && !empty($this->message);
  7. }
  8. /**
  9. * Get alert as array for serialization
  1. // Clamp confidence to [0.0, 1.0]
  2. $analysis['confidence'] = min(1.0, max(0.0, (float)$analysis['confidence']));
  3. // Validate threat_type
  4. $validThreatTypes = ['instruction_override', 'exfiltration', 'hallucination', 'none'];
  5. if (!\in_array($analysis['threat_type'], $validThreatTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. self::$logger->logSecurityEvent(
  7. "Invalid threat_type: " . $analysis['threat_type'] . ", defaulting to 'none'",
  8. 'warning'
  9. );
  10. $analysis['threat_type'] = 'none';
  1. case 'analytics':
  2. // For analytics queries, entities are critical
  3. if (in_array('entities', $failedOps)) {
  4. return 'significant'; // Entities are essential for analytics
  5. }
  6. if (in_array('memory', $failedOps)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return 'minimal'; // Memory less important for analytics
  8. }
  9. return 'minimal';
  10. case 'hybrid':
  1. // Assess impact based on query type and failed operations
  2. switch ($queryType) {
  3. case 'semantic':
  4. // For semantic queries, embeddings are critical
  5. if (in_array('embeddings', $failedOps)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return 'significant'; // Embeddings are essential for semantic search
  7. }
  8. if (in_array('memory', $failedOps)) {
  9. return 'moderate'; // Memory helps but not critical
  10. }
  1. case 'semantic':
  2. // For semantic queries, embeddings are critical
  3. if (in_array('embeddings', $failedOps)) {
  4. return 'significant'; // Embeddings are essential for semantic search
  5. }
  6. if (in_array('memory', $failedOps)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return 'moderate'; // Memory helps but not critical
  8. }
  9. return 'minimal';
  10. case 'analytics':
  1. }
  2. return 'minimal';
  3. case 'analytics':
  4. // For analytics queries, entities are critical
  5. if (in_array('entities', $failedOps)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return 'significant'; // Entities are essential for analytics
  7. }
  8. if (in_array('memory', $failedOps)) {
  9. return 'minimal'; // Memory less important for analytics
  10. }
  1. ['modify', 'modify'],
  2. ['update', 'update']
  3. ];
  4. foreach ($conflictingOps as $pair) {
  5. if ((in_array($pair[0], $operations1) && in_array($pair[1], $operations2)) ||
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. (in_array($pair[1], $operations1) && in_array($pair[0], $operations2))) {
  7. return true;
  8. }
  9. }
  1. ['update', 'update']
  2. ];
  3. foreach ($conflictingOps as $pair) {
  4. if ((in_array($pair[0], $operations1) && in_array($pair[1], $operations2)) ||
  5. (in_array($pair[1], $operations1) && in_array($pair[0], $operations2))) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return true;
  7. }
  8. }
  9. return false;
  1. ];
  2. // Extract words
  3. $words = preg_split('/\s+/', strtolower($text));
  4. $words = array_filter($words, function($word) use ($stopWords) {
  5. return strlen($word) > 2 && !in_array($word, $stopWords);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. });
  7. return array_values($words);
  8. }
  1. }
  2. // Accepter les codes 200, 404 (si /health n'existe pas), ou 405 (méthode non supportée)
  3. $acceptableCodes = [200, 404, 405];
  4. if (!in_array($httpCode, $acceptableCodes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $this->logger->error('HTTP connection test failed', [
  6. 'http_code' => $httpCode,
  7. 'response' => $response,
  8. 'url' => $healthUrl
  9. ]);
  1. return in_array($expertise, $this->requiredExpertise);
  2. }
  3. public function hasSpecialRequirement(string $requirement): bool
  4. {
  5. return in_array($requirement, $this->specialRequirements);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. public function isCritical(): bool
  8. {
  9. return $this->priorityLevel === 'critical';
  1. return $this->priorityLevel === 'critical';
  2. }
  3. public function isHighPriority(): bool
  4. {
  5. return in_array($this->priorityLevel, ['high', 'critical']);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. public function getMetadataValue(string $key): mixed
  8. {
  9. return $this->metadata[$key] ?? null;
  1. return $this->metadata;
  2. }
  3. public function hasRequiredExpertise(string $expertise): bool
  4. {
  5. return in_array($expertise, $this->requiredExpertise);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. public function hasSpecialRequirement(string $requirement): bool
  8. {
  9. return in_array($requirement, $this->specialRequirements);
  1. // "recent" is rarely what users want, so it's last
  2. $priority = ['sum', 'count', 'list', 'recent'];
  3. $selected = [];
  4. foreach ($priority as $type) {
  5. if (in_array($type, $availableInterpretations)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $selected[] = $type;
  7. if (count($selected) >= $count) {
  8. break;
  9. }
  10. }
  1. // Check for single day + weekly/monthly aggregation
  2. if (TemporalConflictPattern::isSingleDayRange($timeRange)) {
  3. $coarseAggregationPeriods = TemporalConflictPattern::getCoarseAggregationPeriods();
  4. foreach ($temporalPeriods as $period) {
  5. if (in_array(strtolower($period), $coarseAggregationPeriods)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return [
  7. 'has_conflict' => true,
  8. 'conflict_type' => 'granularity_too_coarse',
  9. 'conflict_details' => "Cannot aggregate by '{$period}' for a single day ('{$timeRange}'). A single day cannot be broken down into {$period}s.",
  10. 'suggested_clarification' => "Did you want daily data for '{$timeRange}', or did you mean to specify a longer time range for {$period}ly aggregation?",
  1. }
  2. }
  3. // Fill remaining with any available interpretations
  4. foreach ($availableInterpretations as $type) {
  5. if (!in_array($type, $selected)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $selected[] = $type;
  7. if (count($selected) >= $count) {
  8. break;
  9. }
  10. }
  1. // Get agent's permission level
  2. $permissionLevel = $this->getAgentPermissionLevel($agentId, $businessDomain);
  3. // Actions that always require approval regardless of permission level
  4. if (in_array($action, $this->approvalRequiredActions)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. return true;
  6. }
  7. // Propose permission level always requires approval for write actions
  8. if ($permissionLevel === self::PERMISSION_PROPOSE) {
  1. ]
  2. ];
  3. // Check if action is allowed for this permission level
  4. if (isset($permissionActions[$permissionLevel])) {
  5. return in_array($action, $permissionActions[$permissionLevel]);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. // If permission level is unknown, deny access
  8. return false;
  9. }
  1. public function setAgentPermission(string $agentId, string $businessDomain, string $permissionLevel): bool
  2. {
  3. $businessDomain = $this->normalizeDomain($businessDomain);
  4. try {
  5. // Validate permission level
  6. if (!in_array($permissionLevel, $this->validPermissionLevels)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. throw new Exception("Invalid permission level: $permissionLevel. Must be one of: " .
  8. implode(', ', $this->validPermissionLevels));
  9. }
  10. // Check if permission already exists
  1. }
  2. // Execute_safe requires approval for non-safe operations
  3. if ($permissionLevel === self::PERMISSION_EXECUTE_SAFE) {
  4. $unsafeActions = ['delete', 'modify_business_rules', 'modify_rules', 'change_business_logic'];
  5. if (in_array($action, $unsafeActions)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return true;
  7. }
  8. }
  9. return false;
  1. throw new Exception('Feedback text is required');
  2. }
  3. // Validate feedback type
  4. $validTypes = ['correctness', 'efficiency', 'completeness', 'best_practice'];
  5. if (!in_array($feedback['feedback_type'], $validTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. throw new Exception('Invalid feedback type. Must be one of: ' . implode(', ', $validTypes));
  7. }
  8. try {
  9. $feedbackId = $this->generateFeedbackId();
  1. $score += 30;
  2. $factors[] = 'complex_type';
  3. if ($this->debug) {
  4. error_log('[INFO] Complexity factor: complex_type (+30)');
  5. }
  6. } elseif (in_array($type, ['analytics_results', 'analytics_response'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $score += 10;
  8. $factors[] = 'analytics_type';
  9. if ($this->debug) {
  10. error_log('[INFO] Complexity factor: analytics_type (+10)');
  11. }
  1. $score = 0;
  2. $factors = [];
  3. // Factor 1: Result type
  4. $type = $results['type'] ?? '';
  5. if (in_array($type, ['complex_query', 'hybrid'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $score += 30;
  7. $factors[] = 'complex_type';
  8. if ($this->debug) {
  9. error_log('[INFO] Complexity factor: complex_type (+30)');
  10. }
  1. throw new \RuntimeException('LLM selected no critics');
  2. }
  3. // Validate selected critics are from available pool
  4. foreach ($data['selected_critics'] as $criticId) {
  5. if (!in_array($criticId, $availableCriticIds)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. throw new \RuntimeException("LLM selected invalid critic: {$criticId}");
  7. }
  8. }
  9. return [
  1. throw new \RuntimeException("Anomaly {$idx} missing 'description' field");
  2. }
  3. // Validate severity is valid
  4. $validSeverities = ['low', 'medium', 'high'];
  5. if (!in_array($anomaly['severity'], $validSeverities)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. throw new \RuntimeException(
  7. "Anomaly {$idx} has invalid severity: {$anomaly['severity']}. Must be one of: " .
  8. implode(', ', $validSeverities)
  9. );
  10. }
  1. $criticId = $critic->getCriticId();
  2. } elseif (is_array($critic) && isset($critic['critic_id'])) {
  3. $criticId = $critic['critic_id'];
  4. }
  5. if ($criticId && in_array($criticId, $criticIds)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $selected[] = $critic;
  7. }
  8. }
  9. return $selected;
  1. $updates[] = 'approved_at = :approved_at';
  2. $params[':approved_at'] = (new DateTime())->format('Y-m-d H:i:s');
  3. } elseif ($status === 'active') {
  4. $updates[] = 'started_at = :started_at';
  5. $params[':started_at'] = (new DateTime())->format('Y-m-d H:i:s');
  6. } elseif (in_array($status, ['completed', 'failed', 'cancelled'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $updates[] = 'completed_at = :completed_at';
  8. $params[':completed_at'] = (new DateTime())->format('Y-m-d H:i:s');
  9. }
  10. $sql = "UPDATE :table_rag_agent_objectives
  1. if ($actualType !== $expectedType) {
  2. $errors[] = "Expected type '{$expectedType}', got '{$actualType}'";
  3. }
  4. // Range validation for numeric types
  5. if (in_array($expectedType, ['int', 'float'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. if (isset($paramDef['min']) && $value < $paramDef['min']) {
  7. $errors[] = "Value {$value} is below minimum {$paramDef['min']}";
  8. }
  9. if (isset($paramDef['max']) && $value > $paramDef['max']) {
  10. $errors[] = "Value {$value} is above maximum {$paramDef['max']}";
  1. $errors[] = "Value {$value} is above maximum {$paramDef['max']}";
  2. }
  3. }
  4. // Enum validation
  5. if (isset($paramDef['allowed_values']) && !in_array($value, $paramDef['allowed_values'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $errors[] = "Value '{$value}' is not in allowed values: " . implode(', ', $paramDef['allowed_values']);
  7. }
  8. return [
  9. 'valid' => empty($errors),
  1. // Type conversion
  2. if ($key === 'enabled') {
  3. $config[$key] = (bool)$value;
  4. } elseif ($key === 'decay_factor') {
  5. $config[$key] = (float)$value;
  6. } elseif (in_array($key, ['period_seconds', 'recent_evaluation_count'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $config[$key] = (int)$value;
  8. }
  9. }
  10. return $config;
  1. && $this->consistencyScore >= 0.0
  2. && $this->consistencyScore <= 1.0
  3. && $this->expertiseAccuracy >= 0.0
  4. && $this->expertiseAccuracy <= 1.0
  5. && $this->totalEvaluations >= 0
  6. && in_array($this->status, ['bootstrapping', 'establishing', 'established']);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Get reputation as array for serialization
  10. *
  1. // Handle escaped quotes (e.g., \' or \")
  2. // Look for patterns like LIKE '%iPhone\'s%'
  3. $escapedPattern = '/LIKE\s+\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/i';
  4. if (preg_match_all($escapedPattern, $sql, $matches)) {
  5. foreach ($matches[1] as $pattern) {
  6. if (!in_array($pattern, $allMatches)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $allMatches[] = $pattern;
  8. }
  9. }
  10. }
  1. $relatedTable = $safeRelatedTable;
  2. }
  3. $prefix = CLICSHOPPING::getConfig('prefix_table');
  4. // Check if the related table exists
  5. if (in_array($relatedTable, $tables) || in_array($prefix . $relatedTable, $tables)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $actualTable = in_array($prefix . $relatedTable, $tables) ? $prefix . $relatedTable : $relatedTable;
  7. $this->tableRelationships[$table][$column] = $actualTable;
  8. }
  9. }
  10. }
  1. }
  2. $prefix = CLICSHOPPING::getConfig('prefix_table');
  3. // Check if the related table exists
  4. if (in_array($relatedTable, $tables) || in_array($prefix . $relatedTable, $tables)) {
  5. $actualTable = in_array($prefix . $relatedTable, $tables) ? $prefix . $relatedTable : $relatedTable;
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $this->tableRelationships[$table][$column] = $actualTable;
  7. }
  8. }
  9. }
  10. }
  1. 'score' => $evaluation->getOverallScore()
  2. ];
  3. // Collect strengths
  4. foreach ($evaluation->getStrengths() as $strength) {
  5. if (!in_array($strength, $allStrengths)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $allStrengths[] = $strength;
  7. }
  8. }
  9. // Collect improvements
  1. }
  2. }
  3. // Collect improvements
  4. foreach ($evaluation->getImprovements() as $improvement) {
  5. if (!in_array($improvement, $allImprovements)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $allImprovements[] = $improvement;
  7. }
  8. }
  9. }
  1. 'semantic_search',
  2. 'fallback'
  3. ];
  4. foreach ($steps as $step) {
  5. if (!in_array($step->getType(), $allowedTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return false;
  7. }
  8. }
  9. return true;
  1. $dependsOn = $metadata['depends_on'] ?? [];
  2. // Filter circular dependencies
  3. $filteredDependsOn = array_filter($dependsOn, function($depId) use ($cycles, $stepId) {
  4. foreach ($cycles as $cycle) {
  5. if (in_array($stepId, $cycle) && in_array($depId, $cycle)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. // This dependency creates a cycle
  7. return false;
  8. }
  9. }
  10. return true;
  1. {
  2. $stepIds = array_map(fn($step) => $step->getId(), $steps);
  3. foreach ($dependencies as $stepId => $deps) {
  4. foreach ($deps['depends_on'] as $depId) {
  5. if (!in_array($depId, $stepIds)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return false;
  7. }
  8. }
  9. }
  1. 'ALTER', 'TRUNCATE', 'REPLACE', 'SHOW', 'DESCRIBE', 'EXPLAIN'
  2. ];
  3. $firstWord = strtoupper(explode(' ', $input)[0]);
  4. if (in_array($firstWord, $sqlKeywords)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. return true;
  6. }
  7. if (preg_match('/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|TRUNCATE)\s+/i', $input)) {
  8. return true;
  1. // Handles queries where price keyword comes before "on [site]"
  2. if (preg_match('/\b(what|how|show|get|tell)\s+.*?\s+(on|at)\s+(\w+)/i', $query, $matches)) {
  3. $site = strtolower($matches[3]);
  4. // Exclude internal keywords
  5. if (!in_array($site, WebSearchPatterns::$internalKeywords)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $analysis['intent_type'] = 'web_search';
  7. $analysis['confidence'] = 0.95;
  8. $analysis['override_reason'] = "External site pattern detected: on/at $site";
  9. $analysis['detection_method'] = 'pattern_post_filter';
  10. return $analysis;
  1. // Also matches: "of [product] on [site]", "for [product] on [site]"
  2. if (preg_match('/\b(price|find|search|look|check|cheaper|available|of|for)\s+.*?\s+(on|at)\s+(\w+)/i', $query, $matches)) {
  3. $site = strtolower($matches[3]);
  4. // Exclude internal keywords
  5. if (!in_array($site, WebSearchPatterns::$internalKeywords)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $analysis['intent_type'] = 'web_search';
  7. $analysis['confidence'] = 0.95;
  8. $analysis['override_reason'] = "External site pattern detected: on/at $site";
  9. $analysis['detection_method'] = 'pattern_post_filter';
  10. return $analysis;
  1. 'delete_agent',
  2. 'modify_security_settings',
  3. 'access_sensitive_data'
  4. ];
  5. if (in_array($actionType, $criticalActions)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return true;
  7. }
  8. // Check for repeated violations
  9. $recentViolations = $this->getRecentViolationCount($agentId);
  1. 'delete_agent',
  2. 'modify_security_settings',
  3. 'access_sensitive_data'
  4. ];
  5. if (in_array($actionType, $criticalActions)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return 'critical';
  7. }
  8. // High severity actions
  9. $highSeverityActions = [
  1. 'approve_objective',
  2. 'cancel_objective',
  3. 'modify_agent_role'
  4. ];
  5. if (in_array($actionType, $highSeverityActions)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return 'high';
  7. }
  8. // Check context for severity indicators
  9. if (isset($context['repeated_attempt']) && $context['repeated_attempt'] === true) {
  1. // Filter interpretations to keep only selected types
  2. $analysis['interpretations'] = array_filter(
  3. $analysis['interpretations'],
  4. function($interp) use ($selectedTypes) {
  5. return in_array($interp['type'] ?? '', $selectedTypes);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. );
  8. // Re-index array
  9. $analysis['interpretations'] = array_values($analysis['interpretations']);
  1. $errors[] = "Step {$index}: Invalid type '{$step['type']}'";
  2. }
  3. // Validate unique ID
  4. if (isset($step['id'])) {
  5. if (in_array($step['id'], $existingIds)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $errors[] = "Step {$index}: Duplicate ID '{$step['id']}'";
  7. }
  8. if (!preg_match('/^step_\d+$/', $step['id'])) {
  9. $errors[] = "Step {$index}: ID must match pattern 'step_N'";
  1. // Additional metadata
  2. if (!empty($metadata)) {
  3. $parts[] = "Additional Context:";
  4. foreach ($metadata as $key => $value) {
  5. if (is_string($value) && !in_array($key, ['entity_type', 'entity_id'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $parts[] = "- {$key}: {$value}";
  7. }
  8. }
  9. $parts[] = "";
  10. }
  1. $errors[] = "Step {$index}: Missing required field '{$field}'";
  2. }
  3. }
  4. // Validate type
  5. if (isset($step['type']) && !in_array($step['type'], self::ALLOWED_STEP_TYPES)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $errors[] = "Step {$index}: Invalid type '{$step['type']}'";
  7. }
  8. // Validate unique ID
  9. if (isset($step['id'])) {
  1. $result['errors'][] = "Missing required field: {$field}";
  2. }
  3. }
  4. // 3. Validate complexity
  5. if (isset($json['complexity']) && !in_array($json['complexity'], self::COMPLEXITY_LEVELS)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $result['errors'][] = "Invalid complexity level: {$json['complexity']}";
  7. }
  8. // 4. Validate steps
  9. if (isset($json['steps'])) {
  1. if (isset($step['depends_on'])) {
  2. if (!is_array($step['depends_on'])) {
  3. $errors[] = "Step {$index}: 'depends_on' must be an array";
  4. } else {
  5. foreach ($step['depends_on'] as $depId) {
  6. if (!in_array($depId, $existingIds)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $errors[] = "Step {$index}: Dependency '{$depId}' references non-existent step";
  8. }
  9. }
  10. }
  11. }
  1. // Include outliers with reduced weight
  2. $totalWeightedScore = 0.0;
  3. $totalWeight = 0.0;
  4. foreach ($evaluations as $evaluation) {
  5. $weight = in_array($evaluation->getEvaluatorAgentId(), $outlierIds) ? 0.3 : 1.0;
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $totalWeightedScore += $evaluation->getOverallScore() * $weight;
  7. $totalWeight += $weight;
  8. }
  9. $finalScore = $totalWeight > 0 ? $totalWeightedScore / $totalWeight : $consensusScore;
  1. ));
  2. }
  3. // Calculate scores excluding outliers
  4. $nonOutlierEvaluations = array_filter($evaluations, function($evaluation) use ($outlierIds) {
  5. return !in_array($evaluation->getEvaluatorAgentId(), $outlierIds);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. });
  7. if (empty($nonOutlierEvaluations)) {
  8. // All evaluations are outliers, use median
  9. $allScores = array_map(function($eval) {
  1. private function mapTemporalColumnName(string $column, string $temporalPeriod, string $languageCode): string
  2. {
  3. // Check for period-related columns
  4. $periodColumns = ['period', 'month', 'quarter', 'semester', 'year', 'week', 'day', 'MONTH', 'QUARTER', 'YEAR', 'WEEK'];
  5. if (in_array($column, $periodColumns) || stripos($column, 'period') !== false) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return $this->getTemporalColumnLabel($temporalPeriod, $languageCode);
  7. }
  8. // Standard column name mapping
  9. return ucwords(str_replace('_', ' ', $column));
  1. }
  2. // Check if this is a period column that needs temporal formatting
  3. $periodColumns = ['period', 'month', 'quarter', 'semester', 'year', 'week', 'day', 'MONTH', 'QUARTER', 'YEAR', 'WEEK'];
  4. if (in_array($column, $periodColumns) || stripos($column, 'period') !== false) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. return $this->formatTemporalLabel($temporalPeriod, $value, $languageCode);
  6. }
  7. // Format numeric values
  8. if (is_numeric($value)) {
  1. }
  2. return false;
  3. }
  4. // Verify type matches requested types
  5. if (!in_array($subQuery['type'], $requestedTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. if ($this->debug) {
  7. $this->logDebug("Validation failed: sub-query {$index} type '{$subQuery['type']}' not in requested types");
  8. }
  9. return false;
  10. }
  1. }
  2. $filteredRow = [];
  3. foreach ($row as $key => $value) {
  4. if (!in_array($key, $systemFields)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $filteredRow[$key] = $value;
  6. }
  7. }
  8. return $filteredRow;
  1. $feedback_type = $row['feedback_type'] ?? '';
  2. $total += $count;
  3. if (\in_array($feedback_type, ['positive', 'helpful', 'thumbs_up'])) {
  4. $positive += $count;
  5. } elseif (\in_array($feedback_type, ['negative', 'unhelpful', 'thumbs_down'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $negative += $count;
  7. }
  8. }
  9. $satisfaction_rate = $total > 0 ? round(($positive / $total) * 100, 1) : 0;
  1. foreach ($results as $row) {
  2. $count = $row['count'] ?? 0;
  3. $feedback_type = $row['feedback_type'] ?? '';
  4. $total += $count;
  5. if (\in_array($feedback_type, ['positive', 'helpful', 'thumbs_up'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $positive += $count;
  7. } elseif (\in_array($feedback_type, ['negative', 'unhelpful', 'thumbs_down'])) {
  8. $negative += $count;
  9. }
  10. }
  1. ], $meta);
  2. // Ensure the scope array is initialized (though it should be by createScope/enterScope)
  3. $this->scopes[$this->currentScope] ??= [];
  4. if (!in_array($scopedKey, $this->scopes[$this->currentScope])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $this->scopes[$this->currentScope][] = $scopedKey;
  6. }
  7. if ($this->debug) {
  8. $this->securityLogger->logSecurityEvent("WorkingMemory set: {$scopedKey} = " . $this->formatValueForLog($value), 'info');
  1. if (in_array('analytics', $queryTypes) && in_array('web_search', $queryTypes)) {
  2. return 'price_comparison';
  3. }
  4. // Semantic + analytics
  5. if (in_array('semantic', $queryTypes) && in_array('analytics', $queryTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return 'semantic_analytics';
  7. }
  8. // Default for all other combinations
  9. return 'default';
  1. {
  2. sort($queryTypes);
  3. $typeKey = implode('_', $queryTypes);
  4. // Price comparison: analytics + web_search
  5. if (in_array('analytics', $queryTypes) && in_array('web_search', $queryTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. return 'price_comparison';
  7. }
  8. // Semantic + analytics
  9. if (in_array('semantic', $queryTypes) && in_array('analytics', $queryTypes)) {
  1. if (!isset($columns[$table])) {
  2. $columns[$table] = [];
  3. }
  4. if (!in_array($column, $columns[$table])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $columns[$table][] = $column;
  6. }
  7. }
  8. }
  9. }
  1. private function getFrequentlyQueriedColumns(string $table): array
  2. {
  3. $columns = [];
  4. foreach ($this->slowQueries as $query) {
  5. if (in_array($table, $query['analysis']['tables_accessed'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $whereColumns = $this->extractWhereColumns($query['sql']);
  7. if (isset($whereColumns[$table])) {
  8. foreach ($whereColumns[$table] as $column) {
  9. if (!isset($columns[$column])) {
  10. $columns[$column] = 0;
  1. * @return bool True if index exists
  2. */
  3. private function hasIndexOnColumn(array $indexes, string $column): bool
  4. {
  5. foreach ($indexes as $index) {
  6. if (in_array($column, $index['columns'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return true;
  8. }
  9. }
  10. return false;
  11. }
  1. }
  2. break;
  3. }
  4. // Check for "per {period}" pattern
  5. if (preg_match('/\bper\s+' . preg_quote($variant, '/') . '\b/i', $query)) {
  6. if (!in_array($basePeriod, $detected)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $detected[] = $basePeriod;
  8. }
  9. break;
  10. }
  11. }
  1. // First pass: Check for "by {period}" or "per {period}" patterns
  2. foreach ($basePeriods as $basePeriod => $variants) {
  3. foreach ($variants as $variant) {
  4. // Check for "by {period}" pattern
  5. if (preg_match('/\bby\s+' . preg_quote($variant, '/') . '\b/i', $query)) {
  6. if (!in_array($basePeriod, $detected)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $detected[] = $basePeriod;
  8. }
  9. break;
  10. }
  11. // Check for "per {period}" pattern
  1. foreach ($basePeriods as $basePeriod => $variants) {
  2. foreach ($variants as $variant) {
  3. // Check if the period appears anywhere in the query
  4. if (preg_match('/\b' . preg_quote($variant, '/') . '\b/i', $query)) {
  5. if (!in_array($basePeriod, $detected)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $detected[] = $basePeriod;
  7. }
  8. break;
  9. }
  10. }
  1. ]);
  2. $this->workingMemory->set('reasoning_result', $reasoning);
  3. // default to semantic (safer fallback than analytics)
  4. if ($intent['confidence'] < 0.6 && !in_array($intent['type'], ['analytics', 'semantic', 'web_search', 'hybrid'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $this->securityLogger->logStructured(
  6. 'warning',
  7. 'OrchestratorAgent',
  8. 'fallback_to_semantic',
  9. [
  1. $hasWebSearchKeyword = true;
  2. break;
  3. }
  4. }
  5. if ($hasWebSearchKeyword && !in_array('web_search', $intent['sub_types'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $intent['sub_types'][] = 'web_search';
  7. if ($this->debug) {
  8. $this->securityLogger->logStructured('info', 'OrchestratorAgent', 'web_search_detection_fallback', [
  9. 'query' => substr($queryToProcess, 0, 100),
  1. break;
  2. }
  3. }
  4. // If web search keyword found but not in sub_types, add it
  5. if ($hasWebSearchKeyword && !in_array('web_search', $intent['sub_types'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $intent['sub_types'][] = 'web_search';
  7. if ($this->debug) {
  8. $this->securityLogger->logStructured('info', 'OrchestratorAgent', 'web_search_detection', [
  9. 'query' => substr($queryToProcess, 0, 100),
  1. // À implémenter avec Slack API
  2. });
  3. // Canal: SMS (placeholder)
  4. $this->addNotificationChannel('sms', function($alert) {
  5. if (in_array($alert['severity'], [self::SEVERITY_ERROR, self::SEVERITY_CRITICAL])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. // À implémenter avec votre système SMS
  7. }
  8. });
  9. }
  1. }
  2. $targetTable = $prefix . $pluralEntity . '_embedding';
  3. // Only search in the specific table if it exists
  4. if (in_array($targetTable, $embeddingTables)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $embeddingTables = [$targetTable];
  6. if ($this->debug) {
  7. $this->logger->logSecurityEvent(
  8. "Filtered to specific entity table: {$targetTable}",
  1. self::CONFIG_KEY_REPUTATION_DECAY_RECENT_EVAL_COUNT,
  2. self::CONFIG_KEY_REPUTATION_BOOTSTRAP_THRESHOLD_LOW,
  3. self::CONFIG_KEY_REPUTATION_BOOTSTRAP_THRESHOLD_HIGH
  4. ])) {
  5. $config[$key] = (int)$value;
  6. } elseif (in_array($key, [
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. self::CONFIG_KEY_CONSENSUS_THRESHOLD,
  8. self::CONFIG_KEY_REPUTATION_DECAY_FACTOR,
  9. self::CONFIG_KEY_REPUTATION_DECAY_RATE,
  10. self::CONFIG_KEY_REPUTATION_WEIGHT_CONSENSUS,
  11. self::CONFIG_KEY_REPUTATION_WEIGHT_FEEDBACK,
  1. // Type conversion
  2. if ($key === self::CONFIG_KEY_ENABLED ||
  3. $key === self::CONFIG_KEY_FALLBACK_TO_HYBRID ||
  4. $key === self::CONFIG_KEY_REPUTATION_DECAY_ENABLED) {
  5. $config[$key] = self::parseBool($value);
  6. } elseif (in_array($key, [
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. self::CONFIG_KEY_CRITICS_PER_EVALUATION,
  8. self::CONFIG_KEY_MIN_CRITICS_REQUIRED,
  9. self::CONFIG_KEY_ACTOR_RETRY_ATTEMPTS,
  10. self::CONFIG_KEY_CRITIC_EVALUATION_TIMEOUT,
  11. self::CONFIG_KEY_MAX_CONCURRENT_ACTIONS_PER_ACTOR,
  1. }
  2. public function canHandle(array $results): bool
  3. {
  4. $type = $results['type'] ?? '';
  5. return in_array($type, ['analytics_results', 'analytics_response']);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. public function format(array $results): array
  8. {
  9. $question = $results['question'] ?? $results['query'] ?? 'Unknown request';
  1. public function isHealthy(): bool
  2. {
  3. $snapshot = $this->collectMetrics();
  4. $health = $this->calculateOverallHealth($snapshot);
  5. return in_array($health['status'], ['healthy', 'warning']);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. /**
  8. * Gets API metrics
  9. *
  1. // Moderate divergence - use weighted average excluding outliers
  2. $outliers = $context['outliers'] ?? [];
  3. $outlierScores = array_column($outliers, 'score');
  4. $validScores = array_filter($scores, function($score) use ($outlierScores) {
  5. return !in_array($score, $outlierScores);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. });
  7. if (!empty($validScores)) {
  8. $finalScore = array_sum($validScores) / count($validScores);
  9. $reasoning[] = "Moderate divergence detected (agreement: " . round($agreementLevel * 100, 1) . "%)";
  1. bool $enabled = true
  2. ): bool {
  3. self::initialize();
  4. // Validate type
  5. if (!in_array($type, [self::AGENT_TYPE_ACTOR, self::AGENT_TYPE_CRITIC, self::AGENT_TYPE_HYBRID])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. if (self::$debug) {
  7. error_log("AgentActivationConfig: Invalid agent type: {$type}");
  8. }
  9. return false;
  10. }
  1. }
  2. $sourceAttr = $result['source_attribution'];
  3. // If source is RAG, verify embedding data exists
  4. if (in_array($sourceAttr['source_type'], ['rag', 'semantic', 'embedding'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. if (!$this->hasEmbeddingData($result)) {
  6. $validationErrors[] = "RAG source but no document/embedding data found";
  7. return false;
  8. }
  9. }
  1. throw new \Exception('Missing required fields in JSON response');
  2. }
  3. // Validate type (must be one of 4 categories)
  4. $validTypes = ['analytics', 'semantic', 'hybrid', 'web_search'];
  5. if (!in_array($result['type'], $validTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. throw new \Exception('Invalid type: ' . $result['type']);
  7. }
  8. // Validate confidence (must be between 0.0 and 1.0)
  9. $confidence = (float)$result['confidence'];
  1. $response = Gpt::getGptResponse($prompt, 20);
  2. $type = trim(strtolower($response));
  3. // Validate old prompt response - default to 'semantic' if invalid
  4. if (!in_array($type, ['analytics', 'semantic'])) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. $type = 'semantic'; // Default fallback
  6. }
  7. // Return in new format with default values
  8. return [
  1. $domains = [];
  2. foreach ($criteria as $outputType => $criterion) {
  3. if (is_object($criterion) && method_exists($criterion, 'getDomain')) {
  4. $domain = $criterion->getDomain();
  5. if (!empty($domain) && !in_array($domain, $domains)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $domains[] = $domain;
  7. }
  8. }
  9. }
  1. * @throws \InvalidArgumentException If agent type is invalid
  2. */
  3. public function getSystemMessage(string $agentType = 'analytics', string $query = '', string $modelName = 'gpt-4o-mini'): string
  4. {
  5. // Validate agent type
  6. if (!in_array($agentType, self::AGENT_TYPES)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. throw new \InvalidArgumentException("Invalid agent type: {$agentType}. Supported types: " . implode(', ', self::AGENT_TYPES));
  8. }
  9. // Store parameters for buildSystemMessage()
  10. $this->agentType = $agentType;
  1. public function canHandle(array $results): bool
  2. {
  3. $type = $results['type'] ?? '';
  4. // Note: 'hybrid' is now handled by HybridFormatter (priority 105)
  5. // ComplexQueryFormatter handles 'complex_query' and legacy 'hybrid_results'
  6. return in_array($type, ['complex_query', 'hybrid_results']);
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Format complex query results for display
  10. *
  1. error_log("ConversationMemory::recordFeedback - Interaction ID: {$interactionId}");
  2. error_log("ConversationMemory::recordFeedback - Feedback Type: {$feedbackType}");
  3. // Validate feedback type
  4. $validTypes = ['positive', 'negative', 'correction'];
  5. if (!in_array($feedbackType, $validTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. error_log("ConversationMemory::recordFeedback - INVALID TYPE: {$feedbackType}");
  7. $this->securityLogger->logSecurityEvent(
  8. "Invalid feedback type: {$feedbackType}. Must be one of: " . implode(', ', $validTypes),
  9. 'warning'
  10. );
  1. */
  2. public function setDefaultEngine(string $engine): void
  3. {
  4. $allowed = ['google', 'bing', 'duckduckgo', 'yahoo'];
  5. if (!in_array($engine, $allowed)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. throw new \InvalidArgumentException("Engine must be one of: " . implode(', ', $allowed));
  7. }
  8. $this->defaultEngine = $engine;
  9. }
  1. // Extract type
  2. $type = $classificationResult['type'] ?? 'semantic';
  3. // Validate response (now supports 4 categories)
  4. $validTypes = ['analytics', 'semantic', 'hybrid', 'web_search'];
  5. if (!in_array($type, $validTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. if ($this->debug) {
  7. $this->logger->logStructured(
  8. 'warning',
  9. 'QueryClassifier',
  1. public function recordFeedback(string $interactionId,string $feedbackType, array $feedbackData): bool
  2. {
  3. try {
  4. // Validate feedback type
  5. $validTypes = ['positive', 'negative', 'correction'];
  6. if (!in_array($feedbackType, $validTypes)) {
    in_array() should be called with the third parameter set to true to enable strict comparison and avoid type juggling bugs.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. throw new \InvalidArgumentException("Invalid feedback type: {$feedbackType}");
  8. }
  9. // Extract required data
  10. $userId = $feedbackData['user_id'] ?? 'unknown';

Your project should not use deprecated PHP features 5

More information: https://insight.symfony.com/what-we-analyse/php.use_deprecated_function

  1. $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  2. $error = curl_error($ch);
  3. $info = curl_getinfo($ch);
  4. curl_close($ch);
    curl_close() has been deprecated in PHP 8.5 and will be removed from PHP in the next major version.
    Time to fix: about 2 hours
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. $this->stats['messages_sent']++;
  6. $this->stats['last_activity'] = time();
  1. $response = curl_exec($ch);
  2. $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  3. $error = curl_error($ch);
  4. $info = curl_getinfo($ch);
  5. curl_close($ch);
    curl_close() has been deprecated in PHP 8.5 and will be removed from PHP in the next major version.
    Time to fix: about 2 hours
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. if ($error) {
  7. $this->logger->error('cURL connection error', ['error' => $error, 'url' => $healthUrl]);
  8. throw new McpConnectionException("Connection failed: {$error}");
  9. }
  1. if ($ext != 'webp') {
  2. if ($img = imagecreatefromstring(file_get_contents($big_image_resized_path))) {
  3. $image = str_replace($ext, 'webp', $image);
  4. $this->imageResample->save($this->template->getDirectoryPathTemplateShopImages() . $image, $ext);
  5. imagedestroy($img);
    imagedestroy() has been deprecated in PHP 8.5 and will be removed from PHP in the next major version.
    Time to fix: about 2 hours
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. }
  7. if (file_exists($big_image_resized_path)) {
  8. unlink($big_image_resized_path);
  9. }
  1. $result = curl_exec($curl);
  2. if (empty($result)) {
  3. $info = curl_getinfo($curl);
  4. curl_close($curl);
    curl_close() has been deprecated in PHP 8.5 and will be removed from PHP in the next major version.
    Time to fix: about 2 hours
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  5. } else {
  6. $info = 'error';
  7. }
  8. return $info;
  1. $tmp = tempnam('.', 'gif');
  2. if (!$tmp)
  3. $this->Error('Unable to create a temporary file');
  4. if (!imagepng($im, $tmp))
  5. $this->Error('Error while saving to temporary file');
  6. imagedestroy($im);
    imagedestroy() has been deprecated in PHP 8.5 and will be removed from PHP in the next major version.
    Time to fix: about 2 hours
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  7. $info = $this->_parsepng($tmp);
  8. unlink($tmp);
  9. return $info;
  10. }

Mutable DateTime should be avoided in favor of DateTimeImmutable 38

More information: https://insight.symfony.com/what-we-analyse/php.prefer_date_time_immutable

New rule! We've recently added this rule to Insight. Don't be surprised to see new suggestions even though the codebase didn't change.
  1. criticScore: (float)$data['critic_score'],
  2. consensusScore: (float)$data['consensus_score'],
  3. withinThreshold: (bool)$data['within_threshold'],
  4. alignmentDelta: (float)$data['alignment_delta'],
  5. feedbackAccepted: (bool)$data['feedback_accepted'],
  6. evaluatedAt: new \DateTime($data['evaluated_at']),
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. metadata: $data['metadata'] ?? []
  8. );
  9. }
  10. }
  1. *
  2. * @return int
  3. */
  4. public function getElapsedTime(): int
  5. {
  6. $now = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $now->getTimestamp() - $this->createdAt->getTimestamp();
  8. }
  9. /**
  10. * Get the remaining time until estimated completion in seconds
  1. updated_at = :updated_at
  2. WHERE expertise_level = :expertise_level";
  3. $stmt = $this->db->prepare($sql);
  4. $stmt->bindValue(':expertise_weight', (float)$weight);
  5. $stmt->bindValue(':updated_at', (new DateTime())->format('Y-m-d H:i:s'));
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $stmt->bindValue(':expertise_level', $level);
  7. $stmt->execute();
  8. if ($this->debug) {
  9. error_log(sprintf(
  1. $interval = $startDate->diff($endDate);
  2. return [
  3. 'report_id' => $this->generateUuid(),
  4. 'report_type' => $reportType,
  5. 'generated_at' => (new DateTime())->format('Y-m-d H:i:s'),
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. 'period' => [
  7. 'start_date' => $startDate->format('Y-m-d H:i:s'),
  8. 'end_date' => $endDate->format('Y-m-d H:i:s'),
  9. 'duration_days' => $interval->days,
  10. 'duration_hours' => ($interval->days * 24) + $interval->h
  1. $alert->criticId = $criticId;
  2. $alert->alertType = $alertType;
  3. $alert->severity = $severity;
  4. $alert->message = $message;
  5. $alert->context = $context;
  6. $alert->createdAt = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $alert;
  8. }
  9. /**
  1. $this->version = $version;
  2. $this->senderId = $senderId;
  3. $this->recipientId = $recipientId;
  4. $this->payload = $payload;
  5. $this->correlationId = $correlationId;
  6. $this->timestamp = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $this->retryCount = 0;
  8. $this->metadata = [
  9. 'created_at' => $this->timestamp->format('Y-m-d H:i:s.u'),
  10. 'protocol_version' => $version
  11. ];
  1. }
  2. // Distribute feedback into weekly buckets
  3. foreach ($feedbackItems as $item) {
  4. $createdAt = new DateTime($item['created_at']);
  5. $now = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $daysDiff = $now->diff($createdAt)->days;
  7. $weekIndex = floor($daysDiff / 7);
  8. if ($weekIndex < $weeks) {
  9. $weekKey = "week_" . ($weeks - $weekIndex);
  1. *
  2. * @return int Elapsed time in seconds
  3. */
  4. public function getElapsedSeconds(): int
  5. {
  6. $now = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $now->getTimestamp() - $this->startedAt->getTimestamp();
  8. }
  9. /**
  10. * Gets the remaining time before timeout
  1. }
  2. $this->createdAt = new DateTime($row['created_at']);
  3. if ($row['completed_at']) {
  4. $this->completedAt = new DateTime($row['completed_at']);
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. }
  6. if ($row['metrics']) {
  7. $this->metrics = json_decode($row['metrics'], true);
  8. }
  1. $this->evaluations = $evaluations;
  2. $this->consensusScore = $consensusScore;
  3. $this->consensusReached = $consensusReached;
  4. $this->aggregatedFeedback = $aggregatedFeedback;
  5. $this->outliers = $outliers;
  6. $this->createdAt = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. public function getConsensusId(): string { return $this->consensusId; }
  9. public function getOutputId(): string { return $this->outputId; }
  10. public function getEvaluations(): array { return $this->evaluations; }
  1. $reputation->consistencyScore = 0.75;
  2. $reputation->expertiseAccuracy = 0.75;
  3. $reputation->totalEvaluations = 0;
  4. $reputation->status = 'bootstrapping';
  5. $reputation->calculatedAt = new DateTime();
  6. $reputation->lastDecayAt = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $reputation;
  8. }
  9. /**
  1. $this->finalScore = $finalScore;
  2. $this->agreementLevel = $agreementLevel;
  3. $this->outliers = $outliers;
  4. $this->discussionLog = $discussionLog;
  5. $this->createdAt = new DateTime();
  6. $this->resolvedAt = $consensusReached ? new DateTime() : null;
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Generates a unique session ID
  10. *
  1. */
  2. private function logOperation(string $operation, array $data): void
  3. {
  4. $this->normalizationLog[] = [
  5. 'operation' => $operation,
  6. 'timestamp' => (new \DateTime())->format('Y-m-d H:i:s.u'),
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. 'data' => $data
  8. ];
  9. }
  10. }
  1. $stmt = $this->db->prepare($sql);
  2. $stmt->bindValue(':agent_id', $agentId);
  3. $stmt->bindValue(':output_type', $outputType);
  4. $stmt->bindValue(':capability_level', $level);
  5. $stmt->bindValue(':updated_at', (new DateTime())->format('Y-m-d H:i:s'));
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $stmt->execute();
  7. } else {
  8. // Create new capability
  9. $this->registerCapability($agentId, $outputType, $level);
  10. }
  1. $this->clarityScore = $scores['clarity'];
  2. $this->overallScore = $this->calculateOverallScore($scores);
  3. $this->feedback = $feedback;
  4. $this->strengths = $strengths;
  5. $this->improvements = $improvements;
  6. $this->evaluatedAt = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. private function calculateOverallScore(array $scores): float
  9. {
  10. // Weighted average: accuracy (35%), completeness (25%), efficiency (25%), clarity (15%)
  1. $this->predictedOutcome = $predictedOutcome;
  2. $this->confidenceEstimate = max(0.0, min(1.0, $confidenceEstimate));
  3. $this->identifiedRisks = $identifiedRisks;
  4. $this->successProbabilities = $successProbabilities;
  5. $this->recommendedMitigations = $recommendedMitigations;
  6. $this->predictedAt = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. public function getPredictionId(): string { return $this->predictionId; }
  9. public function getActionId(): string { return $this->actionId; }
  10. public function getPredictorAgentId(): string { return $this->predictorAgentId; }
  1. // Generate recommendations
  2. $recommendations = $this->generateRecommendations($correlation, $qualityTrends, $weightingImpact);
  3. $report = [
  4. 'period' => 'Last 30 days',
  5. 'generated_at' => (new DateTime())->format('Y-m-d H:i:s'),
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. 'total_consensus_operations' => count($monthlyConsensus),
  7. 'correlation_analysis' => $correlation,
  8. 'quality_trends' => $qualityTrends,
  9. 'weighting_impact' => $weightingImpact,
  10. 'recommendations' => $recommendations
  1. * @return string
  2. */
  3. private function formatDate(string $dateString): string
  4. {
  5. try {
  6. $dt = new \DateTime($dateString);
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $dt->format('d/m/Y H:i');
  8. } catch (\Throwable) {
  9. return $dateString;
  10. }
  11. }
  1. $outcome->criticScore = (float)($data['criticScore'] ?? $data['critic_score'] ?? 0.0);
  2. $outcome->consensusScore = (float)($data['consensusScore'] ?? $data['consensus_score'] ?? 0.0);
  3. $outcome->withinThreshold = (bool)($data['withinThreshold'] ?? $data['within_threshold'] ?? false);
  4. $outcome->alignmentDelta = (float)($data['alignmentDelta'] ?? $data['alignment_delta'] ?? 0.0);
  5. $outcome->feedbackAccepted = (bool)($data['feedbackAccepted'] ?? $data['feedback_accepted'] ?? false);
  6. $outcome->evaluatedAt = new \DateTime($data['evaluatedAt'] ?? $data['evaluated_at'] ?? 'now');
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $outcome;
  8. }
  9. /**
  1. $this->producerAgentId = $producerAgentId;
  2. $this->output = $output;
  3. $this->outputType = $outputType;
  4. $this->executionMetrics = $executionMetrics;
  5. $this->executionContext = $executionContext;
  6. $this->timestamp = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $this->status = $status;
  8. }
  9. public function getResultId(): string { return $this->resultId; }
  10. public function getActionId(): string { return $this->actionId; }
  1. }
  2. public function acknowledge(): void
  3. {
  4. $this->acknowledged = true;
  5. $this->acknowledgedAt = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. }
  7. public function getFeedbackId(): string { return $this->feedbackId; }
  8. public function getTargetActorId(): string { return $this->targetActorId; }
  9. public function getOutputId(): string { return $this->outputId; }
  1. $this->staticConsensus = $staticConsensus;
  2. $this->consensusDifference = $consensusDifference;
  3. $this->weightedScores = $weightedScores;
  4. $this->confidenceLevel = $confidenceLevel;
  5. $this->consensusQuality = $consensusQuality;
  6. $this->calculatedAt = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. public function getEvaluationId(): string
  9. {
  10. return $this->evaluationId;
  1. * @return string
  2. */
  3. private function formatDate(string $dateString): string
  4. {
  5. try {
  6. $dt = new \DateTime($dateString);
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $dt->format('d/m/Y H:i');
  8. } catch (\Throwable) {
  9. return $dateString;
  10. }
  11. }
  1. $this->evaluatorAgentId = $evaluatorAgentId;
  2. $this->outputId = $outputId;
  3. $this->feedback = $feedback;
  4. $this->strengths = $strengths;
  5. $this->improvements = $improvements;
  6. $this->evaluatedAt = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Validates a score value
  10. *
  1. 'consistencyScore' => (float)$row['consistency_score'],
  2. 'expertiseAccuracy' => (float)$row['expertise_accuracy'],
  3. 'totalEvaluations' => (int)$row['total_evaluations'],
  4. 'status' => $row['status'],
  5. 'calculatedAt' => new \DateTime($row['calculated_at']),
  6. 'lastDecayAt' => new \DateTime($row['last_decay_at'])
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. ];
  8. }
  9. return $reputations;
  10. }
  1. $this->normalizedWeights = $normalizedWeights;
  2. $this->explanations = $explanations;
  3. $this->overallRationale = $overallRationale;
  4. $this->factorAnalysis = $factorAnalysis;
  5. $this->bounds = $bounds;
  6. $this->calculatedAt = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $this->isFallback = $isFallback;
  8. $this->fallbackReason = $fallbackReason;
  9. }
  10. public function getEvaluationId(): string
  1. try {
  2. $Q = $this->db->prepare('SELECT date_created FROM :table_products_cockpit_ai_rule_adjustments WHERE rule_key = :key ORDER BY date_created DESC LIMIT 1');
  3. $Q->bindValue(':key', $ruleKey);
  4. $Q->execute();
  5. if (!$Q->fetch()) return true;
  6. return (new \DateTime())->diff(new \DateTime($Q->value('date_created')))->days >= 7;
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. } catch (\Throwable) {
  8. return true;
  9. }
  10. }
  1. $days = 1;
  2. if ($startDate && $endDate) {
  3. $interval = $startDate->diff($endDate);
  4. $days = max(1, $interval->days);
  5. } elseif ($startDate) {
  6. $interval = $startDate->diff(new DateTime());
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $days = max(1, $interval->days);
  8. }
  9. // Get breakdown by evaluator
  10. $byEvaluator = $this->getEvaluationBreakdown('evaluator_agent_id', $whereClause, $params);
  1. $history->criticScore = $criticScore;
  2. $history->alignmentDelta = abs($consensusScore - $criticScore);
  3. $history->reputationImpact = $newReputation - $oldReputation;
  4. $history->oldReputation = $oldReputation;
  5. $history->newReputation = $newReputation;
  6. $history->recordedAt = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $history;
  8. }
  9. /**
  1. $history->criticScore = $criticScore;
  2. $history->alignmentDelta = $alignmentDelta;
  3. $history->reputationImpact = $newReputation - $oldReputation;
  4. $history->oldReputation = $oldReputation;
  5. $history->newReputation = $newReputation;
  6. $history->recordedAt = new DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. $this->store->saveHistory($history);
  8. }
  9. /**
  1. $alert->message = $row['message'];
  2. $alert->context = $row['context'] ? json_decode($row['context'], true) : null;
  3. $alert->acknowledged = (bool)$row['acknowledged'];
  4. $alert->acknowledgedBy = $row['acknowledged_by'];
  5. $alert->acknowledgedAt = $row['acknowledged_at'] ? new \DateTime($row['acknowledged_at']) : null;
  6. $alert->createdAt = new \DateTime($row['created_at']);
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $alert;
  8. }
  9. /**
  1. $this->userId = $userId;
  2. $this->languageId = $languageId;
  3. $this->systemState = $systemState;
  4. $this->userPreferences = $userPreferences;
  5. $this->environmentalData = $environmentalData;
  6. $this->timestamp = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. public function getContextId(): string { return $this->contextId; }
  9. public function getUserId(): string { return $this->userId; }
  10. public function getLanguageId(): int { return $this->languageId; }
  1. $factors['seo_score'] = new ScoreFactor(null, 100.0, notAnalyzed: true);
  2. }
  3. // REQ-SC-01 : Récupération de l'âge du produit et du max catalogue
  4. $dateAdded = new \DateTime($product['products_date_added'] ?? 'now');
  5. $ageDays = (int) $dateAdded->diff(new \DateTime())->format('%a');
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. $maxDays = $context->catalog->ageMax ?? 365;
  7. // Ajout du facteur de fraîcheur
  8. $factors['creation_date'] = new CreationDateFactor($ageDays, $maxDays);
  1. criticScore: (float)$job['critic_score'],
  2. consensusScore: (float)$job['consensus_score'],
  3. withinThreshold: abs($job['critic_score'] - $job['consensus_score']) < 0.1,
  4. alignmentDelta: (float)$job['alignment_delta'],
  5. feedbackAccepted: (bool)$job['feedback_accepted'],
  6. evaluatedAt: new \DateTime(),
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. metadata: json_decode($job['metadata'], true) ?? []
  8. );
  9. // Process reputation update
  10. $this->reputationTracker->trackEvaluation($outcome);
  1. $history->criticScore = (float)$row['critic_score'];
  2. $history->alignmentDelta = (float)$row['alignment_delta'];
  3. $history->reputationImpact = (float)$row['reputation_impact'];
  4. $history->oldReputation = (float)$row['old_reputation'];
  5. $history->newReputation = (float)$row['new_reputation'];
  6. $history->recordedAt = new \DateTime($row['recorded_at']);
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. return $history;
  8. }
  9. /**
  1. $this->evaluations = $evaluations;
  2. $this->reputations = $reputations;
  3. $this->agreementLevel = $agreementLevel;
  4. $this->confidence = $confidence;
  5. $this->stability = $stability;
  6. $this->calculatedAt = new \DateTime();
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. }
  8. /**
  9. * Get consensus result as array for serialization
  10. *
  1. 'criticScore' => (float)$row['critic_score'],
  2. 'consensusScore' => (float)$row['consensus_score'],
  3. 'withinThreshold' => (bool)$row['within_threshold'],
  4. 'alignmentDelta' => (float)$row['alignment_delta'],
  5. 'feedbackAccepted' => (bool)$row['feedback_accepted'],
  6. 'evaluatedAt' => new \DateTime($row['evaluated_at'])
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  7. ];
  8. }
  9. return $outcomes;
  10. }
  1. // Generate alerts
  2. $alertCount = $this->generateAlerts($allIssues);
  3. return [
  4. 'detection_run_at' => (new DateTime())->format('Y-m-d H:i:s'),
    Use DateTimeImmutable instead of DateTime.
    Time to fix: about 30 minutes
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  5. 'period' => [
  6. 'start_date' => $startDate ? $startDate->format('Y-m-d H:i:s') : 'all time',
  7. 'end_date' => $endDate ? $endDate->format('Y-m-d H:i:s') : 'now'
  8. ],
  9. 'issues_detected' => [