These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Spider package. |
||
5 | * |
||
6 | * (c) Matthijs van den Bos <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace VDB\Spider\Tests\Discoverer; |
||
13 | |||
14 | use VDB\Spider\Discoverer\XPathExpressionDiscoverer; |
||
15 | use VDB\Spider\Discoverer\DiscovererSet; |
||
16 | use VDB\Spider\Filter\Prefetch\UriFilter; |
||
17 | |||
18 | /** |
||
19 | * |
||
20 | */ |
||
21 | class DiscovererSetTest extends DiscovererTestCase |
||
22 | { |
||
23 | /** |
||
24 | * @var DiscovererSet |
||
25 | */ |
||
26 | private $discovererSet; |
||
27 | |||
28 | |||
29 | public function setUp(): void |
||
30 | { |
||
31 | parent::setUp(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @covers VDB\Spider\Discoverer\DiscovererSet |
||
36 | */ |
||
37 | public function testConstructor() |
||
38 | { |
||
39 | $this->discovererSet = new DiscovererSet([new XPathExpressionDiscoverer("//a")]); |
||
40 | |||
41 | $uris = $this->discovererSet->discover($this->spiderResource); |
||
42 | $this->assertCount(1, $uris); |
||
0 ignored issues
–
show
|
|||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @covers VDB\Spider\Discoverer\DiscovererSet |
||
47 | */ |
||
48 | public function testSetDiscoverer() |
||
49 | { |
||
50 | $this->discovererSet = new DiscovererSet(); |
||
51 | $this->discovererSet->set(new XPathExpressionDiscoverer("//a")); |
||
52 | |||
53 | $uris = $this->discovererSet->discover($this->spiderResource); |
||
54 | $this->assertCount(1, $uris); |
||
0 ignored issues
–
show
$uris is of type array<integer,object<VDB...scoverer\UriInterface>> , but the function expects a object<Countable>|object...nit\Framework\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @covers VDB\Spider\Discoverer\DiscovererSet |
||
59 | */ |
||
60 | public function testFilter() |
||
61 | { |
||
62 | $this->discovererSet = new DiscovererSet([new XPathExpressionDiscoverer("//a")]); |
||
63 | |||
64 | $this->discovererSet->addFilter(new UriFilter(['/^.*contact.*$/'])); |
||
65 | |||
66 | $uris = $this->discovererSet->discover($this->spiderResource); |
||
67 | $this->assertCount(0, $uris); |
||
0 ignored issues
–
show
$uris is of type array<integer,object<VDB...scoverer\UriInterface>> , but the function expects a object<Countable>|object...nit\Framework\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
68 | } |
||
69 | } |
||
70 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: