Issues (12)

src/google/TestProxy.php (2 issues)

Labels
1
<?php
2
3
namespace rOpenDev\Google;
4
5
class TestProxy
6
{
7
    protected $types;
8
9
    public static function go($proxy)
10
    {
11
        $current = new self();
12
13
        return $current->isPorxyValid($proxy);
0 ignored issues
show
The method isPorxyValid() does not exist on rOpenDev\Google\TestProxy. Did you maybe mean isProxyValid()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
        return $current->/** @scrutinizer ignore-call */ isPorxyValid($proxy);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
14
    }
15
16
    /**
17
     * Test si un proxy n'est pas déjà cramé par Google. Si aucun proxy n'est enregistré pour
18
     * la requête (via setProxy), la fonction test l'IP locale.
19
     *
20
     * @return bool
21
     */
22
    public function isProxyValid(?string $proxy = null)
23
    {
24
        $keywords = ['bateau', 'avion', 'navire', 'seconde', 'bac', 'piscine', 'fuser', 'place', 'homme', 'femme',  'quad', 'moto', 'velo',
25
            'enfant', 'poilu', 'voiture', 'oiseau', 'singe', 'animaux', 'nature', 'paysage', 'jeux', 'maison', 'paysage', 'jardin', ];
26
27
        $GoogleSerp = new Search($keywords[array_rand($keywords)]);
28
        $GoogleSerp->setTld('fr')->setLanguage('fr')->setSleep(0)->setNbrPage(1)->setCache(false);
0 ignored issues
show
The call to rOpenDev\Google\Search::setCache() has too few arguments starting with source. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $GoogleSerp->setTld('fr')->setLanguage('fr')->setSleep(0)->setNbrPage(1)->/** @scrutinizer ignore-call */ setCache(false);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
29
        if ($proxy) {
30
            $GoogleSerp->setProxy($proxy);
31
        }
32
        $r = $GoogleSerp->extractResults();
33
34
        return false === $r || empty($r) ? false : true;
35
    }
36
}
37