Skip to content

Commit c9e5db9

Browse files
authored
minor #122 Replace PHPStan with Psalm (pamil)
This PR was merged into the 2.1 branch. Discussion ---------- Commits ------- 5de4ce6 Replace PHPStan with Psalm
2 parents 56c23ef + 5de4ce6 commit c9e5db9

7 files changed

+32
-18
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"friends-of-behat/mink-extension": "^2.2",
2525
"friends-of-behat/page-object-extension": "^0.3.1",
2626
"friends-of-behat/service-container-extension": "^1.0",
27-
"phpstan/phpstan-shim": "^0.11",
27+
"vimeo/psalm": "3.10.1",
2828
"sylius-labs/coding-standard": "^3.0",
2929
"symfony/browser-kit": "^4.4|^5.0",
3030
"symfony/framework-bundle": "^4.4|^5.0",
@@ -55,7 +55,7 @@
5555
],
5656
"analyse": [
5757
"vendor/bin/ecs check --ansi --no-progress-bar src tests",
58-
"vendor/bin/phpstan analyse --ansi --no-progress -c phpstan.neon -l max src"
58+
"vendor/bin/psalm src --no-progress"
5959
]
6060
},
6161
"extra": {

phpstan.neon

-12
This file was deleted.

psalm.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
totallyTyped="true"
4+
errorLevel="4"
5+
resolveFromConfigFile="true"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xmlns="https://getpsalm.org/schema/config"
8+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
9+
>
10+
<projectFiles>
11+
<directory name="src" />
12+
<ignoreFiles>
13+
<directory name="vendor" />
14+
</ignoreFiles>
15+
</projectFiles>
16+
17+
<issueHandlers>
18+
<UndefinedClass>
19+
<errorLevel type="suppress">
20+
<referencedClass name="Symfony\Component\BrowserKit\AbstractBrowser" />
21+
<referencedClass name="Symfony\Component\BrowserKit\Client" />
22+
</errorLevel>
23+
</UndefinedClass>
24+
</issueHandlers>
25+
</psalm>

src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public function supportsEnvironmentAndSubject(Environment $environment, $testSub
8585
}
8686

8787
/**
88-
* @param UninitializedSymfonyExtensionEnvironment $uninitializedEnvironment
89-
*
9088
* @throws EnvironmentIsolationException
9189
*/
9290
public function isolateEnvironment(Environment $uninitializedEnvironment, $testSubject = null): Environment
@@ -174,6 +172,8 @@ private function normalizeContext($context): string
174172
}
175173

176174
/**
175+
* @psalm-assert UninitializedSymfonyExtensionEnvironment $uninitializedEnvironment
176+
*
177177
* @throws EnvironmentIsolationException
178178
*/
179179
private function assertEnvironmentCanBeIsolated(Environment $uninitializedEnvironment, $testSubject): void

src/Context/Environment/InitializedSymfonyExtensionEnvironment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function bindCallee(Callee $callee): callable
4949
{
5050
$callable = $callee->getCallable();
5151

52-
if ($callee->isAnInstanceMethod()) {
52+
if (is_array($callable) && $callee->isAnInstanceMethod()) {
5353
return [$this->getContext($callable[0]), $callable[1]];
5454
}
5555

src/Context/Environment/UninitializedSymfonyExtensionEnvironment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class UninitializedSymfonyExtensionEnvironment extends StaticEnvironment i
2626
/** @var string[] */
2727
private $contexts;
2828

29-
/** @var ContextEnvironment|null */
29+
/** @var ContextEnvironment */
3030
private $delegatedEnvironment;
3131

3232
public function __construct(Suite $suite, array $contexts, ContextEnvironment $delegatedEnvironment)

src/Listener/KernelOrchestrator.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static function getSubscribedEvents(): array
3636

3737
public function setUp(): void
3838
{
39+
/** @psalm-suppress InvalidArgument Psalm complains that ContainerInterface does not match object|null */
3940
$this->symfonyKernel->getContainer()->set('behat.service_container', $this->behatContainer);
4041
}
4142

0 commit comments

Comments
 (0)