Skip to content

Commit cfb93c3

Browse files
authored
Merge pull request #637 from FriendsOfSymfony/phpstan2
use phpstan 2
2 parents b1e9ed0 + e36fda6 commit cfb93c3

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

.github/workflows/static.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: Pull in optional dependencies
19-
run: composer require --no-update jean-beru/fos-http-cache-cloudfront twig/twig symfony/console
19+
run: composer require --no-update jean-beru/fos-http-cache-cloudfront twig/twig symfony/console phpstan/phpstan-symfony
2020

2121
- name: PHPStan
2222
uses: docker://oskarstark/phpstan-ga

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
"symfony/routing": "^6.4 || ^7.0",
5858
"matthiasnoback/symfony-config-test": "^4.3.0 || ^5.1",
5959
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0",
60-
"phpstan/phpstan": "^1.10",
61-
"phpstan/phpstan-symfony": "^1.3",
62-
"phpstan/extension-installer": "^1.3",
60+
"phpstan/phpstan": "^2",
61+
"phpstan/phpstan-symfony": "^2",
62+
"phpstan/extension-installer": "^1.4",
6363
"jean-beru/fos-http-cache-cloudfront": "^1.1",
6464
"friendsofphp/php-cs-fixer": "^3.54"
6565
},

phpstan.neon.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
parameters:
2-
level: 1
2+
level: 5
33
paths:
44
- src

src/EventListener/FlashMessageListener.php

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Cookie;
1616
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
1717
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
18+
use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface;
1819
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1920
use Symfony\Component\HttpKernel\KernelEvents;
2021
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -56,6 +57,9 @@ public function onKernelResponse(ResponseEvent $event): void
5657
} catch (SessionNotFoundException) {
5758
return;
5859
}
60+
if (!($session instanceof FlashBagAwareSessionInterface)) {
61+
return;
62+
}
5963

6064
// Flash messages are stored in the session. If there is none, there
6165
// can't be any flash messages in it. $session->getFlashBag() would

src/EventListener/InvalidationListener.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,13 @@ private function invalidateRoutes(array $routes, Request $request): void
169169
foreach ($routes as $route) {
170170
$params = [];
171171

172-
if (null !== $route->getParams()) {
173-
// Iterate over route params and try to evaluate their values
174-
foreach ($route->getParams() as $key => $value) {
175-
if (is_array($value)) {
176-
$value = $this->getExpressionLanguage()->evaluate($value['expression'], $values);
177-
}
178-
179-
$params[$key] = $value;
172+
// Iterate over route params and try to evaluate their values
173+
foreach ($route->getParams() as $key => $value) {
174+
if (is_array($value)) {
175+
$value = $this->getExpressionLanguage()->evaluate($value['expression'], $values);
180176
}
177+
178+
$params[$key] = $value;
181179
}
182180
$this->cacheManager->invalidateRoute($route->getName(), $params);
183181
}

src/EventListener/TagListener.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ public static function getSubscribedEvents(): array
9696
private function getAttributeTags(Request $request): array
9797
{
9898
// Check for _tag request attribute that is set when using Tag attribute
99-
/** @var $tagConfigurations Tag[] */
100-
if (!$tagConfigurations = $request->attributes->get('_tag')) {
99+
/** @var Tag[] $tagConfigurations */
100+
$tagConfigurations = $request->attributes->get('_tag');
101+
if (!$tagConfigurations) {
101102
return [];
102103
}
103104

0 commit comments

Comments
 (0)