| Conditions | 1 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function testSafeRoutes(array $routes, string $path, bool $expectedResult) |
||
| 24 | { |
||
| 25 | /* @var $uri UriInterface|\PHPUnit_Framework_MockObject_MockObject */ |
||
| 26 | $uri = $this->getMockBuilder(UriInterface::class)->getMock(); |
||
| 27 | |||
| 28 | $uri->expects(self::any())->method('getPath')->willReturn($path); |
||
|
|
|||
| 29 | |||
| 30 | /* @var $request RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ |
||
| 31 | $request = $this->getMockBuilder(ServerRequestInterface::class)->getMock(); |
||
| 32 | |||
| 33 | $request->expects(self::any())->method('getUri')->willReturn($uri); |
||
| 34 | |||
| 35 | self::assertSame($expectedResult, (new IsSafeHttpRoute(...$routes))->__invoke($request)); |
||
| 36 | } |
||
| 37 | |||
| 64 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: