Your project should use dedicated PHP string functions 5

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

  1. * @param string $ip The IP address to check
  2. * @param string $range The CIDR range (e.g., '192.168.1.0/24')
  3. */
  4. public static function ipInRange(string $ip, string $range): bool
  5. {
  6. if (strpos($range, '/') === false) {
    Consider replacing strpos() with str_contains() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  7. return $ip === $range;
  8. }
  9. list($subnet, $bits) = explode('/', $range);
  10. $ip = ip2long($ip);
  • gyakutsuki

    not included
  1. error_log('[WebSearchFormatter] Formatting web search results\n');
  2. error_log('[WebSearchFormatter] Result keys: ' . implode(', ', array_keys($results)) . "\n");
  3. error_log('[WebSearchFormatter] Has text_response: ' . (isset($results['text_response']) ? 'YES' : 'NO') . "\n");
  4. if (isset($results['text_response'])) {
  5. $isHtml = (strpos($results['text_response'], '<') !== false);
    Consider replacing strpos() with str_contains() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. error_log('[WebSearchFormatter] text_response is HTML: ' . ($isHtml ? 'YES' : 'NO') . "\n");
  7. error_log('[WebSearchFormatter] text_response length: ' . strlen($results['text_response']) . "\n");
  8. }
  9. }
  • gyakutsuki

    not included
  1. $isHtmlContent = false;
  2. if (isset($results['text_response']) && !empty($results['text_response'])) {
  3. $interpretationText = $results['text_response'];
  4. // Check if text_response contains HTML (from ResultSynthesizer)
  5. $isHtmlContent = (strpos($interpretationText, '<div') !== false || strpos($interpretationText, '<p>') !== false);
    Consider replacing strpos() with str_contains() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. } elseif (isset($results['interpretation']) && $results['interpretation'] !== 'Array') {
  7. $interpretationText = $results['interpretation'];
  8. } elseif (isset($results['response']) && !empty($results['response'])) {
  9. $interpretationText = $results['response'];
  10. }
  • gyakutsuki

    not included
  1. $Qcategories->execute();
  2. $categories_array = $Qcategories->fetchAll();
  3. foreach ($categories_array as $cat) {
  4. $catLower = strtolower($cat['categories_name'] ?? '');
  5. if (strpos($translated, $catLower) !== false) {
    Consider replacing strpos() with str_contains() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by ClicShopping
  6. $intent['entities']['category'] = $catLower;
  7. $matchWeight += 0.8;
  8. $totalWeight += 1;
  9. break;
  10. }
  • gyakutsuki

    not included
  1. if ($output !== null) {
  2. // Envoi des Headers HTTP
  3. header('Content-Type: ' . $mimeType);
  4. // Détermine l'extension et encode si c'est du JSON
  5. if (strpos($mimeType, 'json') !== false) {
    Consider replacing strpos() with str_contains() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by clicshopping
  6. // S'assurer que la sortie est un tableau/objet avant d'encoder
  7. if (is_array($output) || is_object($output)) {
  8. $output = json_encode($output, JSON_PRETTY_PRINT);
  9. }
  10. }
  • gyakutsuki

    not included