Passed
Push — master ( 079aca...05e9ba )
by Jeroen De
04:40
created

testAdaptsDumpReaderToIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Wikibase\JsonDumpReader\Tests\Unit\Iterator;
6
7
use PHPUnit\Framework\TestCase;
8
use Wikibase\JsonDumpReader\JsonDumpFactory;
9
use Wikibase\JsonDumpReader\Reader\FakeDumpReader;
10
11
/**
12
 * @covers \Wikibase\JsonDumpReader\JsonDumpFactory
13
 * @covers \Wikibase\JsonDumpReader\Reader\FakeDumpReader
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class StringDumpIteratorTest extends TestCase {
19
20
	public function testAdaptsDumpReaderToIterator() {
21
		$lines = [ 'foo', 'bar', 'baz' ];
22
		$iterator = ( new JsonDumpFactory() )->newStringDumpIterator( new FakeDumpReader( $lines ) );
0 ignored issues
show
Documentation introduced by
$lines is of type array<integer,string,{"0..."string","2":"string"}>, but the function expects a string.

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...
23
24
		$this->assertSame(
25
			$lines,
26
			iterator_to_array( $iterator )
27
		);
28
	}
29
30
}