diff --git a/composer.json b/composer.json index fd892a2..635fcb7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "friends-of-behat/mink-extension": "^2.2", "friends-of-behat/page-object-extension": "^0.3.1", "friends-of-behat/service-container-extension": "^1.0", - "phpstan/phpstan-shim": "^0.11", + "vimeo/psalm": "3.10.1", "sylius-labs/coding-standard": "^3.0", "symfony/browser-kit": "^4.4|^5.0", "symfony/framework-bundle": "^4.4|^5.0", @@ -55,7 +55,7 @@ ], "analyse": [ "vendor/bin/ecs check --ansi --no-progress-bar src tests", - "vendor/bin/phpstan analyse --ansi --no-progress -c phpstan.neon -l max src" + "vendor/bin/psalm src --no-progress" ] }, "extra": { diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index b282061..0000000 --- a/phpstan.neon +++ /dev/null @@ -1,12 +0,0 @@ -parameters: - reportUnmatchedIgnoredErrors: false - - ignoreErrors: - - '/Cannot access offset 0 on callable/' - - '/Cannot access offset 1 on callable/' - - '/Cannot call method [a-zA-Z0-9]+\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null\./' - - '/Method FriendsOfBehat\\SymfonyExtension\\Context\\Environment\\InitializedSymfonyExtensionEnvironment::bindCallee\(\) should return callable/' - - '/Strict comparison using === between 0\|1 and 2 will always evaluate to false\./' - - '/Class Symfony\\Component\\BrowserKit\\Client not found\./' - - '/Class Symfony\\Component\\BrowserKit\\AbstractBrowser not found\./' - - '/Parameter \#1 \$client of method Behat\\Mink\\Driver\\BrowserKitDriver::__construct\(\) expects/' diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..fe98d98 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php b/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php index 1493794..b9db9f2 100644 --- a/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php +++ b/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php @@ -85,8 +85,6 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler } /** - * @param UninitializedSymfonyExtensionEnvironment $uninitializedEnvironment - * * @throws EnvironmentIsolationException */ public function isolateEnvironment(Environment $uninitializedEnvironment, $testSubject = null): Environment @@ -174,6 +172,8 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler } /** + * @psalm-assert UninitializedSymfonyExtensionEnvironment $uninitializedEnvironment + * * @throws EnvironmentIsolationException */ private function assertEnvironmentCanBeIsolated(Environment $uninitializedEnvironment, $testSubject): void diff --git a/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php b/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php index 6527899..1aa4bf6 100644 --- a/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php +++ b/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php @@ -49,7 +49,7 @@ final class InitializedSymfonyExtensionEnvironment implements SymfonyExtensionEn { $callable = $callee->getCallable(); - if ($callee->isAnInstanceMethod()) { + if (is_array($callable) && $callee->isAnInstanceMethod()) { return [$this->getContext($callable[0]), $callable[1]]; } diff --git a/src/Context/Environment/UninitializedSymfonyExtensionEnvironment.php b/src/Context/Environment/UninitializedSymfonyExtensionEnvironment.php index f3d0626..db1504e 100644 --- a/src/Context/Environment/UninitializedSymfonyExtensionEnvironment.php +++ b/src/Context/Environment/UninitializedSymfonyExtensionEnvironment.php @@ -26,7 +26,7 @@ final class UninitializedSymfonyExtensionEnvironment extends StaticEnvironment i /** @var string[] */ private $contexts; - /** @var ContextEnvironment|null */ + /** @var ContextEnvironment */ private $delegatedEnvironment; public function __construct(Suite $suite, array $contexts, ContextEnvironment $delegatedEnvironment) diff --git a/src/Listener/KernelOrchestrator.php b/src/Listener/KernelOrchestrator.php index 92d01b0..2fad7d7 100644 --- a/src/Listener/KernelOrchestrator.php +++ b/src/Listener/KernelOrchestrator.php @@ -36,6 +36,7 @@ final class KernelOrchestrator implements EventSubscriberInterface public function setUp(): void { + /** @psalm-suppress InvalidArgument Psalm complains that ContainerInterface does not match object|null */ $this->symfonyKernel->getContainer()->set('behat.service_container', $this->behatContainer); }