testNewStopwatchFetcherReturnsFetcherThatUsesStopwatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace FileFetcher\Stopwatch\Tests\Integration;
6
7
use FileFetcher\Stopwatch\Factory;
8
use FileFetcher\StubFileFetcher;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Stopwatch\Stopwatch;
11
12
/**
13
 * @covers \FileFetcher\Stopwatch\Factory
14
 *
15
 * @licence BSD-3-Clause
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class FactoryTest extends TestCase {
19
20
	public function testNewStopwatchFetcherReturnsFetcherThatUsesStopwatch() {
21
		$stopwatch = $this->createMock( Stopwatch::class );
22
		$stopwatch->expects( $this->once() )->method( 'start' );
23
		$stopwatch->expects( $this->once() )->method( 'stop' );
24
25
		$fetcher = ( new Factory() )->newStopwatchFetcher(
26
			new StubFileFetcher( '' ),
27
			$stopwatch
0 ignored issues
show
Documentation introduced by
$stopwatch is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component\Stopwatch\Stopwatch>.

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...
28
		);
29
30
		$fetcher->fetchFile( 'whatever' );
31
	}
32
33
}
34