Skip to content

Commit d013008

Browse files
authored
[phpstan] enable deprecated rules + fix deprecations (#912)
* [phpstan] enable deprecated rules * update file node * cleanup stmts aware and file node
1 parent 7aeb980 commit d013008

7 files changed

Lines changed: 50 additions & 9 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"phpecs/phpecs": "^2.2",
1212
"phpstan/extension-installer": "^1.4",
1313
"phpstan/phpstan": "^2.1.32",
14+
"phpstan/phpstan-deprecation-rules": "^2.0",
1415
"phpstan/phpstan-webmozart-assert": "^2.0",
1516
"phpunit/phpunit": "^11.5",
1617
"rector/jack": "^0.4",

config/sets/symfony/symfony-code-quality.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ParamTypeFromRouteRequiredRegexRector;
1616
use Rector\Symfony\CodeQuality\Rector\ClassMethod\RemoveUnusedRequestParamRector;
1717
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector;
18-
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ReturnDirectJsonResponseRector;
1918
use Rector\Symfony\CodeQuality\Rector\MethodCall\AssertSameResponseCodeWithDebugContentsRector;
2019
use Rector\Symfony\CodeQuality\Rector\MethodCall\LiteralGetToRequestClassConstantRector;
2120
use Rector\Symfony\CodeQuality\Rector\MethodCall\ParameterBagTypedGetMethodCallRector;

phpstan.neon

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parameters:
1212

1313
# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
1414
typeAliases:
15-
StmtsAware: \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\CustomNode\FileWithoutNamespace
15+
StmtsAware: \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\FileNode
1616

1717
reportUnmatchedIgnoredErrors: false
1818
treatPhpDocTypesAsCertain: false
@@ -71,3 +71,11 @@ parameters:
7171

7272
# local use php 8.3
7373
- identifier: typeCoverage.constantTypeCoverage
74+
75+
# in tests
76+
-
77+
message: '#Fetching deprecated class constant SYMFONY_(.*?) of class Rector\\Symfony\\Set\\SymfonySetList#'
78+
paths:
79+
- tests
80+
- config/sets/symfony/annotations-to-attributes.php
81+

rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
2828
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
2929
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
30-
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
3130
use Rector\Doctrine\NodeAnalyzer\AttrinationFinder;
3231
use Rector\PhpParser\Node\BetterNodeFinder;
3332
use Rector\Rector\AbstractRector;
@@ -363,8 +362,11 @@ private function removeDoctrineAnnotationTagValueNode(
363362
}
364363
}
365364

365+
/**
366+
* @param StmtsAware $stmtsAware
367+
*/
366368
private function refactorStmtsAwareNode(
367-
StmtsAwareInterface $stmtsAware,
369+
Node $stmtsAware,
368370
DoctrineAnnotationTagValueNode | Attribute $templateTagValueNodeOrAttribute,
369371
bool $hasThisRenderOrReturnsResponse,
370372
ClassMethod $classMethod

rules/Symfony42/Rector/New_/RootNodeTreeBuilderRector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use PhpParser\Node\Scalar\String_;
1313
use PhpParser\Node\Stmt\Expression;
1414
use PHPStan\Type\ObjectType;
15-
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
1615
use Rector\PhpParser\Enum\NodeGroup;
1716
use Rector\PhpParser\Node\BetterNodeFinder;
1817
use Rector\Rector\AbstractRector;
@@ -123,7 +122,10 @@ public function refactor(Node $node): ?Node
123122
return null;
124123
}
125124

126-
private function getRootMethodCallNode(StmtsAwareInterface $stmtsAware): ?Node
125+
/**
126+
* @param StmtsAware $stmtsAware
127+
*/
128+
private function getRootMethodCallNode(Node $stmtsAware): ?Node
127129
{
128130
$methodCalls = $this->betterNodeFinder->findInstanceOf($stmtsAware, MethodCall::class);
129131

src/Set/SymfonySetList.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
namespace Rector\Symfony\Set;
66

77
/**
8-
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
9-
*
108
* @api
119
*/
1210
final class SymfonySetList
@@ -17,101 +15,121 @@ final class SymfonySetList
1715
public const CONFIGS = __DIR__ . '/../../config/sets/symfony/configs.php';
1816

1917
/**
18+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
2019
* @var string
2120
*/
2221
public const SYMFONY_25 = __DIR__ . '/../../config/sets/symfony/symfony25.php';
2322

2423
/**
24+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
2525
* @var string
2626
*/
2727
public const SYMFONY_26 = __DIR__ . '/../../config/sets/symfony/symfony26.php';
2828

2929
/**
30+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
3031
* @var string
3132
*/
3233
public const SYMFONY_27 = __DIR__ . '/../../config/sets/symfony/symfony27.php';
3334

3435
/**
36+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
3537
* @var string
3638
*/
3739
public const SYMFONY_28 = __DIR__ . '/../../config/sets/symfony/symfony28.php';
3840

3941
/**
42+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
4043
* @var string
4144
*/
4245
public const SYMFONY_30 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony30.php';
4346

4447
/**
48+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
4549
* @var string
4650
*/
4751
public const SYMFONY_31 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony31.php';
4852

4953
/**
54+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
5055
* @var string
5156
*/
5257
public const SYMFONY_32 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony32.php';
5358

5459
/**
60+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
5561
* @var string
5662
*/
5763
public const SYMFONY_33 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony33.php';
5864

5965
/**
66+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
6067
* @var string
6168
*/
6269
public const SYMFONY_34 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony34.php';
6370

6471
/**
72+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
6573
* @var string
6674
*/
6775
public const SYMFONY_40 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony40.php';
6876

6977
/**
78+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
7079
* @var string
7180
*/
7281
public const SYMFONY_41 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony41.php';
7382

7483
/**
84+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
7585
* @var string
7686
*/
7787
public const SYMFONY_42 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony42.php';
7888

7989
/**
90+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
8091
* @var string
8192
*/
8293
public const SYMFONY_43 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony43.php';
8394

8495
/**
96+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
8597
* @var string
8698
*/
8799
public const SYMFONY_44 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony44.php';
88100

89101
/**
102+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
90103
* @var string
91104
*/
92105
public const SYMFONY_50 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50.php';
93106

94107
/**
108+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
95109
* @var string
96110
*/
97111
public const SYMFONY_50_TYPES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50/symfony50-types.php';
98112

99113
/**
114+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
100115
* @var string
101116
*/
102117
public const SYMFONY_51 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony51.php';
103118

104119
/**
120+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
105121
* @var string
106122
*/
107123
public const SYMFONY_52 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52.php';
108124

109125
/**
126+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
110127
* @var string
111128
*/
112129
public const SYMFONY_53 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony53.php';
113130

114131
/**
132+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
115133
* @var string
116134
*/
117135
public const SYMFONY_54 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony54.php';
@@ -123,56 +141,67 @@ final class SymfonySetList
123141
public const SYMFONY_52_VALIDATOR_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52-validator-attributes.php';
124142

125143
/**
144+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
126145
* @var string
127146
*/
128147
public const SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony60.php';
129148

130149
/**
150+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
131151
* @var string
132152
*/
133153
public const SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony61.php';
134154

135155
/**
156+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
136157
* @var string
137158
*/
138159
public const SYMFONY_62 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony62.php';
139160

140161
/**
162+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
141163
* @var string
142164
*/
143165
public const SYMFONY_63 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony63.php';
144166

145167
/**
168+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
146169
* @var string
147170
*/
148171
public const SYMFONY_64 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony64.php';
149172

150173
/**
174+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
151175
* @var string
152176
*/
153177
public const SYMFONY_70 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony70.php';
154178

155179
/**
180+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
156181
* @var string
157182
*/
158183
public const SYMFONY_71 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony71.php';
159184

160185
/**
186+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
161187
* @var string
162188
*/
163189
public const SYMFONY_72 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony72.php';
164190

165191
/**
192+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
166193
* @var string
167194
*/
168195
public const SYMFONY_73 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony73.php';
169196

170197
/**
198+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
171199
* @var string
172200
*/
173201
public const SYMFONY_74 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony74.php';
174202

175203
/**
204+
* @deprecated Set list are too generic and do not handle package differences. Use ->withComposerBased(symfony: true) instead
176205
* @var string
177206
*/
178207
public const SYMFONY_80 = __DIR__ . '/../../config/sets/symfony/symfony8/symfony80.php';

src/ValueObjectFactory/ServiceMapFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function createTagsFromData(array $tagsData): array
188188
*/
189189
private function convertXmlToArray(SimpleXMLElement $simpleXMLElement): array
190190
{
191-
$data = Json::decode(Json::encode((array) $simpleXMLElement), Json::FORCE_ARRAY);
191+
$data = Json::decode(Json::encode((array) $simpleXMLElement), true);
192192

193193
$data = $this->unWrapAttributes($data);
194194

0 commit comments

Comments
 (0)