diff --git a/composer.json b/composer.json index aa590bd..06333f4 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "react/promise": "^3 || ^2.7" }, "require-dev": { - "phpstan/phpstan": "1.8.10 || 1.4.10", + "phpstan/phpstan": "1.9.2 || 1.4.10", "phpunit/phpunit": "^9.5 || ^7.5", "psr/container": "^2 || ^1" }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6112643..c4587eb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -13,5 +13,3 @@ parameters: # ignore unknown `Fiber` class (PHP 8.1+) - '/^Instantiated class Fiber not found\.$/' - '/^Call to method (start|isTerminated|getReturn)\(\) on an unknown class Fiber\.$/' - # ignore incomplete type information for mocks in legacy PHPUnit 7.5 - - '/^Parameter #\d+ .+ of .+ expects .+, PHPUnit\\Framework\\MockObject\\MockObject given\.$/' diff --git a/tests/AppTest.php b/tests/AppTest.php index 9433d03..7a2218e 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -74,6 +74,7 @@ public function testConstructWithContainerAssignsDefaultHandlersAndContainerForR $container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler); $container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler); + assert($container instanceof Container); $app = new App($container); $ref = new ReflectionProperty($app, 'handler'); @@ -109,6 +110,7 @@ public function testConstructWithContainerAndMiddlewareClassNameAssignsCallableF $container = $this->createMock(Container::class); $container->expects($this->once())->method('callable')->with('stdClass')->willReturn($middleware); + assert($container instanceof Container); $app = new App($container, \stdClass::class); $ref = new ReflectionProperty($app, 'handler'); @@ -224,6 +226,7 @@ public function testConstructWithContainerAndErrorHandlerClassAssignsErrorHandle $container = $this->createMock(Container::class); $container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler); + assert($container instanceof Container); $app = new App($container, ErrorHandler::class); $ref = new ReflectionProperty($app, 'handler'); @@ -257,6 +260,8 @@ public function testConstructWithMultipleContainersAndErrorHandlerClassAssignsEr $container = $this->createMock(Container::class); $container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler); + assert($unused instanceof Container); + assert($container instanceof Container); $app = new App($unused, $container, ErrorHandler::class, $unused); $ref = new ReflectionProperty($app, 'handler'); @@ -291,6 +296,8 @@ public function testConstructWithMultipleContainersAndMiddlewareAssignsErrorHand $container = $this->createMock(Container::class); $container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler); + assert($unused instanceof Container); + assert($container instanceof Container); $app = new App($unused, $container, $middleware, $unused); $ref = new ReflectionProperty($app, 'handler'); @@ -361,6 +368,9 @@ public function testConstructWithMultipleContainersAndMiddlewareAndErrorHandlerC $container2 = $this->createMock(Container::class); $container2->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler2); + assert($unused instanceof Container); + assert($container1 instanceof Container); + assert($container2 instanceof Container); $app = new App($unused, $container1, $middleware, $container2, ErrorHandler::class, $unused); $ref = new ReflectionProperty($app, 'handler'); @@ -448,6 +458,7 @@ public function testConstructWithContainerAndAccessLogHandlerClassAndErrorHandle $container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler); $container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler); + assert($container instanceof Container); $app = new App($container, AccessLogHandler::class, ErrorHandler::class); $ref = new ReflectionProperty($app, 'handler'); @@ -515,6 +526,8 @@ public function testConstructWithMultipleContainersAndAccessLogHandlerClassAndEr $container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler); $container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler); + assert($unused instanceof Container); + assert($container instanceof Container); $app = new App($unused, $container, AccessLogHandler::class, ErrorHandler::class, $unused); $ref = new ReflectionProperty($app, 'handler'); @@ -554,6 +567,8 @@ public function testConstructWithMultipleContainersAndMiddlewareAssignsDefaultHa $container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler); $container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler); + assert($unused instanceof Container); + assert($container instanceof Container); $app = new App($unused, $container, $middleware, $unused); $ref = new ReflectionProperty($app, 'handler'); diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php index d33d722..26423a4 100644 --- a/tests/ContainerTest.php +++ b/tests/ContainerTest.php @@ -1982,6 +1982,7 @@ public function __invoke(ServerRequestInterface $request): Response $psr->expects($this->never())->method('has'); $psr->expects($this->once())->method('get')->with(get_class($controller))->willReturn($controller); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $callable = $container->callable(get_class($controller)); @@ -2002,6 +2003,7 @@ public function testCallableReturnsCallableThatThrowsWhenFactoryReturnsInvalidCl $psr->expects($this->never())->method('has'); $psr->expects($this->once())->method('get')->with('FooBar')->willThrowException($exception); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $callable = $container->callable('FooBar'); // @phpstan-ignore-line @@ -2054,6 +2056,7 @@ public function testGetEnvReturnsStringFromPsrContainer(): void $psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(true); $psr->expects($this->once())->method('get')->with('X_FOO')->willReturn('bar'); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $this->assertEquals('bar', $container->getEnv('X_FOO')); @@ -2065,6 +2068,7 @@ public function testGetEnvReturnsNullIfPsrContainerHasNoEntry(): void $psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(false); $psr->expects($this->never())->method('get'); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $this->assertNull($container->getEnv('X_FOO')); @@ -2076,6 +2080,7 @@ public function testGetEnvReturnsStringFromGlobalServerIfPsrContainerHasNoEntry( $psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(false); $psr->expects($this->never())->method('get'); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $_SERVER['X_FOO'] = 'bar'; @@ -2102,6 +2107,7 @@ public function testGetEnvThrowsIfMapPsrContainerReturnsInvalidType(): void $psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(true); $psr->expects($this->once())->method('get')->with('X_FOO')->willReturn(42); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $this->expectException(\TypeError::class); @@ -2139,6 +2145,7 @@ public function testGetAccessLogHandlerReturnsAccessLogHandlerInstanceFromPsrCon $psr->expects($this->once())->method('has')->with(AccessLogHandler::class)->willReturn(true); $psr->expects($this->once())->method('get')->with(AccessLogHandler::class)->willReturn($accessLogHandler); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $ret = $container->getAccessLogHandler(); @@ -2152,6 +2159,7 @@ public function testGetAccessLogHandlerReturnsDefaultAccessLogHandlerInstanceIfP $psr->expects($this->once())->method('has')->with(AccessLogHandler::class)->willReturn(false); $psr->expects($this->never())->method('get'); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $accessLogHandler = $container->getAccessLogHandler(); @@ -2189,6 +2197,7 @@ public function testGetErrorHandlerReturnsErrorHandlerInstanceFromPsrContainer() $psr->expects($this->once())->method('has')->with(ErrorHandler::class)->willReturn(true); $psr->expects($this->once())->method('get')->with(ErrorHandler::class)->willReturn($errorHandler); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $ret = $container->getErrorHandler(); @@ -2202,6 +2211,7 @@ public function testGetErrorHandlerReturnsDefaultErrorHandlerInstanceIfPsrContai $psr->expects($this->once())->method('has')->with(ErrorHandler::class)->willReturn(false); $psr->expects($this->never())->method('get'); + assert($psr instanceof ContainerInterface); $container = new Container($psr); $errorHandler = $container->getErrorHandler(); diff --git a/tests/Io/RouteHandlerTest.php b/tests/Io/RouteHandlerTest.php index c12e195..4f15d91 100644 --- a/tests/Io/RouteHandlerTest.php +++ b/tests/Io/RouteHandlerTest.php @@ -54,6 +54,7 @@ public function testMapRouteWithClassNameAddsRouteOnRouterWithControllerCallable $container = $this->createMock(Container::class); $container->expects($this->once())->method('callable')->with('stdClass')->willReturn($controller); + assert($container instanceof Container); $handler = new RouteHandler($container); $router = $this->createMock(RouteCollector::class); @@ -98,6 +99,7 @@ public function testMapRouteWithContainerAndControllerClassNameAddsRouteOnRouter $ref->setAccessible(true); $ref->setValue($handler, $router); + assert($container instanceof Container); $handler->map(['GET'], '/', $container, \stdClass::class); } diff --git a/tests/install-as-dep/composer.json b/tests/install-as-dep/composer.json index d404fd2..a47dac7 100644 --- a/tests/install-as-dep/composer.json +++ b/tests/install-as-dep/composer.json @@ -1,7 +1,6 @@ { "require": { - "clue/framework-x": "*@dev", - "react/async": "^4@dev || ^3@dev" + "clue/framework-x": "*@dev" }, "repositories": [ {