Conditions | 1 |
Paths | 1 |
Total Lines | 26 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | public function testParse() |
||
26 | { |
||
27 | $arrayName = 'ArrayName'; |
||
28 | $arrayLength = 3; |
||
29 | $entity = m::mock(EntityInterface::class); |
||
30 | $entityParser = m::mock(ParserInterface::class) |
||
31 | ->shouldReceive('parse') |
||
|
|||
32 | ->with('serialised') |
||
33 | ->andReturn($entity) |
||
34 | ->times($arrayLength) |
||
35 | ->getMock(); |
||
36 | $parserResolver = m::mock(ParserResolver::class) |
||
37 | ->shouldReceive('resolve') |
||
38 | ->with($arrayName) |
||
39 | ->andReturn($entityParser) |
||
40 | ->once() |
||
41 | ->getMock(); |
||
42 | $parser = new ArrayParser($parserResolver); |
||
43 | |||
44 | $parsed = $parser->parse( |
||
45 | $arrayName, |
||
46 | $arrayLength, |
||
47 | "\tserialised\r\n\tserialised\r\n\tserialised\r\n" |
||
48 | ); |
||
49 | |||
50 | $this->assertEquals([$entity, $entity, $entity], $parsed); |
||
51 | } |
||
53 |
This check compares calls to functions or methods with their respective definitions. If the call has more 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.