Skip to content

Commit 6fdce8d

Browse files
phpstan-botclaude
andcommitted
Update test expectations for class-string value-level descriptions
Tests now expect class-string<ClassName> instead of quoted 'ClassName' when ConstantStringType with isClassString flag is described at value verbosity level. Also update baseline and ignored error patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dc330b4 commit 6fdce8d

12 files changed

Lines changed: 48 additions & 48 deletions

build/phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ parameters:
108108
message: '#^Variable property access on T of PHPStan\\Rules\\RuleError\.$#'
109109
path: ../src/Rules/RuleErrorBuilder.php
110110
-
111-
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, string given\\.$#"
111+
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, 'PHPStan…' given\\.$#"
112112
count: 1
113113
path: ../src/Command/CommandHelper.php
114114
-
115-
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, string given\\.$#"
115+
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, 'PHPStan…' given\\.$#"
116116
count: 1
117117
path: ../src/Diagnose/PHPStanDiagnoseExtension.php
118118
- identifier: ternary.shortNotAllowed

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ parameters:
742742
path: src/Rules/RuleLevelHelper.php
743743

744744
-
745-
rawMessage: 'Call to function method_exists() with ''PHPUnit\\Framework\\TestCase'' and ''assertFileDoesNotEx…'' will always evaluate to true.'
745+
rawMessage: 'Call to function method_exists() with class-string<PHPUnit\Framework\TestCase> and ''assertFileDoesNotEx…'' will always evaluate to true.'
746746
identifier: function.alreadyNarrowedType
747747
count: 1
748748
path: src/Testing/LevelsTestCase.php

tests/PHPStan/Rules/Classes/ClassAttributesRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testBug7171(): void
150150
{
151151
$this->analyse([__DIR__ . '/data/bug-7171.php'], [
152152
[
153-
'Parameter $repositoryClass of attribute class Bug7171\Entity constructor expects class-string<Bug7171\EntityRepository<T of object>>|null, \'stdClass\' given.',
153+
'Parameter $repositoryClass of attribute class Bug7171\Entity constructor expects class-string<Bug7171\EntityRepository<T of object>>|null, class-string<stdClass> given.',
154154
66,
155155
],
156156
]);

tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ public function testInstanceof(): void
190190
$tipText,
191191
],
192192
[
193-
'Instanceof between class-string<DateTimeInterface> and \'DateTimeInterface\' will always evaluate to false.',
193+
'Instanceof between class-string<DateTimeInterface> and class-string<DateTimeInterface> will always evaluate to false.',
194194
432,
195195
$tipText,
196196
],
197197
[
198-
'Instanceof between DateTimeInterface and \'DateTimeInterface\' will always evaluate to true.',
198+
'Instanceof between DateTimeInterface and class-string<DateTimeInterface> will always evaluate to true.',
199199
433,
200200
$tipText,
201201
],

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function testImpossibleCheckTypeFunctionCall(): void
160160
582,
161161
],
162162
[
163-
'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExists\' and \'testWithStringFirst…\' will always evaluate to true.',
163+
'Call to function method_exists() with class-string<CheckTypeFunctionCall\\MethodExists> and \'testWithStringFirst…\' will always evaluate to true.',
164164
596,
165165
],
166166
[
@@ -196,30 +196,30 @@ public function testImpossibleCheckTypeFunctionCall(): void
196196
656,
197197
],
198198
[
199-
'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'method\' will always evaluate to true.',
199+
'Call to function method_exists() with class-string<CheckTypeFunctionCall\MethodExistsWithTrait> and \'method\' will always evaluate to true.',
200200
659,
201201
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
202202
],
203203
[
204-
'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'someAnother\' will always evaluate to true.',
204+
'Call to function method_exists() with class-string<CheckTypeFunctionCall\MethodExistsWithTrait> and \'someAnother\' will always evaluate to true.',
205205
662,
206206
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
207207
],
208208
[
209-
'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'unknown\' will always evaluate to false.',
209+
'Call to function method_exists() with class-string<CheckTypeFunctionCall\MethodExistsWithTrait> and \'unknown\' will always evaluate to false.',
210210
665,
211211
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
212212
],
213213
[
214-
'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'method\' will always evaluate to true.',
214+
'Call to function method_exists() with class-string<CheckTypeFunctionCall\MethodExistsWithTrait> and \'method\' will always evaluate to true.',
215215
668,
216216
],
217217
[
218-
'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'someAnother\' will always evaluate to true.',
218+
'Call to function method_exists() with class-string<CheckTypeFunctionCall\MethodExistsWithTrait> and \'someAnother\' will always evaluate to true.',
219219
671,
220220
],
221221
[
222-
'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'unknown\' will always evaluate to false.',
222+
'Call to function method_exists() with class-string<CheckTypeFunctionCall\MethodExistsWithTrait> and \'unknown\' will always evaluate to false.',
223223
674,
224224
],
225225
[
@@ -391,11 +391,11 @@ public function testBug6305(): void
391391
$this->treatPhpDocTypesAsCertain = true;
392392
$this->analyse([__DIR__ . '/data/bug-6305.php'], [
393393
[
394-
'Call to function is_subclass_of() with Bug6305\B and \'Bug6305\\\A\' will always evaluate to true.',
394+
'Call to function is_subclass_of() with Bug6305\B and class-string<Bug6305\A> will always evaluate to true.',
395395
11,
396396
],
397397
[
398-
'Call to function is_subclass_of() with Bug6305\B and \'Bug6305\\\B\' will always evaluate to false.',
398+
'Call to function is_subclass_of() with Bug6305\B and class-string<Bug6305\B> will always evaluate to false.',
399399
14,
400400
],
401401
]);
@@ -412,11 +412,11 @@ public function testBug13713(): void
412412
$this->treatPhpDocTypesAsCertain = true;
413413
$this->analyse([__DIR__ . '/data/bug-13713.php'], [
414414
[
415-
"Call to function is_subclass_of() with arguments Bug13713\\test, 'stdClass' and false will always evaluate to true.",
415+
"Call to function is_subclass_of() with arguments Bug13713\\test, class-string<stdClass> and false will always evaluate to true.",
416416
12,
417417
],
418418
[
419-
"Call to function is_subclass_of() with arguments class-string<Bug13713\\test>, 'stdClass' and true will always evaluate to true.",
419+
"Call to function is_subclass_of() with arguments class-string<Bug13713\\test>, class-string<stdClass> and true will always evaluate to true.",
420420
25,
421421
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
422422
],
@@ -1004,7 +1004,7 @@ public function testBugPR3404(): void
10041004
$this->treatPhpDocTypesAsCertain = true;
10051005
$this->analyse([__DIR__ . '/data/bug-pr-3404.php'], [
10061006
[
1007-
'Call to function is_a() with arguments BugPR3404\Location, \'BugPR3404\\\\Location\' and true will always evaluate to true.',
1007+
'Call to function is_a() with arguments BugPR3404\Location, class-string<BugPR3404\\Location> and true will always evaluate to true.',
10081008
21,
10091009
],
10101010
]);

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testBug12473(): void
264264
$tip,
265265
],*/
266266
[
267-
'Call to method ReflectionClass<Bug12473\\PictureUser>::isSubclassOf() with \'Bug12473\\\\PictureProduct\' will always evaluate to false.',
267+
'Call to method ReflectionClass<Bug12473\\PictureUser>::isSubclassOf() with class-string<Bug12473\\PictureProduct> will always evaluate to false.',
268268
49,
269269
$tip,
270270
],

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,12 @@ public function testBug3633(): void
571571
$tipText,
572572
],
573573
[
574-
'Strict comparison using === between \'Bug3633\\\HelloWorld\' and \'Bug3633\\\HelloWorld\' will always evaluate to true.',
574+
'Strict comparison using === between class-string<Bug3633\HelloWorld> and class-string<Bug3633\HelloWorld> will always evaluate to true.',
575575
41,
576576
$tipText,
577577
],
578578
[
579-
'Strict comparison using === between \'Bug3633\\\HelloWorld\' and \'Bug3633\\\OtherClass\' will always evaluate to false.',
579+
'Strict comparison using === between class-string<Bug3633\HelloWorld> and class-string<Bug3633\OtherClass> will always evaluate to false.',
580580
44,
581581
],
582582
[
@@ -585,12 +585,12 @@ public function testBug3633(): void
585585
$tipText,
586586
],
587587
[
588-
'Strict comparison using === between \'Bug3633\\\OtherClass\' and \'Bug3633\\\HelloWorld\' will always evaluate to false.',
588+
'Strict comparison using === between class-string<Bug3633\OtherClass> and class-string<Bug3633\HelloWorld> will always evaluate to false.',
589589
71,
590590
$tipText,
591591
],
592592
[
593-
'Strict comparison using === between \'Bug3633\\\OtherClass\' and \'Bug3633\\\OtherClass\' will always evaluate to true.',
593+
'Strict comparison using === between class-string<Bug3633\OtherClass> and class-string<Bug3633\OtherClass> will always evaluate to true.',
594594
74,
595595
$tipText,
596596
],
@@ -605,27 +605,27 @@ public function testBug3633(): void
605605
$tipText,
606606
],
607607
[
608-
'Strict comparison using === between \'Bug3633\\\FinalClass\' and \'Bug3633\\\FinalClass\' will always evaluate to true.',
608+
'Strict comparison using === between class-string<Bug3633\FinalClass> and class-string<Bug3633\FinalClass> will always evaluate to true.',
609609
102,
610610
$tipText,
611611
],
612612
[
613-
'Strict comparison using === between \'Bug3633\\\FinalClass\' and \'Bug3633\\\HelloWorld\' will always evaluate to false.',
613+
'Strict comparison using === between class-string<Bug3633\FinalClass> and class-string<Bug3633\HelloWorld> will always evaluate to false.',
614614
106,
615615
$tipText,
616616
],
617617
[
618-
'Strict comparison using === between \'Bug3633\\\FinalClass\' and \'Bug3633\\\OtherClass\' will always evaluate to false.',
618+
'Strict comparison using === between class-string<Bug3633\FinalClass> and class-string<Bug3633\OtherClass> will always evaluate to false.',
619619
109,
620620
$tipText,
621621
],
622622
[
623-
'Strict comparison using !== between \'Bug3633\\\FinalClass\' and \'Bug3633\\\FinalClass\' will always evaluate to false.',
623+
'Strict comparison using !== between class-string<Bug3633\FinalClass> and class-string<Bug3633\FinalClass> will always evaluate to false.',
624624
112,
625625
$tipText,
626626
],
627627
[
628-
'Strict comparison using === between \'Bug3633\\\FinalClass\' and \'Bug3633\\\FinalClass\' will always evaluate to true.',
628+
'Strict comparison using === between class-string<Bug3633\FinalClass> and class-string<Bug3633\FinalClass> will always evaluate to true.',
629629
115,
630630
],
631631
]);

tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,22 @@ public function testRule(): void
148148
176,
149149
],
150150
[
151-
'Trying to invoke array{\'CallCallables\\\\CallableInForeach\', \'bar\'|\'foo\'} but it might not be a callable.',
151+
'Trying to invoke array{class-string<CallCallables\\CallableInForeach>, \'bar\'|\'foo\'} but it might not be a callable.',
152152
188,
153153
],
154154
[
155-
'Trying to invoke array{\'CallCallables\\\\ConstantArrayUnionCallables\'|\'DateTimeImmutable\', \'doFoo\'} but it might not be a callable.',
155+
'Trying to invoke array{class-string<CallCallables\\ConstantArrayUnionCallables>|class-string<DateTimeImmutable>, \'doFoo\'} but it might not be a callable.',
156156
214,
157157
],
158158
[
159-
'Trying to invoke array{\'CallCallables\\\ConstantArrayUnionCallables\', \'doBaz\'|\'doFoo\'} but it might not be a callable.',
159+
'Trying to invoke array{class-string<CallCallables\\ConstantArrayUnionCallables>, \'doBaz\'|\'doFoo\'} but it might not be a callable.',
160160
221,
161161
],
162162
];
163163

164164
if (PHP_VERSION_ID >= 80000) {
165165
$errors[] = [
166-
'Trying to invoke array{\'CallCallables\\\ConstantArrayUnionCallables\'|\'CallCallables\\\ConstantArrayUnionCallablesTest\', \'doBar\'|\'doFoo\'} but it\'s not a callable.',
166+
'Trying to invoke array{class-string<CallCallables\\ConstantArrayUnionCallables>|class-string<CallCallables\\ConstantArrayUnionCallablesTest>, \'doBar\'|\'doFoo\'} but it\'s not a callable.',
167167
229,
168168
];
169169
}

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,11 +1200,11 @@ public function testBug4371(): void
12001200
{
12011201
$errors = [
12021202
[
1203-
'Parameter #1 $object_or_class of function is_a expects object, class-string<Bug4371\Bar> given.',
1203+
'Parameter #1 $object_or_class of function is_a expects object, string given.',
12041204
14,
12051205
],
12061206
[
1207-
'Parameter #1 $object_or_class of function is_a expects object, class-string<Bug4371\Bar> given.',
1207+
'Parameter #1 $object_or_class of function is_a expects object, string given.',
12081208
22,
12091209
],
12101210
];
@@ -1213,11 +1213,11 @@ public function testBug4371(): void
12131213
// php 7.x had different parameter names
12141214
$errors = [
12151215
[
1216-
'Parameter #1 $object_or_string of function is_a expects object, class-string<Bug4371\Bar> given.',
1216+
'Parameter #1 $object_or_string of function is_a expects object, string given.',
12171217
14,
12181218
],
12191219
[
1220-
'Parameter #1 $object_or_string of function is_a expects object, class-string<Bug4371\Bar> given.',
1220+
'Parameter #1 $object_or_string of function is_a expects object, string given.',
12211221
22,
12221222
],
12231223
];
@@ -1230,15 +1230,15 @@ public function testIsSubclassAllowString(): void
12301230
{
12311231
$errors = [
12321232
[
1233-
'Parameter #1 $object_or_class of function is_subclass_of expects object, class-string<IsSubclassAllowString\A> given.',
1233+
'Parameter #1 $object_or_class of function is_subclass_of expects object, string given.',
12341234
11,
12351235
],
12361236
[
1237-
'Parameter #1 $object_or_class of function is_subclass_of expects object, class-string<IsSubclassAllowString\B> given.',
1237+
'Parameter #1 $object_or_class of function is_subclass_of expects object, string given.',
12381238
14,
12391239
],
12401240
[
1241-
'Parameter #1 $object_or_class of function is_subclass_of expects object, class-string<IsSubclassAllowString\B> given.',
1241+
'Parameter #1 $object_or_class of function is_subclass_of expects object, string given.',
12421242
17,
12431243
],
12441244
];
@@ -1247,15 +1247,15 @@ public function testIsSubclassAllowString(): void
12471247
// php 7.x had different parameter names
12481248
$errors = [
12491249
[
1250-
'Parameter #1 $object_or_string of function is_subclass_of expects object, class-string<IsSubclassAllowString\A> given.',
1250+
'Parameter #1 $object_or_string of function is_subclass_of expects object, string given.',
12511251
11,
12521252
],
12531253
[
1254-
'Parameter #1 $object_or_string of function is_subclass_of expects object, class-string<IsSubclassAllowString\B> given.',
1254+
'Parameter #1 $object_or_string of function is_subclass_of expects object, string given.',
12551255
14,
12561256
],
12571257
[
1258-
'Parameter #1 $object_or_string of function is_subclass_of expects object, class-string<IsSubclassAllowString\B> given.',
1258+
'Parameter #1 $object_or_string of function is_subclass_of expects object, string given.',
12591259
17,
12601260
],
12611261
];

tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ public function testBug4550(): void
454454
$this->checkThisOnly = false;
455455
$this->analyse([__DIR__ . '/data/bug-4550.php'], [
456456
[
457-
'Parameter #1 $class of static method Bug4550\Test::valuesOf() expects class-string<Person>, string given.',
457+
"Parameter #1 \$class of static method Bug4550\Test::valuesOf() expects class-string<Person>, 'Person' given.",
458458
34,
459459
],
460460
[
461-
'Parameter #1 $class of static method Bug4550\Test::valuesOf() expects class-string<Person>, string given.',
461+
"Parameter #1 \$class of static method Bug4550\Test::valuesOf() expects class-string<Person>, 'Person' given.",
462462
44,
463463
],
464464
]);
@@ -482,7 +482,7 @@ public function testBug1971Php8(): void
482482
$this->checkThisOnly = false;
483483
$this->analyse([__DIR__ . '/data/bug-1971.php'], [
484484
[
485-
'Parameter #1 $callback of static method Closure::fromCallable() expects callable(): mixed, array{\'Bug1971\\\HelloWorld\', \'sayHello\'} given.',
485+
'Parameter #1 $callback of static method Closure::fromCallable() expects callable(): mixed, array{class-string<Bug1971\HelloWorld>, \'sayHello\'} given.',
486486
14,
487487
],
488488
[
@@ -577,7 +577,7 @@ public function testTemplateTypeInOneBranchOfConditional(): void
577577
$this->checkExplicitMixed = true;
578578
$this->analyse([__DIR__ . '/data/template-type-in-one-branch-of-conditional.php'], [
579579
[
580-
'Parameter #1 $params of static method TemplateTypeInOneBranchOfConditional\DriverManager::getConnection() expects array{wrapperClass?: class-string<TemplateTypeInOneBranchOfConditional\Connection>}, array{wrapperClass: \'stdClass\'} given.',
580+
'Parameter #1 $params of static method TemplateTypeInOneBranchOfConditional\DriverManager::getConnection() expects array{wrapperClass?: class-string<TemplateTypeInOneBranchOfConditional\Connection>}, array{wrapperClass: class-string<stdClass>} given.',
581581
27,
582582
"Offset 'wrapperClass' (class-string<TemplateTypeInOneBranchOfConditional\Connection>) does not accept type class-string<stdClass>.",
583583
],

0 commit comments

Comments
 (0)