Skip to content

Commit b807800

Browse files
committed
Bump PHPStan and Rector
1 parent 6bfffda commit b807800

File tree

6 files changed

+213
-25
lines changed

6 files changed

+213
-25
lines changed

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
"matthiasnoback/symfony-config-test": "^5.1",
3232
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
3333
"phpstan/extension-installer": "^1.2",
34-
"phpstan/phpstan": "1.12.8",
35-
"phpstan/phpstan-phpunit": "1.4.0",
36-
"phpstan/phpstan-symfony": "1.4.12",
37-
"phpunit/phpunit": "9.6.21",
34+
"phpstan/phpstan": "2.1.4",
35+
"phpstan/phpstan-phpunit": "2.0.4",
36+
"phpstan/phpstan-symfony": "2.0.2",
37+
"phpunit/phpunit": "9.6.22",
3838
"psr/cache": "^1.0 || ^2.0 || ^3.0",
3939
"psr/container": "^1.0 || ^2.0",
4040
"psr/log": "^1.0 || ^2.0 || ^3.0",
4141
"ratchet/rfc6455": "^0.3.1",
4242
"react/event-loop": "^1.3",
43-
"rector/rector": "1.2.10",
43+
"rector/rector": "2.0.9",
4444
"symfony/cache": "^6.4 || ^7.2",
4545
"symfony/http-foundation": "^6.4 || ^7.2",
4646
"symfony/phpunit-bridge": "^6.4 || ^7.2"

phpstan-baseline.neon

+204-9
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,241 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Parameter \\#1 \\$data of function unserialize expects string, mixed given\\.$#"
4+
message: '#^Parameter \#1 \$data of function unserialize expects string, mixed given\.$#'
5+
identifier: argument.type
56
count: 1
67
path: src/Authentication/Provider/SessionAuthenticationProvider.php
78

89
-
9-
message: "#^Cannot cast mixed to string\\.$#"
10+
message: '#^Cannot cast mixed to string\.$#'
11+
identifier: cast.string
1012
count: 1
1113
path: src/Authentication/Storage/DriverBackedTokenStorage.php
1214

1315
-
14-
message: "#^Argument of an invalid type array\\|bool\\|float\\|int\\|string\\|null supplied for foreach, only iterables are supported\\.$#"
16+
message: '#^Cannot access offset ''allowed_origins'' on mixed\.$#'
17+
identifier: offsetAccess.nonOffsetAccessible
18+
count: 1
19+
path: src/DependencyInjection/BabDevWebSocketExtension.php
20+
21+
-
22+
message: '#^Cannot access offset ''blocked_ip_addresses'' on mixed\.$#'
23+
identifier: offsetAccess.nonOffsetAccessible
24+
count: 1
25+
path: src/DependencyInjection/BabDevWebSocketExtension.php
26+
27+
-
28+
message: '#^Cannot access offset ''connections'' on mixed\.$#'
29+
identifier: offsetAccess.nonOffsetAccessible
30+
count: 1
31+
path: src/DependencyInjection/BabDevWebSocketExtension.php
32+
33+
-
34+
message: '#^Cannot access offset ''context'' on mixed\.$#'
35+
identifier: offsetAccess.nonOffsetAccessible
36+
count: 1
37+
path: src/DependencyInjection/BabDevWebSocketExtension.php
38+
39+
-
40+
message: '#^Cannot access offset ''dbal'' on mixed\.$#'
41+
identifier: offsetAccess.nonOffsetAccessible
42+
count: 3
43+
path: src/DependencyInjection/BabDevWebSocketExtension.php
44+
45+
-
46+
message: '#^Cannot access offset ''identity'' on mixed\.$#'
47+
identifier: offsetAccess.nonOffsetAccessible
48+
count: 1
49+
path: src/DependencyInjection/BabDevWebSocketExtension.php
50+
51+
-
52+
message: '#^Cannot access offset ''interval'' on mixed\.$#'
53+
identifier: offsetAccess.nonOffsetAccessible
54+
count: 2
55+
path: src/DependencyInjection/BabDevWebSocketExtension.php
56+
57+
-
58+
message: '#^Cannot access offset ''keepalive'' on mixed\.$#'
59+
identifier: offsetAccess.nonOffsetAccessible
60+
count: 2
61+
path: src/DependencyInjection/BabDevWebSocketExtension.php
62+
63+
-
64+
message: '#^Cannot access offset ''max_http_request_size'' on mixed\.$#'
65+
identifier: offsetAccess.nonOffsetAccessible
66+
count: 1
67+
path: src/DependencyInjection/BabDevWebSocketExtension.php
68+
69+
-
70+
message: '#^Cannot access offset ''periodic'' on mixed\.$#'
71+
identifier: offsetAccess.nonOffsetAccessible
72+
count: 3
73+
path: src/DependencyInjection/BabDevWebSocketExtension.php
74+
75+
-
76+
message: '#^Cannot access offset ''providers'' on mixed\.$#'
77+
identifier: offsetAccess.nonOffsetAccessible
78+
count: 1
79+
path: src/DependencyInjection/BabDevWebSocketExtension.php
80+
81+
-
82+
message: '#^Cannot access offset ''resource'' on mixed\.$#'
83+
identifier: offsetAccess.nonOffsetAccessible
84+
count: 1
85+
path: src/DependencyInjection/BabDevWebSocketExtension.php
86+
87+
-
88+
message: '#^Cannot access offset ''router'' on mixed\.$#'
89+
identifier: offsetAccess.nonOffsetAccessible
90+
count: 1
91+
path: src/DependencyInjection/BabDevWebSocketExtension.php
92+
93+
-
94+
message: '#^Cannot access offset ''session'' on mixed\.$#'
95+
identifier: offsetAccess.nonOffsetAccessible
96+
count: 1
97+
path: src/DependencyInjection/BabDevWebSocketExtension.php
98+
99+
-
100+
message: '#^Cannot access offset ''uri'' on mixed\.$#'
101+
identifier: offsetAccess.nonOffsetAccessible
102+
count: 1
103+
path: src/DependencyInjection/BabDevWebSocketExtension.php
104+
105+
-
106+
message: '#^Cannot access offset string on mixed\.$#'
107+
identifier: offsetAccess.nonOffsetAccessible
108+
count: 1
109+
path: src/DependencyInjection/BabDevWebSocketExtension.php
110+
111+
-
112+
message: '#^Parameter \#1 \$id of class Symfony\\Component\\DependencyInjection\\Reference constructor expects string, mixed given\.$#'
113+
identifier: argument.type
114+
count: 3
115+
path: src/DependencyInjection/BabDevWebSocketExtension.php
116+
117+
-
118+
message: '#^Parameter \#1 \$sessionConfig of method BabDev\\WebSocketBundle\\DependencyInjection\\BabDevWebSocketExtension\:\:configureWebSocketSession\(\) expects array, mixed given\.$#'
119+
identifier: argument.type
120+
count: 1
121+
path: src/DependencyInjection/BabDevWebSocketExtension.php
122+
123+
-
124+
message: '#^Parameter \#2 \$config of method BabDev\\WebSocketBundle\\DependencyInjection\\Factory\\Authentication\\AuthenticationProviderFactory\:\:createAuthenticationProvider\(\) expects array, mixed given\.$#'
125+
identifier: argument.type
126+
count: 1
127+
path: src/DependencyInjection/BabDevWebSocketExtension.php
128+
129+
-
130+
message: '#^Parameter \#2 \$config of method Symfony\\Component\\DependencyInjection\\Extension\\Extension\:\:isConfigEnabled\(\) expects array, mixed given\.$#'
131+
identifier: argument.type
132+
count: 1
133+
path: src/DependencyInjection/BabDevWebSocketExtension.php
134+
135+
-
136+
message: '#^Parameter \#2 \$value of method Symfony\\Component\\DependencyInjection\\Container\:\:setParameter\(\) expects array\|bool\|float\|int\|string\|UnitEnum\|null, mixed given\.$#'
137+
identifier: argument.type
138+
count: 1
139+
path: src/DependencyInjection/BabDevWebSocketExtension.php
140+
141+
-
142+
message: '#^Argument of an invalid type array\|bool\|float\|int\|string\|null supplied for foreach, only iterables are supported\.$#'
143+
identifier: foreach.nonIterable
15144
count: 1
16145
path: src/DependencyInjection/Compiler/PingDBALConnectionsCompilerPass.php
17146

18147
-
19-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
148+
message: '#^Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition\:\:children\(\)\.$#'
149+
identifier: method.notFound
150+
count: 1
151+
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
152+
153+
-
154+
message: '#^Cannot call method defaultNull\(\) on mixed\.$#'
155+
identifier: method.nonObject
156+
count: 1
157+
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
158+
159+
-
160+
message: '#^Cannot call method end\(\) on mixed\.$#'
161+
identifier: method.nonObject
162+
count: 2
163+
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
164+
165+
-
166+
message: '#^Cannot call method ifTrue\(\) on mixed\.$#'
167+
identifier: method.nonObject
168+
count: 1
169+
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
170+
171+
-
172+
message: '#^Cannot call method info\(\) on mixed\.$#'
173+
identifier: method.nonObject
20174
count: 1
21175
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
22176

23177
-
24-
message: "#^Parameter \\#1 \\$class of function class_exists expects string, mixed given\\.$#"
178+
message: '#^Cannot call method thenInvalid\(\) on mixed\.$#'
179+
identifier: method.nonObject
180+
count: 1
181+
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
182+
183+
-
184+
message: '#^Cannot call method validate\(\) on mixed\.$#'
185+
identifier: method.nonObject
186+
count: 1
187+
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
188+
189+
-
190+
message: '#^Cannot call method variableNode\(\) on mixed\.$#'
191+
identifier: method.nonObject
192+
count: 1
193+
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
194+
195+
-
196+
message: '#^Call to function method_exists\(\) with \$this\(BabDev\\WebSocketBundle\\Routing\\Loader\\AttributeLoader\) and ''setRouteAttributeCl…'' will always evaluate to true\.$#'
197+
identifier: function.alreadyNarrowedType
198+
count: 1
199+
path: src/Routing/Loader/AttributeLoader.php
200+
201+
-
202+
message: '#^Parameter \#1 \$class of function class_exists expects string, mixed given\.$#'
203+
identifier: argument.type
204+
count: 1
205+
path: src/Routing/Loader/AttributeLoader.php
206+
207+
-
208+
message: '#^Parameter \#1 \$path of method Symfony\\Component\\Routing\\Loader\\AttributeClassLoader\:\:createRoute\(\) expects string, mixed given\.$#'
209+
identifier: argument.type
210+
count: 1
211+
path: src/Routing/Loader/AttributeLoader.php
212+
213+
-
214+
message: '#^Parameter \#1 \$resource of class Symfony\\Component\\Config\\Resource\\FileResource constructor expects string, string\|false given\.$#'
215+
identifier: argument.type
25216
count: 1
26217
path: src/Routing/Loader/AttributeLoader.php
27218

28219
-
29-
message: "#^Parameter \\#1 \\$resource of class Symfony\\\\Component\\\\Config\\\\Resource\\\\FileResource constructor expects string, string\\|false given\\.$#"
220+
message: '#^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$#'
221+
identifier: argument.type
30222
count: 1
31223
path: src/Routing/Loader/AttributeLoader.php
32224

33225
-
34-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
226+
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, string\|null given\.$#'
227+
identifier: argument.type
35228
count: 1
36229
path: src/Routing/Loader/AttributeLoader.php
37230

38231
-
39-
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|null given\\.$#"
232+
message: '#^Parameter \#3 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$#'
233+
identifier: argument.type
40234
count: 1
41235
path: src/Routing/Loader/AttributeLoader.php
42236

43237
-
44-
message: "#^Cannot cast mixed to string\\.$#"
238+
message: '#^Cannot cast mixed to string\.$#'
239+
identifier: cast.string
45240
count: 1
46241
path: tests/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactoryTest.php

rector.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
use Rector\Config\RectorConfig;
44
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
55
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
6-
use Rector\PHPUnit\Set\PHPUnitSetList;
7-
use Rector\Set\ValueObject\LevelSetList;
8-
use Rector\Set\ValueObject\SetList;
96
use Rector\Symfony\Set\SymfonySetList;
107

118
return RectorConfig::configure()
@@ -36,10 +33,9 @@
3633
__DIR__.'/vendor/phpstan/phpstan-symfony/extension.neon',
3734
__DIR__.'/phpstan.neon',
3835
])
36+
->withPhpSets()
37+
->withPreparedSets(codeQuality: true, phpunitCodeQuality: true)
3938
->withSets([
40-
LevelSetList::UP_TO_PHP_82,
41-
SetList::CODE_QUALITY,
42-
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
4339
SymfonySetList::SYMFONY_64,
4440
])
4541
->withPreparedSets(codeQuality: true);

src/Authentication/Provider/AuthenticationProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function supports(Connection $connection): bool;
1616
/**
1717
* Attempts to authenticate the current connection.
1818
*
19-
* Implementations can assume this method will only be executed when supports() is true.
19+
* Implementations can assume this method will only be executed when {@see supports()} returns true.
2020
*
2121
* @throws AuthenticationException if there was an error while trying to authenticate the user
2222
*/

src/Authentication/StorageBackedConnectionRepository.php

-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function findAll(Topic $topic, bool $anonymous = false): array
2323
{
2424
$result = [];
2525

26-
/** @var Connection $connection */
2726
foreach ($topic as $connection) {
2827
$client = $this->findTokenForConnection($connection);
2928

@@ -44,7 +43,6 @@ public function findAllByUsername(Topic $topic, string $username): array
4443
{
4544
$result = [];
4645

47-
/** @var Connection $connection */
4846
foreach ($topic as $connection) {
4947
$client = $this->findTokenForConnection($connection);
5048

@@ -63,7 +61,6 @@ public function findAllWithRoles(Topic $topic, array $roles): array
6361
{
6462
$result = [];
6563

66-
/** @var Connection $connection */
6764
foreach ($topic as $connection) {
6865
$client = $this->findTokenForConnection($connection);
6966

@@ -100,7 +97,6 @@ public function getUser(Connection $connection): ?UserInterface
10097

10198
public function hasConnectionForUsername(Topic $topic, string $username): bool
10299
{
103-
/** @var Connection $connection */
104100
foreach ($topic as $connection) {
105101
$client = $this->findTokenForConnection($connection);
106102

src/DependencyInjection/Compiler/PingDBALConnectionsCompilerPass.php

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function process(ContainerBuilder $container): void
2222
return;
2323
}
2424

25+
/** @var string $id */
2526
foreach ($container->getParameter('babdev_websocket_server.ping_dbal_connections') as $id) {
2627
if (!$container->has($id)) {
2728
throw new InvalidArgumentException(\sprintf('The "%s" service does not exist in the container, please review the "server.periodic.dbal.connections" configuration for the BabDevWebSocketBundle to ensure all connections are set in your DoctrineBundle configuration.', $id));

0 commit comments

Comments
 (0)