From db3bfb7edfab604346bd64b1ed1d6335e53e3fbe Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 11 Apr 2025 14:08:31 +0200 Subject: [PATCH] RuleTestCase: Order errors --- src/Testing/RuleTestCase.php | 2 +- .../InvalidKeyInArrayDimFetchRuleTest.php | 4 +- .../Rules/Classes/ClassConstantRuleTest.php | 18 ++--- ...xistingClassesInEnumImplementsRuleTest.php | 4 +- .../Classes/ImpossibleInstanceOfRuleTest.php | 4 +- .../Rules/Classes/InstantiationRuleTest.php | 20 ++--- .../Classes/LocalTypeAliasesRuleTest.php | 36 ++++----- .../Classes/LocalTypeTraitAliasesRuleTest.php | 22 +++--- .../Rules/Classes/MethodTagRuleTest.php | 24 +++--- .../Classes/MethodTagTraitUseRuleTest.php | 8 +- tests/PHPStan/Rules/Classes/MixinRuleTest.php | 10 +-- .../Rules/Classes/PropertyTagRuleTest.php | 20 ++--- .../UnusedConstructorParametersRuleTest.php | 4 +- ...mpossibleCheckTypeFunctionCallRuleTest.php | 78 +++++++++---------- .../Comparison/MatchExpressionRuleTest.php | 12 +-- .../MagicConstantContextRuleTest.php | 8 +- .../UnusedPrivatePropertyRuleTest.php | 8 +- .../Rules/Functions/CallCallablesRuleTest.php | 4 +- .../CallToFunctionParametersRuleTest.php | 8 +- .../CallToNonExistentFunctionRuleTest.php | 4 +- .../Rules/Functions/CallUserFuncRuleTest.php | 4 +- ...lassesInArrowFunctionTypehintsRuleTest.php | 20 ++--- ...stingClassesInClosureTypehintsRuleTest.php | 24 +++--- .../ExistingClassesInTypehintsRuleTest.php | 46 +++++------ .../Rules/Generics/ClassAncestorsRuleTest.php | 14 ++-- .../Generics/ClassTemplateTypeRuleTest.php | 10 +-- .../Generics/FunctionTemplateTypeRuleTest.php | 6 +- .../Generics/InterfaceAncestorsRuleTest.php | 10 +-- .../InterfaceTemplateTypeRuleTest.php | 10 +-- .../MethodSignatureVarianceRuleTest.php | 10 +-- .../MethodTagTemplateTypeRuleTest.php | 6 +- .../MethodTagTemplateTypeTraitRuleTest.php | 6 +- .../Generics/MethodTemplateTypeRuleTest.php | 10 +-- .../Generics/TraitTemplateTypeRuleTest.php | 10 +-- .../Rules/Generics/UsedTraitsRuleTest.php | 8 +- ...stractMethodInNonAbstractClassRuleTest.php | 16 ++-- .../Rules/Methods/CallMethodsRuleTest.php | 48 ++++++------ .../Methods/CallStaticMethodsRuleTest.php | 12 +-- .../Methods/ConstructorReturnTypeRuleTest.php | 8 +- .../ExistingClassesInTypehintsRuleTest.php | 56 ++++++------- .../Methods/OverridingMethodRuleTest.php | 16 ++-- .../PhpDoc/IncompatiblePhpDocTypeRuleTest.php | 20 ++--- .../Rules/PhpDoc/MethodAssertRuleTest.php | 8 +- .../WrongVariableNameInVarTagRuleTest.php | 12 +-- .../AccessStaticPropertiesRuleTest.php | 8 +- .../ExistingClassesInPropertiesRuleTest.php | 14 ++-- .../PHPStan/Rules/Pure/PureMethodRuleTest.php | 4 +- .../RegularExpressionPatternRuleTest.php | 16 ++-- .../Variables/DefinedVariableRuleTest.php | 12 +-- 49 files changed, 371 insertions(+), 371 deletions(-) diff --git a/src/Testing/RuleTestCase.php b/src/Testing/RuleTestCase.php index cd0f52534e..0116e0bd9d 100644 --- a/src/Testing/RuleTestCase.php +++ b/src/Testing/RuleTestCase.php @@ -241,7 +241,7 @@ private function gatherAnalyserErrorsWithDelayedErrors(array $files): array ); return [ - $finalizer->finalize($analyserResult, false, true)->getAnalyserResult()->getUnorderedErrors(), + $finalizer->finalize($analyserResult, false, true)->getAnalyserResult()->getErrors(), array_merge($classRule->getDelayedErrors(), $traitRule->getDelayedErrors()), ]; } diff --git a/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php b/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php index 757b25cbd7..f27f95b9d1 100644 --- a/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php +++ b/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php @@ -81,11 +81,11 @@ public function testBug6315(): void 20, ], [ - 'Invalid array key type Bug6315\FooEnum::B.', + 'Invalid array key type Bug6315\FooEnum::A.', 21, ], [ - 'Invalid array key type Bug6315\FooEnum::A.', + 'Invalid array key type Bug6315\FooEnum::B.', 21, ], [ diff --git a/tests/PHPStan/Rules/Classes/ClassConstantRuleTest.php b/tests/PHPStan/Rules/Classes/ClassConstantRuleTest.php index e1e48ef78e..c3a8f3ebb4 100644 --- a/tests/PHPStan/Rules/Classes/ClassConstantRuleTest.php +++ b/tests/PHPStan/Rules/Classes/ClassConstantRuleTest.php @@ -77,11 +77,11 @@ public function testClassConstant(): void 26, ], [ - 'Class ClassConstantNamespace\Foo referenced with incorrect case: ClassConstantNamespace\FOO.', + 'Access to undefined constant ClassConstantNamespace\Foo::DOLOR.', 27, ], [ - 'Access to undefined constant ClassConstantNamespace\Foo::DOLOR.', + 'Class ClassConstantNamespace\Foo referenced with incorrect case: ClassConstantNamespace\FOO.', 27, ], [ @@ -155,11 +155,11 @@ public function testClassConstantVisibility(): void 129, ], [ - 'Class ClassConstantVisibility\Foo referenced with incorrect case: ClassConstantVisibility\FOO.', + 'Access to private constant PRIVATE_FOO of class ClassConstantVisibility\Foo.', 135, ], [ - 'Access to private constant PRIVATE_FOO of class ClassConstantVisibility\Foo.', + 'Class ClassConstantVisibility\Foo referenced with incorrect case: ClassConstantVisibility\FOO.', 135, ], ]); @@ -445,11 +445,11 @@ public function testDynamicAccess(): void $this->analyse([__DIR__ . '/data/dynamic-constant-access.php'], [ [ - 'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.', + 'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.', 20, ], [ - 'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.', + 'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.', 20, ], [ @@ -465,15 +465,15 @@ public function testDynamicAccess(): void 41, ], [ - 'Access to undefined constant ClassConstantDynamicAccess\Foo::QUX.', + 'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.', 44, ], [ - 'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.', + 'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.', 44, ], [ - 'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.', + 'Access to undefined constant ClassConstantDynamicAccess\Foo::QUX.', 44, ], ]); diff --git a/tests/PHPStan/Rules/Classes/ExistingClassesInEnumImplementsRuleTest.php b/tests/PHPStan/Rules/Classes/ExistingClassesInEnumImplementsRuleTest.php index e706e005d9..af55e8791e 100644 --- a/tests/PHPStan/Rules/Classes/ExistingClassesInEnumImplementsRuleTest.php +++ b/tests/PHPStan/Rules/Classes/ExistingClassesInEnumImplementsRuleTest.php @@ -58,11 +58,11 @@ public function testRule(): void 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Enum EnumImplements\FooEnum referenced with incorrect case: EnumImplements\FOOEnum.', + 'Enum EnumImplements\Foo7 implements enum EnumImplements\FooEnum.', 55, ], [ - 'Enum EnumImplements\Foo7 implements enum EnumImplements\FooEnum.', + 'Enum EnumImplements\FooEnum referenced with incorrect case: EnumImplements\FOOEnum.', 55, ], ]); diff --git a/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php b/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php index 2ef0c3d184..b86139cb3d 100644 --- a/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php +++ b/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php @@ -111,12 +111,12 @@ public function testInstanceof(): void 228, ], [ - 'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Foo will always evaluate to true.', + 'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Bar will always evaluate to true.', 232, $tipText, ], [ - 'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Bar will always evaluate to true.', + 'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Foo will always evaluate to true.', 232, $tipText, ], diff --git a/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php b/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php index bf5e7ab8af..639a3f4136 100644 --- a/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php +++ b/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php @@ -94,19 +94,19 @@ public function testInstantiation(): void 57, ], [ - 'Class TestInstantiation\FooInstantiation referenced with incorrect case: TestInstantiation\FOOInstantiation.', + 'Class TestInstantiation\FooInstantiation does not have a constructor and must be instantiated without any parameters.', 64, ], [ - 'Class TestInstantiation\FooInstantiation does not have a constructor and must be instantiated without any parameters.', + 'Class TestInstantiation\FooInstantiation referenced with incorrect case: TestInstantiation\FOOInstantiation.', 64, ], [ - 'Class TestInstantiation\BarInstantiation referenced with incorrect case: TestInstantiation\BARInstantiation.', + 'Class TestInstantiation\BarInstantiation constructor invoked with 0 parameters, 1 required.', 65, ], [ - 'Class TestInstantiation\BarInstantiation constructor invoked with 0 parameters, 1 required.', + 'Class TestInstantiation\BarInstantiation referenced with incorrect case: TestInstantiation\BARInstantiation.', 65, ], [ @@ -408,22 +408,22 @@ public function testBug7048(): void } $this->analyse([__DIR__ . '/data/bug-7048.php'], [ - [ - 'Unknown parameter $recurrences in call to DatePeriod constructor.', - 21, - ], [ 'Missing parameter $end (DateTimeInterface|int) in call to DatePeriod constructor.', 18, ], [ - 'Unknown parameter $isostr in call to DatePeriod constructor.', - 25, + 'Unknown parameter $recurrences in call to DatePeriod constructor.', + 21, ], [ 'Missing parameter $start (string) in call to DatePeriod constructor.', 24, ], + [ + 'Unknown parameter $isostr in call to DatePeriod constructor.', + 25, + ], [ 'Parameter #3 $end of class DatePeriod constructor expects DateTimeInterface|int, string given.', 41, diff --git a/tests/PHPStan/Rules/Classes/LocalTypeAliasesRuleTest.php b/tests/PHPStan/Rules/Classes/LocalTypeAliasesRuleTest.php index 9f6ac7b3ec..ae180ba463 100644 --- a/tests/PHPStan/Rules/Classes/LocalTypeAliasesRuleTest.php +++ b/tests/PHPStan/Rules/Classes/LocalTypeAliasesRuleTest.php @@ -46,27 +46,27 @@ public function testRule(): void { $this->analyse([__DIR__ . '/data/local-type-aliases.php'], [ [ - 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Bar.', + 'Circular definition detected in type alias CircularTypeAlias1.', 23, ], [ - 'Type alias GlobalTypeAlias already exists as a global type alias.', + 'Circular definition detected in type alias CircularTypeAlias2.', 23, ], [ - 'Type alias has an invalid name: int.', + 'Circular definition detected in type alias RecursiveTypeAlias.', 23, ], [ - 'Circular definition detected in type alias RecursiveTypeAlias.', + 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Bar.', 23, ], [ - 'Circular definition detected in type alias CircularTypeAlias1.', + 'Type alias GlobalTypeAlias already exists as a global type alias.', 23, ], [ - 'Circular definition detected in type alias CircularTypeAlias2.', + 'Type alias has an invalid name: int.', 23, ], [ @@ -82,23 +82,23 @@ public function testRule(): void 39, ], [ - 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Baz.', + 'Circular definition detected in type alias CircularTypeAliasImport2.', 39, ], [ - 'Type alias GlobalTypeAlias already exists as a global type alias.', + 'Imported type alias ExportedTypeAlias has an invalid name: int.', 39, ], [ - 'Imported type alias ExportedTypeAlias has an invalid name: int.', + 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Baz.', 39, ], [ - 'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.', + 'Type alias GlobalTypeAlias already exists as a global type alias.', 39, ], [ - 'Circular definition detected in type alias CircularTypeAliasImport2.', + 'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.', 39, ], [ @@ -110,29 +110,29 @@ public function testRule(): void 62, ], [ - 'Class LocalTypeAliases\MissingTypehints has type alias NoIterableValue with no value type specified in iterable type array.', + 'Class LocalTypeAliases\MissingTypehints has type alias NoCallable with no signature specified for callable.', 77, - 'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type', ], [ 'Class LocalTypeAliases\MissingTypehints has type alias NoGenerics with generic class LocalTypeAliases\Generic but does not specify its types: T', 77, ], [ - 'Class LocalTypeAliases\MissingTypehints has type alias NoCallable with no signature specified for callable.', + 'Class LocalTypeAliases\MissingTypehints has type alias NoIterableValue with no value type specified in iterable type array.', 77, + 'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type', ], [ - 'Type alias A contains unknown class LocalTypeAliases\Nonexistent.', + 'Class LocalTypeAliases\Foo referenced with incorrect case: LocalTypeAliases\fOO.', 87, - 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Type alias B contains invalid type LocalTypeTraitAliases\Foo.', + 'Type alias A contains unknown class LocalTypeAliases\Nonexistent.', 87, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Class LocalTypeAliases\Foo referenced with incorrect case: LocalTypeAliases\fOO.', + 'Type alias B contains invalid type LocalTypeTraitAliases\Foo.', 87, ], [ diff --git a/tests/PHPStan/Rules/Classes/LocalTypeTraitAliasesRuleTest.php b/tests/PHPStan/Rules/Classes/LocalTypeTraitAliasesRuleTest.php index 9654660857..ca5350502f 100644 --- a/tests/PHPStan/Rules/Classes/LocalTypeTraitAliasesRuleTest.php +++ b/tests/PHPStan/Rules/Classes/LocalTypeTraitAliasesRuleTest.php @@ -46,27 +46,27 @@ public function testRule(): void { $this->analyse([__DIR__ . '/data/local-type-trait-aliases.php'], [ [ - 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Bar.', + 'Circular definition detected in type alias CircularTypeAlias1.', 23, ], [ - 'Type alias GlobalTypeAlias already exists as a global type alias.', + 'Circular definition detected in type alias CircularTypeAlias2.', 23, ], [ - 'Type alias has an invalid name: int.', + 'Circular definition detected in type alias RecursiveTypeAlias.', 23, ], [ - 'Circular definition detected in type alias RecursiveTypeAlias.', + 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Bar.', 23, ], [ - 'Circular definition detected in type alias CircularTypeAlias1.', + 'Type alias GlobalTypeAlias already exists as a global type alias.', 23, ], [ - 'Circular definition detected in type alias CircularTypeAlias2.', + 'Type alias has an invalid name: int.', 23, ], [ @@ -82,23 +82,23 @@ public function testRule(): void 39, ], [ - 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Baz.', + 'Circular definition detected in type alias CircularTypeAliasImport2.', 39, ], [ - 'Type alias GlobalTypeAlias already exists as a global type alias.', + 'Imported type alias ExportedTypeAlias has an invalid name: int.', 39, ], [ - 'Imported type alias ExportedTypeAlias has an invalid name: int.', + 'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Baz.', 39, ], [ - 'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.', + 'Type alias GlobalTypeAlias already exists as a global type alias.', 39, ], [ - 'Circular definition detected in type alias CircularTypeAliasImport2.', + 'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.', 39, ], [ diff --git a/tests/PHPStan/Rules/Classes/MethodTagRuleTest.php b/tests/PHPStan/Rules/Classes/MethodTagRuleTest.php index 0c221078d2..4ebc1fef80 100644 --- a/tests/PHPStan/Rules/Classes/MethodTagRuleTest.php +++ b/tests/PHPStan/Rules/Classes/MethodTagRuleTest.php @@ -43,9 +43,9 @@ public function testRule(): void $fooClassLine = 12; $this->analyse([__DIR__ . '/data/method-tag.php'], [ [ - 'PHPDoc tag @method for method MethodTag\Foo::doFoo() return type contains unknown class MethodTag\intt.', - $fooClassLine, - 'Learn more at https://phpstan.org/user-guide/discovering-symbols', + 'Class MethodTag\Foo has PHPDoc tag @method for method doMissingIterablueValue() return type with no value type specified in iterable type array.', + 12, + MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP, ], [ 'PHPDoc tag @method for method MethodTag\Foo::doBar() parameter #1 $a contains unresolvable type.', @@ -56,12 +56,12 @@ public function testRule(): void 12, ], [ - 'Class MethodTag\Foo has PHPDoc tag @method for method doMissingIterablueValue() return type with no value type specified in iterable type array.', - 12, - MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP, + 'PHPDoc tag @method for method MethodTag\Foo::doFoo() return type contains unknown class MethodTag\intt.', + $fooClassLine, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'PHPDoc tag @method for method MethodTag\TestGenerics::doA() return type contains generic type Exception but class Exception is not generic.', + 'Generic type MethodTag\Generic in PHPDoc tag @method for method MethodTag\TestGenerics::doC() return type specifies 3 template types, but class MethodTag\Generic supports only 2: T, U', 39, ], [ @@ -69,7 +69,7 @@ public function testRule(): void 39, ], [ - 'Generic type MethodTag\Generic in PHPDoc tag @method for method MethodTag\TestGenerics::doC() return type specifies 3 template types, but class MethodTag\Generic supports only 2: T, U', + 'PHPDoc tag @method for method MethodTag\TestGenerics::doA() return type contains generic type Exception but class Exception is not generic.', 39, ], [ @@ -90,16 +90,16 @@ public function testRule(): void 63, ], [ - 'PHPDoc tag @method for method MethodTag\NonexistentClasses::doA() return type contains unknown class MethodTag\Nonexistent.', + 'Class MethodTag\Foo referenced with incorrect case: MethodTag\fOO.', 73, - 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'PHPDoc tag @method for method MethodTag\NonexistentClasses::doB() return type contains invalid type PropertyTagTrait\Foo.', + 'PHPDoc tag @method for method MethodTag\NonexistentClasses::doA() return type contains unknown class MethodTag\Nonexistent.', 73, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Class MethodTag\Foo referenced with incorrect case: MethodTag\fOO.', + 'PHPDoc tag @method for method MethodTag\NonexistentClasses::doB() return type contains invalid type PropertyTagTrait\Foo.', 73, ], ]); diff --git a/tests/PHPStan/Rules/Classes/MethodTagTraitUseRuleTest.php b/tests/PHPStan/Rules/Classes/MethodTagTraitUseRuleTest.php index bdacfb3c6a..2d7575e6c0 100644 --- a/tests/PHPStan/Rules/Classes/MethodTagTraitUseRuleTest.php +++ b/tests/PHPStan/Rules/Classes/MethodTagTraitUseRuleTest.php @@ -44,17 +44,17 @@ public function testRule(): void $fooTraitLine = 12; $this->analyse([__DIR__ . '/data/method-tag-trait.php'], [ [ - 'PHPDoc tag @method for method MethodTagTrait\Foo::doFoo() return type contains unknown class MethodTagTrait\intt.', + 'PHPDoc tag @method for method MethodTagTrait\Foo::doBar() parameter #1 $a contains unresolvable type.', $fooTraitLine, - 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'PHPDoc tag @method for method MethodTagTrait\Foo::doBar() parameter #1 $a contains unresolvable type.', + 'PHPDoc tag @method for method MethodTagTrait\Foo::doBaz2() parameter #1 $a default value contains unresolvable type.', $fooTraitLine, ], [ - 'PHPDoc tag @method for method MethodTagTrait\Foo::doBaz2() parameter #1 $a default value contains unresolvable type.', + 'PHPDoc tag @method for method MethodTagTrait\Foo::doFoo() return type contains unknown class MethodTagTrait\intt.', $fooTraitLine, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], ]); } diff --git a/tests/PHPStan/Rules/Classes/MixinRuleTest.php b/tests/PHPStan/Rules/Classes/MixinRuleTest.php index c389d025a0..9b18420f27 100644 --- a/tests/PHPStan/Rules/Classes/MixinRuleTest.php +++ b/tests/PHPStan/Rules/Classes/MixinRuleTest.php @@ -51,11 +51,11 @@ public function testRule(): void 24, ], [ - 'PHPDoc tag @mixin contains generic type Exception but class Exception is not generic.', + 'Generic type Traversable in PHPDoc tag @mixin specifies 3 template types, but interface Traversable supports only 2: TKey, TValue', 34, ], [ - 'Generic type Traversable in PHPDoc tag @mixin specifies 3 template types, but interface Traversable supports only 2: TKey, TValue', + 'PHPDoc tag @mixin contains generic type Exception but class Exception is not generic.', 34, ], [ @@ -67,13 +67,13 @@ public function testRule(): void 50, ], [ - 'PHPDoc tag @mixin contains unknown class MixinRule\UnknownestClass.', + 'PHPDoc tag @mixin contains invalid type MixinRule\FooTrait.', 50, - 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'PHPDoc tag @mixin contains invalid type MixinRule\FooTrait.', + 'PHPDoc tag @mixin contains unknown class MixinRule\UnknownestClass.', 50, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ 'PHPDoc tag @mixin contains unknown class MixinRule\U.', diff --git a/tests/PHPStan/Rules/Classes/PropertyTagRuleTest.php b/tests/PHPStan/Rules/Classes/PropertyTagRuleTest.php index 826047dbb9..0c6f798865 100644 --- a/tests/PHPStan/Rules/Classes/PropertyTagRuleTest.php +++ b/tests/PHPStan/Rules/Classes/PropertyTagRuleTest.php @@ -55,12 +55,12 @@ public function testRule(): void $tipText, ], [ - 'PHPDoc tag @property for property PropertyTag\Foo::$c contains unknown class PropertyTag\stringg.', + 'PHPDoc tag @property for property PropertyTag\Foo::$c contains unknown class PropertyTag\intt.', $fooClassLine, $tipText, ], [ - 'PHPDoc tag @property for property PropertyTag\Foo::$c contains unknown class PropertyTag\intt.', + 'PHPDoc tag @property for property PropertyTag\Foo::$c contains unknown class PropertyTag\stringg.', $fooClassLine, $tipText, ], @@ -70,12 +70,12 @@ public function testRule(): void $tipText, ], [ - 'PHPDoc tag @property for property PropertyTag\Foo::$e contains unknown class PropertyTag\stringg.', + 'PHPDoc tag @property for property PropertyTag\Foo::$e contains unknown class PropertyTag\intt.', $fooClassLine, $tipText, ], [ - 'PHPDoc tag @property for property PropertyTag\Foo::$e contains unknown class PropertyTag\intt.', + 'PHPDoc tag @property for property PropertyTag\Foo::$e contains unknown class PropertyTag\stringg.', $fooClassLine, $tipText, ], @@ -94,7 +94,7 @@ public function testRule(): void 31, ], [ - 'PHPDoc tag @property for property PropertyTag\TestGenerics::$a contains generic type Exception but class Exception is not generic.', + 'Generic type PropertyTag\Generic in PHPDoc tag @property for property PropertyTag\TestGenerics::$c specifies 3 template types, but class PropertyTag\Generic supports only 2: T, U', 51, ], [ @@ -102,7 +102,7 @@ public function testRule(): void 51, ], [ - 'Generic type PropertyTag\Generic in PHPDoc tag @property for property PropertyTag\TestGenerics::$c specifies 3 template types, but class PropertyTag\Generic supports only 2: T, U', + 'PHPDoc tag @property for property PropertyTag\TestGenerics::$a contains generic type Exception but class Exception is not generic.', 51, ], [ @@ -123,16 +123,16 @@ public function testRule(): void 75, ], [ - 'PHPDoc tag @property for property PropertyTag\NonexistentClasses::$a contains unknown class PropertyTag\Nonexistent.', + 'Class PropertyTag\Foo referenced with incorrect case: PropertyTag\fOO.', 85, - 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'PHPDoc tag @property for property PropertyTag\NonexistentClasses::$b contains invalid type PropertyTagTrait\Foo.', + 'PHPDoc tag @property for property PropertyTag\NonexistentClasses::$a contains unknown class PropertyTag\Nonexistent.', 85, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Class PropertyTag\Foo referenced with incorrect case: PropertyTag\fOO.', + 'PHPDoc tag @property for property PropertyTag\NonexistentClasses::$b contains invalid type PropertyTagTrait\Foo.', 85, ], ]); diff --git a/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php b/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php index 542ba55e5e..9574294bf2 100644 --- a/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php +++ b/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php @@ -27,11 +27,11 @@ public function testUnusedConstructorParametersNoExactLine(): void $this->reportExactLine = false; $this->analyse([__DIR__ . '/data/unused-constructor-parameters.php'], [ [ - 'Constructor of class UnusedConstructorParameters\Foo has an unused parameter $unusedParameter.', + 'Constructor of class UnusedConstructorParameters\Foo has an unused parameter $anotherUnusedParameter.', 11, ], [ - 'Constructor of class UnusedConstructorParameters\Foo has an unused parameter $anotherUnusedParameter.', + 'Constructor of class UnusedConstructorParameters\Foo has an unused parameter $unusedParameter.', 11, ], ]); diff --git a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php index 021f8cd455..53de596977 100644 --- a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php @@ -184,45 +184,6 @@ public function testImpossibleCheckTypeFunctionCall(): void 'Call to function method_exists() with CheckTypeFunctionCall\MethodExists and \'testWithNewObjectIn…\' will always evaluate to true.', 635, ], - [ - 'Call to function method_exists() with $this(CheckTypeFunctionCall\MethodExistsWithTrait) and \'method\' will always evaluate to true.', - 650, - ], - [ - 'Call to function method_exists() with $this(CheckTypeFunctionCall\MethodExistsWithTrait) and \'someAnother\' will always evaluate to true.', - 653, - ], - [ - 'Call to function method_exists() with $this(CheckTypeFunctionCall\MethodExistsWithTrait) and \'unknown\' will always evaluate to false.', - 656, - ], - [ - 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'method\' will always evaluate to true.', - 659, - 'Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.', - ], - [ - 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'someAnother\' will always evaluate to true.', - 662, - 'Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.', - ], - [ - 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'unknown\' will always evaluate to false.', - 665, - 'Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.', - ], - [ - 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'method\' will always evaluate to true.', - 668, - ], - [ - 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'someAnother\' will always evaluate to true.', - 671, - ], - [ - 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'unknown\' will always evaluate to false.', - 674, - ], [ 'Call to function is_string() with string will always evaluate to true.', 703, @@ -277,6 +238,45 @@ public function testImpossibleCheckTypeFunctionCall(): void 952, 'Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.', ], + [ + 'Call to function method_exists() with $this(CheckTypeFunctionCall\MethodExistsWithTrait) and \'method\' will always evaluate to true.', + 650, + ], + [ + 'Call to function method_exists() with $this(CheckTypeFunctionCall\MethodExistsWithTrait) and \'someAnother\' will always evaluate to true.', + 653, + ], + [ + 'Call to function method_exists() with $this(CheckTypeFunctionCall\MethodExistsWithTrait) and \'unknown\' will always evaluate to false.', + 656, + ], + [ + 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'method\' will always evaluate to true.', + 659, + 'Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.', + ], + [ + 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'someAnother\' will always evaluate to true.', + 662, + 'Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.', + ], + [ + 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'unknown\' will always evaluate to false.', + 665, + 'Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.', + ], + [ + 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'method\' will always evaluate to true.', + 668, + ], + [ + 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'someAnother\' will always evaluate to true.', + 671, + ], + [ + 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExistsWithTrait\' and \'unknown\' will always evaluate to false.', + 674, + ], ], ); } diff --git a/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php b/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php index d7a005c589..215c7d193f 100644 --- a/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php @@ -157,11 +157,11 @@ public function testEnums(): void 104, ], [ - 'Match arm comparison between *NEVER* and MatchEnums\Foo::ONE is always false.', + 'Match arm comparison between *NEVER* and MatchEnums\DifferentEnum::ONE is always false.', 113, ], [ - 'Match arm comparison between *NEVER* and MatchEnums\DifferentEnum::ONE is always false.', + 'Match arm comparison between *NEVER* and MatchEnums\Foo::ONE is always false.', 113, ], ]); @@ -298,14 +298,14 @@ public function testLastArmAlwaysTrue(): void 62, $tipText, ], - [ - 'Match arm comparison between 1 and 0 is always false.', - 70, - ], [ 'Match expression does not handle remaining value: 1', 69, ], + [ + 'Match arm comparison between 1 and 0 is always false.', + 70, + ], ]); } diff --git a/tests/PHPStan/Rules/Constants/MagicConstantContextRuleTest.php b/tests/PHPStan/Rules/Constants/MagicConstantContextRuleTest.php index 2f598d78b3..5d4a073adc 100644 --- a/tests/PHPStan/Rules/Constants/MagicConstantContextRuleTest.php +++ b/tests/PHPStan/Rules/Constants/MagicConstantContextRuleTest.php @@ -145,10 +145,6 @@ public function testGlobalNamespace(): void 'Magic constant __TRAIT__ is always empty outside a trait.', 26, ], - [ - 'Magic constant __NAMESPACE__ is always empty in global namespace.', - 34, - ], [ 'Magic constant __CLASS__ is always empty outside a class.', 46, @@ -161,6 +157,10 @@ public function testGlobalNamespace(): void 'Magic constant __TRAIT__ is always empty outside a trait.', 51, ], + [ + 'Magic constant __NAMESPACE__ is always empty in global namespace.', + 34, + ], ]); } diff --git a/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php b/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php index c83a84d425..8e70966099 100644 --- a/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php +++ b/tests/PHPStan/Rules/DeadCode/UnusedPrivatePropertyRuleTest.php @@ -111,13 +111,13 @@ public function testRule(): void $tip, ], [ - 'Property class@anonymous/tests/PHPStan/Rules/DeadCode/data/unused-private-property.php:152::$bar is unused.', - 153, + 'Property UnusedPrivateProperty\DolorWithAnonymous::$foo is unused.', + 148, $tip, ], [ - 'Property UnusedPrivateProperty\DolorWithAnonymous::$foo is unused.', - 148, + 'Property class@anonymous/tests/PHPStan/Rules/DeadCode/data/unused-private-property.php:152::$bar is unused.', + 153, $tip, ], [ diff --git a/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php b/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php index 26b4a4b906..5e8496ef8f 100644 --- a/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php @@ -170,11 +170,11 @@ public function testNamedArguments(): void 14, ], [ - 'Unknown parameter $i in call to callable callable(int, int): void.', + 'Missing parameter $ (int) in call to callable callable(int, int): void.', 23, ], [ - 'Missing parameter $ (int) in call to callable callable(int, int): void.', + 'Unknown parameter $i in call to callable callable(int, int): void.', 23, ], [ diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 0eea3694d1..3d84ebefcd 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -1603,19 +1603,19 @@ public function testBug9018(): void $this->analyse([__DIR__ . '/data/bug-9018.php'], [ [ - 'Unknown parameter $str1 in call to function levenshtein.', + 'Missing parameter $string1 (string) in call to function levenshtein.', 13, ], [ - 'Unknown parameter $str2 in call to function levenshtein.', + 'Missing parameter $string2 (string) in call to function levenshtein.', 13, ], [ - 'Missing parameter $string1 (string) in call to function levenshtein.', + 'Unknown parameter $str1 in call to function levenshtein.', 13, ], [ - 'Missing parameter $string2 (string) in call to function levenshtein.', + 'Unknown parameter $str2 in call to function levenshtein.', 13, ], ]); diff --git a/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php b/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php index 4344c32b14..390b7ca2b7 100644 --- a/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php @@ -78,12 +78,12 @@ public function testMatchExprAnalysis(): void 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Function ipsum not found.', + 'Function dolor not found.', 11, 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Function dolor not found.', + 'Function ipsum not found.', 11, 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], diff --git a/tests/PHPStan/Rules/Functions/CallUserFuncRuleTest.php b/tests/PHPStan/Rules/Functions/CallUserFuncRuleTest.php index 7ee37a1458..5e6f0865cc 100644 --- a/tests/PHPStan/Rules/Functions/CallUserFuncRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallUserFuncRuleTest.php @@ -47,11 +47,11 @@ public function testRule(): void 19, ], [ - 'Unknown parameter $j in call to callable passed to call_user_func().', + 'Missing parameter $i (int) in call to callable passed to call_user_func().', 22, ], [ - 'Missing parameter $i (int) in call to callable passed to call_user_func().', + 'Unknown parameter $j in call to callable passed to call_user_func().', 22, ], [ diff --git a/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php b/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php index 5b603724ec..d258b1379c 100644 --- a/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php @@ -43,11 +43,11 @@ public function testRule(): void { $this->analyse([__DIR__ . '/data/arrow-function-typehints.php'], [ [ - 'Parameter $bar of anonymous function has invalid type ArrowFunctionExistingClassesInTypehints\Bar.', + 'Anonymous function has invalid return type ArrowFunctionExistingClassesInTypehints\Baz.', 10, ], [ - 'Anonymous function has invalid return type ArrowFunctionExistingClassesInTypehints\Baz.', + 'Parameter $bar of anonymous function has invalid type ArrowFunctionExistingClassesInTypehints\Bar.', 10, ], ]); @@ -171,11 +171,11 @@ public function dataRequiredParameterAfterOptional(): array 21, ], [ - 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 25, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', 25, ], ], @@ -220,7 +220,7 @@ public function dataRequiredParameterAfterOptional(): array 23, ], [ - 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 25, ], [ @@ -228,7 +228,7 @@ public function dataRequiredParameterAfterOptional(): array 25, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', 25, ], ], @@ -258,19 +258,19 @@ public function dataIntersectionTypes(): array 80100, [ [ - 'Parameter $a of anonymous function has unresolvable native type.', + 'Anonymous function has unresolvable native return type.', 27, ], [ - 'Anonymous function has unresolvable native return type.', + 'Parameter $a of anonymous function has unresolvable native type.', 27, ], [ - 'Parameter $a of anonymous function has unresolvable native type.', + 'Anonymous function has unresolvable native return type.', 29, ], [ - 'Anonymous function has unresolvable native return type.', + 'Parameter $a of anonymous function has unresolvable native type.', 29, ], ], diff --git a/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php b/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php index db80402633..26127ac069 100644 --- a/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php @@ -50,11 +50,11 @@ public function testExistingClassInTypehint(): void 15, ], [ - 'Class TestClosureFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestClosureFunctionTypehints\fOOfUnctionTypehints.', + 'Class TestClosureFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestClosureFunctionTypehints\FOOfUnctionTypehintS.', 30, ], [ - 'Class TestClosureFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestClosureFunctionTypehints\FOOfUnctionTypehintS.', + 'Class TestClosureFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestClosureFunctionTypehints\fOOfUnctionTypehints.', 30, ], [ @@ -72,11 +72,11 @@ public function testValidTypehintPhp71(): void { $this->analyse([__DIR__ . '/data/closure-7.1-typehints.php'], [ [ - 'Parameter $bar of anonymous function has invalid type TestClosureFunctionTypehintsPhp71\NonexistentClass.', + 'Anonymous function has invalid return type TestClosureFunctionTypehintsPhp71\NonexistentClass.', 35, ], [ - 'Anonymous function has invalid return type TestClosureFunctionTypehintsPhp71\NonexistentClass.', + 'Parameter $bar of anonymous function has invalid type TestClosureFunctionTypehintsPhp71\NonexistentClass.', 35, ], ]); @@ -215,11 +215,11 @@ public function dataRequiredParameterAfterOptional(): array 37, ], [ - 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 45, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', 45, ], ], @@ -264,7 +264,7 @@ public function dataRequiredParameterAfterOptional(): array 41, ], [ - 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 45, ], [ @@ -272,7 +272,7 @@ public function dataRequiredParameterAfterOptional(): array 45, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', 45, ], ], @@ -302,19 +302,19 @@ public function dataIntersectionTypes(): array 80100, [ [ - 'Parameter $a of anonymous function has unresolvable native type.', + 'Anonymous function has unresolvable native return type.', 30, ], [ - 'Anonymous function has unresolvable native return type.', + 'Parameter $a of anonymous function has unresolvable native type.', 30, ], [ - 'Parameter $a of anonymous function has unresolvable native type.', + 'Anonymous function has unresolvable native return type.', 35, ], [ - 'Anonymous function has unresolvable native return type.', + 'Parameter $a of anonymous function has unresolvable native type.', 35, ], ], diff --git a/tests/PHPStan/Rules/Functions/ExistingClassesInTypehintsRuleTest.php b/tests/PHPStan/Rules/Functions/ExistingClassesInTypehintsRuleTest.php index 46e872ec74..f47dc8c831 100644 --- a/tests/PHPStan/Rules/Functions/ExistingClassesInTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ExistingClassesInTypehintsRuleTest.php @@ -55,11 +55,11 @@ public function testExistingClassInTypehint(): void 33, ], [ - 'Class TestFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestFunctionTypehints\fOOFunctionTypehints.', + 'Class TestFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestFunctionTypehints\fOOFunctionTypehintS.', 38, ], [ - 'Class TestFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestFunctionTypehints\fOOFunctionTypehintS.', + 'Class TestFunctionTypehints\FooFunctionTypehints referenced with incorrect case: TestFunctionTypehints\fOOFunctionTypehints.', 38, ], [ @@ -79,19 +79,19 @@ public function testExistingClassInTypehint(): void 56, ], [ - 'Parameter $trait of function TestFunctionTypehints\referencesTraitsInNative() has invalid type TestFunctionTypehints\SomeTrait.', + 'Function TestFunctionTypehints\referencesTraitsInNative() has invalid return type TestFunctionTypehints\SomeTrait.', 61, ], [ - 'Function TestFunctionTypehints\referencesTraitsInNative() has invalid return type TestFunctionTypehints\SomeTrait.', + 'Parameter $trait of function TestFunctionTypehints\referencesTraitsInNative() has invalid type TestFunctionTypehints\SomeTrait.', 61, ], [ - 'Parameter $trait of function TestFunctionTypehints\referencesTraitsInPhpDoc() has invalid type TestFunctionTypehints\SomeTrait.', + 'Function TestFunctionTypehints\referencesTraitsInPhpDoc() has invalid return type TestFunctionTypehints\SomeTrait.', 70, ], [ - 'Function TestFunctionTypehints\referencesTraitsInPhpDoc() has invalid return type TestFunctionTypehints\SomeTrait.', + 'Parameter $trait of function TestFunctionTypehints\referencesTraitsInPhpDoc() has invalid type TestFunctionTypehints\SomeTrait.', 70, ], [ @@ -126,11 +126,11 @@ public function testWithoutNamespace(): void 31, ], [ - 'Class FooFunctionTypehints referenced with incorrect case: fOOFunctionTypehints.', + 'Class FooFunctionTypehints referenced with incorrect case: fOOFunctionTypehintS.', 36, ], [ - 'Class FooFunctionTypehints referenced with incorrect case: fOOFunctionTypehintS.', + 'Class FooFunctionTypehints referenced with incorrect case: fOOFunctionTypehints.', 36, ], [ @@ -150,19 +150,19 @@ public function testWithoutNamespace(): void 54, ], [ - 'Parameter $trait of function referencesTraitsInNativeWithoutNamespace() has invalid type SomeTraitWithoutNamespace.', + 'Function referencesTraitsInNativeWithoutNamespace() has invalid return type SomeTraitWithoutNamespace.', 59, ], [ - 'Function referencesTraitsInNativeWithoutNamespace() has invalid return type SomeTraitWithoutNamespace.', + 'Parameter $trait of function referencesTraitsInNativeWithoutNamespace() has invalid type SomeTraitWithoutNamespace.', 59, ], [ - 'Parameter $trait of function referencesTraitsInPhpDocWithoutNamespace() has invalid type SomeTraitWithoutNamespace.', + 'Function referencesTraitsInPhpDocWithoutNamespace() has invalid return type SomeTraitWithoutNamespace.', 68, ], [ - 'Function referencesTraitsInPhpDocWithoutNamespace() has invalid return type SomeTraitWithoutNamespace.', + 'Parameter $trait of function referencesTraitsInPhpDocWithoutNamespace() has invalid type SomeTraitWithoutNamespace.', 68, ], ]); @@ -296,11 +296,11 @@ public function dataRequiredParameterAfterOptional(): array 42, ], [ - 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 50, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', 50, ], ], @@ -345,7 +345,7 @@ public function dataRequiredParameterAfterOptional(): array 46, ], [ - 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 50, ], [ @@ -353,7 +353,7 @@ public function dataRequiredParameterAfterOptional(): array 50, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', 50, ], ], @@ -383,19 +383,19 @@ public function dataIntersectionTypes(): array 80100, [ [ - 'Parameter $a of function FunctionIntersectionTypes\doBar() has unresolvable native type.', + 'Function FunctionIntersectionTypes\doBar() has unresolvable native return type.', 30, ], [ - 'Function FunctionIntersectionTypes\doBar() has unresolvable native return type.', + 'Parameter $a of function FunctionIntersectionTypes\doBar() has unresolvable native type.', 30, ], [ - 'Parameter $a of function FunctionIntersectionTypes\doBaz() has unresolvable native type.', + 'Function FunctionIntersectionTypes\doBaz() has unresolvable native return type.', 35, ], [ - 'Function FunctionIntersectionTypes\doBaz() has unresolvable native return type.', + 'Parameter $a of function FunctionIntersectionTypes\doBaz() has unresolvable native type.', 35, ], ], @@ -472,15 +472,15 @@ public function testParamOutClasses(): void { $this->analyse([__DIR__ . '/data/param-out-classes.php'], [ [ - 'Parameter $p of function ParamOutClasses\doFoo() has invalid type ParamOutClasses\Nonexistent.', + 'Class ParamOutClasses\Foo referenced with incorrect case: ParamOutClasses\fOO.', 20, ], [ - 'Parameter $q of function ParamOutClasses\doFoo() has invalid type ParamOutClasses\FooTrait.', + 'Parameter $p of function ParamOutClasses\doFoo() has invalid type ParamOutClasses\Nonexistent.', 20, ], [ - 'Class ParamOutClasses\Foo referenced with incorrect case: ParamOutClasses\fOO.', + 'Parameter $q of function ParamOutClasses\doFoo() has invalid type ParamOutClasses\FooTrait.', 20, ], ]); diff --git a/tests/PHPStan/Rules/Generics/ClassAncestorsRuleTest.php b/tests/PHPStan/Rules/Generics/ClassAncestorsRuleTest.php index dd82f5bada..db1ac2af02 100644 --- a/tests/PHPStan/Rules/Generics/ClassAncestorsRuleTest.php +++ b/tests/PHPStan/Rules/Generics/ClassAncestorsRuleTest.php @@ -39,11 +39,11 @@ public function testRuleExtends(): void 35, ], [ - 'The @extends tag of class ClassAncestorsExtends\FooWrongClassExtended describes ClassAncestorsExtends\FooGeneric2 but the class extends ClassAncestorsExtends\FooGeneric.', + 'Class ClassAncestorsExtends\FooWrongClassExtended extends generic class ClassAncestorsExtends\FooGeneric but does not specify its types: T, U', 43, ], [ - 'Class ClassAncestorsExtends\FooWrongClassExtended extends generic class ClassAncestorsExtends\FooGeneric but does not specify its types: T, U', + 'The @extends tag of class ClassAncestorsExtends\FooWrongClassExtended describes ClassAncestorsExtends\FooGeneric2 but the class extends ClassAncestorsExtends\FooGeneric.', 43, ], [ @@ -145,15 +145,15 @@ public function testRuleImplements(): void 44, ], [ - 'The @implements tag of class ClassAncestorsImplements\FooWrongClassImplemented describes ClassAncestorsImplements\FooGeneric2 but the class implements: ClassAncestorsImplements\FooGeneric, ClassAncestorsImplements\FooGeneric3', + 'Class ClassAncestorsImplements\FooWrongClassImplemented implements generic interface ClassAncestorsImplements\FooGeneric but does not specify its types: T, U', 52, ], [ - 'Class ClassAncestorsImplements\FooWrongClassImplemented implements generic interface ClassAncestorsImplements\FooGeneric but does not specify its types: T, U', + 'Class ClassAncestorsImplements\FooWrongClassImplemented implements generic interface ClassAncestorsImplements\FooGeneric3 but does not specify its types: T, W', 52, ], [ - 'Class ClassAncestorsImplements\FooWrongClassImplemented implements generic interface ClassAncestorsImplements\FooGeneric3 but does not specify its types: T, W', + 'The @implements tag of class ClassAncestorsImplements\FooWrongClassImplemented describes ClassAncestorsImplements\FooGeneric2 but the class implements: ClassAncestorsImplements\FooGeneric, ClassAncestorsImplements\FooGeneric3', 52, ], [ @@ -197,11 +197,11 @@ public function testRuleImplements(): void 172, ], [ - 'Type stdClass in generic type ClassAncestorsImplements\FooGeneric in PHPDoc tag @implements is not subtype of template type U of Exception of interface ClassAncestorsImplements\FooGeneric.', + 'Type stdClass in generic type ClassAncestorsImplements\FooGeneric2 in PHPDoc tag @implements is not subtype of template type V of Exception of interface ClassAncestorsImplements\FooGeneric2.', 182, ], [ - 'Type stdClass in generic type ClassAncestorsImplements\FooGeneric2 in PHPDoc tag @implements is not subtype of template type V of Exception of interface ClassAncestorsImplements\FooGeneric2.', + 'Type stdClass in generic type ClassAncestorsImplements\FooGeneric in PHPDoc tag @implements is not subtype of template type U of Exception of interface ClassAncestorsImplements\FooGeneric.', 182, ], [ diff --git a/tests/PHPStan/Rules/Generics/ClassTemplateTypeRuleTest.php b/tests/PHPStan/Rules/Generics/ClassTemplateTypeRuleTest.php index 0538311ee5..aa17ad3eca 100644 --- a/tests/PHPStan/Rules/Generics/ClassTemplateTypeRuleTest.php +++ b/tests/PHPStan/Rules/Generics/ClassTemplateTypeRuleTest.php @@ -54,11 +54,11 @@ public function testRule(): void 41, ], [ - 'PHPDoc tag @template for class ClassTemplateType\Dolor cannot have existing type alias LocalAlias as its name.', + 'PHPDoc tag @template for class ClassTemplateType\Dolor cannot have existing type alias ImportedAlias as its name.', 53, ], [ - 'PHPDoc tag @template for class ClassTemplateType\Dolor cannot have existing type alias ImportedAlias as its name.', + 'PHPDoc tag @template for class ClassTemplateType\Dolor cannot have existing type alias LocalAlias as its name.', 53, ], [ @@ -78,13 +78,13 @@ public function testRule(): void 78, ], [ - 'Call-site variance of covariant int in generic type ClassTemplateType\Consecteur in PHPDoc tag @template U is redundant, template type T of class ClassTemplateType\Consecteur has the same variance.', + 'Call-site variance of contravariant int in generic type ClassTemplateType\Consecteur in PHPDoc tag @template W is in conflict with covariant template type T of class ClassTemplateType\Consecteur.', 113, - 'You can safely remove the call-site variance annotation.', ], [ - 'Call-site variance of contravariant int in generic type ClassTemplateType\Consecteur in PHPDoc tag @template W is in conflict with covariant template type T of class ClassTemplateType\Consecteur.', + 'Call-site variance of covariant int in generic type ClassTemplateType\Consecteur in PHPDoc tag @template U is redundant, template type T of class ClassTemplateType\Consecteur has the same variance.', 113, + 'You can safely remove the call-site variance annotation.', ], [ 'PHPDoc tag @template T for class ClassTemplateType\Elit has invalid default type ClassTemplateType\Zazzzu.', diff --git a/tests/PHPStan/Rules/Generics/FunctionTemplateTypeRuleTest.php b/tests/PHPStan/Rules/Generics/FunctionTemplateTypeRuleTest.php index f9d15da674..07ccb8616a 100644 --- a/tests/PHPStan/Rules/Generics/FunctionTemplateTypeRuleTest.php +++ b/tests/PHPStan/Rules/Generics/FunctionTemplateTypeRuleTest.php @@ -59,13 +59,13 @@ public function testRule(): void 68, ], [ - 'Call-site variance of covariant int in generic type FunctionTemplateType\GenericCovariant in PHPDoc tag @template U is redundant, template type T of class FunctionTemplateType\GenericCovariant has the same variance.', + 'Call-site variance of contravariant int in generic type FunctionTemplateType\GenericCovariant in PHPDoc tag @template W is in conflict with covariant template type T of class FunctionTemplateType\GenericCovariant.', 94, - 'You can safely remove the call-site variance annotation.', ], [ - 'Call-site variance of contravariant int in generic type FunctionTemplateType\GenericCovariant in PHPDoc tag @template W is in conflict with covariant template type T of class FunctionTemplateType\GenericCovariant.', + 'Call-site variance of covariant int in generic type FunctionTemplateType\GenericCovariant in PHPDoc tag @template U is redundant, template type T of class FunctionTemplateType\GenericCovariant has the same variance.', 94, + 'You can safely remove the call-site variance annotation.', ], [ 'PHPDoc tag @template T for function FunctionTemplateType\invalidDefault() has invalid default type FunctionTemplateType\Zazzzu.', diff --git a/tests/PHPStan/Rules/Generics/InterfaceAncestorsRuleTest.php b/tests/PHPStan/Rules/Generics/InterfaceAncestorsRuleTest.php index f82610ea0b..a6c7b3c022 100644 --- a/tests/PHPStan/Rules/Generics/InterfaceAncestorsRuleTest.php +++ b/tests/PHPStan/Rules/Generics/InterfaceAncestorsRuleTest.php @@ -129,15 +129,15 @@ public function testRuleExtends(): void 44, ], [ - 'The @extends tag of interface InterfaceAncestorsExtends\FooWrongClassImplemented describes InterfaceAncestorsExtends\FooGeneric2 but the interface extends: InterfaceAncestorsExtends\FooGeneric, InterfaceAncestorsExtends\FooGeneric3', + 'Interface InterfaceAncestorsExtends\FooWrongClassImplemented extends generic interface InterfaceAncestorsExtends\FooGeneric but does not specify its types: T, U', 52, ], [ - 'Interface InterfaceAncestorsExtends\FooWrongClassImplemented extends generic interface InterfaceAncestorsExtends\FooGeneric but does not specify its types: T, U', + 'Interface InterfaceAncestorsExtends\FooWrongClassImplemented extends generic interface InterfaceAncestorsExtends\FooGeneric3 but does not specify its types: T, W', 52, ], [ - 'Interface InterfaceAncestorsExtends\FooWrongClassImplemented extends generic interface InterfaceAncestorsExtends\FooGeneric3 but does not specify its types: T, W', + 'The @extends tag of interface InterfaceAncestorsExtends\FooWrongClassImplemented describes InterfaceAncestorsExtends\FooGeneric2 but the interface extends: InterfaceAncestorsExtends\FooGeneric, InterfaceAncestorsExtends\FooGeneric3', 52, ], [ @@ -181,11 +181,11 @@ public function testRuleExtends(): void 172, ], [ - 'Type stdClass in generic type InterfaceAncestorsExtends\FooGeneric in PHPDoc tag @extends is not subtype of template type U of Exception of interface InterfaceAncestorsExtends\FooGeneric.', + 'Type stdClass in generic type InterfaceAncestorsExtends\FooGeneric2 in PHPDoc tag @extends is not subtype of template type V of Exception of interface InterfaceAncestorsExtends\FooGeneric2.', 182, ], [ - 'Type stdClass in generic type InterfaceAncestorsExtends\FooGeneric2 in PHPDoc tag @extends is not subtype of template type V of Exception of interface InterfaceAncestorsExtends\FooGeneric2.', + 'Type stdClass in generic type InterfaceAncestorsExtends\FooGeneric in PHPDoc tag @extends is not subtype of template type U of Exception of interface InterfaceAncestorsExtends\FooGeneric.', 182, ], [ diff --git a/tests/PHPStan/Rules/Generics/InterfaceTemplateTypeRuleTest.php b/tests/PHPStan/Rules/Generics/InterfaceTemplateTypeRuleTest.php index b997498703..8233b39e30 100644 --- a/tests/PHPStan/Rules/Generics/InterfaceTemplateTypeRuleTest.php +++ b/tests/PHPStan/Rules/Generics/InterfaceTemplateTypeRuleTest.php @@ -49,21 +49,21 @@ public function testRule(): void 33, ], [ - 'PHPDoc tag @template for interface InterfaceTemplateType\Ipsum cannot have existing type alias LocalAlias as its name.', + 'PHPDoc tag @template for interface InterfaceTemplateType\Ipsum cannot have existing type alias ImportedAlias as its name.', 45, ], [ - 'PHPDoc tag @template for interface InterfaceTemplateType\Ipsum cannot have existing type alias ImportedAlias as its name.', + 'PHPDoc tag @template for interface InterfaceTemplateType\Ipsum cannot have existing type alias LocalAlias as its name.', 45, ], [ - 'Call-site variance of covariant int in generic type InterfaceTemplateType\Covariant in PHPDoc tag @template U is redundant, template type T of interface InterfaceTemplateType\Covariant has the same variance.', + 'Call-site variance of contravariant int in generic type InterfaceTemplateType\Covariant in PHPDoc tag @template W is in conflict with covariant template type T of interface InterfaceTemplateType\Covariant.', 74, - 'You can safely remove the call-site variance annotation.', ], [ - 'Call-site variance of contravariant int in generic type InterfaceTemplateType\Covariant in PHPDoc tag @template W is in conflict with covariant template type T of interface InterfaceTemplateType\Covariant.', + 'Call-site variance of covariant int in generic type InterfaceTemplateType\Covariant in PHPDoc tag @template U is redundant, template type T of interface InterfaceTemplateType\Covariant has the same variance.', 74, + 'You can safely remove the call-site variance annotation.', ], [ 'PHPDoc tag @template T for interface InterfaceTemplateType\InvalidDefault has invalid default type InterfaceTemplateType\Zazzzu.', diff --git a/tests/PHPStan/Rules/Generics/MethodSignatureVarianceRuleTest.php b/tests/PHPStan/Rules/Generics/MethodSignatureVarianceRuleTest.php index ec893f0947..14ebf94139 100644 --- a/tests/PHPStan/Rules/Generics/MethodSignatureVarianceRuleTest.php +++ b/tests/PHPStan/Rules/Generics/MethodSignatureVarianceRuleTest.php @@ -44,15 +44,15 @@ public function testRule(): void 35, ], [ - 'Template type X is declared as covariant, but occurs in invariant position in parameter e of method MethodSignatureVariance\Covariant\C::a().', + 'Template type X is declared as covariant, but occurs in contravariant position in parameter f of method MethodSignatureVariance\Covariant\C::a().', 35, ], [ - 'Template type X is declared as covariant, but occurs in contravariant position in parameter f of method MethodSignatureVariance\Covariant\C::a().', + 'Template type X is declared as covariant, but occurs in contravariant position in parameter h of method MethodSignatureVariance\Covariant\C::a().', 35, ], [ - 'Template type X is declared as covariant, but occurs in contravariant position in parameter h of method MethodSignatureVariance\Covariant\C::a().', + 'Template type X is declared as covariant, but occurs in invariant position in parameter e of method MethodSignatureVariance\Covariant\C::a().', 35, ], [ @@ -115,11 +115,11 @@ public function testRule(): void 35, ], [ - 'Template type X is declared as contravariant, but occurs in invariant position in parameter e of method MethodSignatureVariance\Contravariant\C::a().', + 'Template type X is declared as contravariant, but occurs in covariant position in parameter g of method MethodSignatureVariance\Contravariant\C::a().', 35, ], [ - 'Template type X is declared as contravariant, but occurs in covariant position in parameter g of method MethodSignatureVariance\Contravariant\C::a().', + 'Template type X is declared as contravariant, but occurs in invariant position in parameter e of method MethodSignatureVariance\Contravariant\C::a().', 35, ], [ diff --git a/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeRuleTest.php b/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeRuleTest.php index 1db002fd94..360c015879 100644 --- a/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeRuleTest.php +++ b/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeRuleTest.php @@ -41,15 +41,15 @@ public function testRule(): void { $this->analyse([__DIR__ . '/data/method-tag-template.php'], [ [ - 'PHPDoc tag @method template U for method MethodTagTemplate\HelloWorld::sayHello() has invalid bound type MethodTagTemplate\Nonexisting.', + 'PHPDoc tag @method template T for method MethodTagTemplate\HelloWorld::sayHello() shadows @template T for class MethodTagTemplate\HelloWorld.', 13, ], [ - 'PHPDoc tag @method template for method MethodTagTemplate\HelloWorld::sayHello() cannot have existing class stdClass as its name.', + 'PHPDoc tag @method template U for method MethodTagTemplate\HelloWorld::sayHello() has invalid bound type MethodTagTemplate\Nonexisting.', 13, ], [ - 'PHPDoc tag @method template T for method MethodTagTemplate\HelloWorld::sayHello() shadows @template T for class MethodTagTemplate\HelloWorld.', + 'PHPDoc tag @method template for method MethodTagTemplate\HelloWorld::sayHello() cannot have existing class stdClass as its name.', 13, ], [ diff --git a/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeTraitRuleTest.php b/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeTraitRuleTest.php index 773f6c30c3..1eec54168f 100644 --- a/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeTraitRuleTest.php +++ b/tests/PHPStan/Rules/Generics/MethodTagTemplateTypeTraitRuleTest.php @@ -42,15 +42,15 @@ public function testRule(): void { $this->analyse([__DIR__ . '/data/method-tag-trait-template.php'], [ [ - 'PHPDoc tag @method template U for method MethodTagTraitTemplate\HelloWorld::sayHello() has invalid bound type MethodTagTraitTemplate\Nonexisting.', + 'PHPDoc tag @method template T for method MethodTagTraitTemplate\HelloWorld::sayHello() shadows @template T for class MethodTagTraitTemplate\HelloWorld.', 11, ], [ - 'PHPDoc tag @method template for method MethodTagTraitTemplate\HelloWorld::sayHello() cannot have existing class stdClass as its name.', + 'PHPDoc tag @method template U for method MethodTagTraitTemplate\HelloWorld::sayHello() has invalid bound type MethodTagTraitTemplate\Nonexisting.', 11, ], [ - 'PHPDoc tag @method template T for method MethodTagTraitTemplate\HelloWorld::sayHello() shadows @template T for class MethodTagTraitTemplate\HelloWorld.', + 'PHPDoc tag @method template for method MethodTagTraitTemplate\HelloWorld::sayHello() cannot have existing class stdClass as its name.', 11, ], [ diff --git a/tests/PHPStan/Rules/Generics/MethodTemplateTypeRuleTest.php b/tests/PHPStan/Rules/Generics/MethodTemplateTypeRuleTest.php index 9276fec7c1..53496b51a8 100644 --- a/tests/PHPStan/Rules/Generics/MethodTemplateTypeRuleTest.php +++ b/tests/PHPStan/Rules/Generics/MethodTemplateTypeRuleTest.php @@ -57,21 +57,21 @@ public function testRule(): void 66, ], [ - 'PHPDoc tag @template for method MethodTemplateType\Ipsum::doFoo() cannot have existing type alias LocalAlias as its name.', + 'PHPDoc tag @template for method MethodTemplateType\Ipsum::doFoo() cannot have existing type alias ImportedAlias as its name.', 85, ], [ - 'PHPDoc tag @template for method MethodTemplateType\Ipsum::doFoo() cannot have existing type alias ImportedAlias as its name.', + 'PHPDoc tag @template for method MethodTemplateType\Ipsum::doFoo() cannot have existing type alias LocalAlias as its name.', 85, ], [ - 'Call-site variance of covariant int in generic type MethodTemplateType\Dolor in PHPDoc tag @template U is redundant, template type T of class MethodTemplateType\Dolor has the same variance.', + 'Call-site variance of contravariant int in generic type MethodTemplateType\Dolor in PHPDoc tag @template W is in conflict with covariant template type T of class MethodTemplateType\Dolor.', 109, - 'You can safely remove the call-site variance annotation.', ], [ - 'Call-site variance of contravariant int in generic type MethodTemplateType\Dolor in PHPDoc tag @template W is in conflict with covariant template type T of class MethodTemplateType\Dolor.', + 'Call-site variance of covariant int in generic type MethodTemplateType\Dolor in PHPDoc tag @template U is redundant, template type T of class MethodTemplateType\Dolor has the same variance.', 109, + 'You can safely remove the call-site variance annotation.', ], [ 'PHPDoc tag @template T for method MethodTemplateType\InvalidDefault::invalid() has invalid default type MethodTemplateType\Zazzzu.', diff --git a/tests/PHPStan/Rules/Generics/TraitTemplateTypeRuleTest.php b/tests/PHPStan/Rules/Generics/TraitTemplateTypeRuleTest.php index 84351d9ea9..3131aa18fc 100644 --- a/tests/PHPStan/Rules/Generics/TraitTemplateTypeRuleTest.php +++ b/tests/PHPStan/Rules/Generics/TraitTemplateTypeRuleTest.php @@ -53,21 +53,21 @@ public function testRule(): void 33, ], [ - 'PHPDoc tag @template for trait TraitTemplateType\Ipsum cannot have existing type alias LocalAlias as its name.', + 'PHPDoc tag @template for trait TraitTemplateType\Ipsum cannot have existing type alias ImportedAlias as its name.', 45, ], [ - 'PHPDoc tag @template for trait TraitTemplateType\Ipsum cannot have existing type alias ImportedAlias as its name.', + 'PHPDoc tag @template for trait TraitTemplateType\Ipsum cannot have existing type alias LocalAlias as its name.', 45, ], [ - 'Call-site variance of covariant int in generic type TraitTemplateType\Dolor in PHPDoc tag @template U is redundant, template type T of class TraitTemplateType\Dolor has the same variance.', + 'Call-site variance of contravariant int in generic type TraitTemplateType\Dolor in PHPDoc tag @template W is in conflict with covariant template type T of class TraitTemplateType\Dolor.', 64, - 'You can safely remove the call-site variance annotation.', ], [ - 'Call-site variance of contravariant int in generic type TraitTemplateType\Dolor in PHPDoc tag @template W is in conflict with covariant template type T of class TraitTemplateType\Dolor.', + 'Call-site variance of covariant int in generic type TraitTemplateType\Dolor in PHPDoc tag @template U is redundant, template type T of class TraitTemplateType\Dolor has the same variance.', 64, + 'You can safely remove the call-site variance annotation.', ], [ 'PHPDoc tag @template T for trait TraitTemplateType\Adipiscing has invalid default type TraitTemplateType\Zazzzu.', diff --git a/tests/PHPStan/Rules/Generics/UsedTraitsRuleTest.php b/tests/PHPStan/Rules/Generics/UsedTraitsRuleTest.php index 76dc75145f..defe5d853f 100644 --- a/tests/PHPStan/Rules/Generics/UsedTraitsRuleTest.php +++ b/tests/PHPStan/Rules/Generics/UsedTraitsRuleTest.php @@ -47,6 +47,10 @@ public function testRule(): void 'Generic type UsedTraits\GenericTrait in PHPDoc tag @use specifies 2 template types, but trait UsedTraits\GenericTrait supports only 1: T', 46, ], + [ + 'Call-site variance annotation of covariant Throwable in generic type UsedTraits\GenericTrait in PHPDoc tag @use is not allowed.', + 69, + ], [ 'The @use tag of trait UsedTraits\NestedTrait describes UsedTraits\NongenericTrait but the trait uses UsedTraits\GenericTrait.', 54, @@ -55,10 +59,6 @@ public function testRule(): void 'Trait UsedTraits\NestedTrait uses generic trait UsedTraits\GenericTrait but does not specify its types: T', 54, ], - [ - 'Call-site variance annotation of covariant Throwable in generic type UsedTraits\GenericTrait in PHPDoc tag @use is not allowed.', - 69, - ], ]); } diff --git a/tests/PHPStan/Rules/Methods/AbstractMethodInNonAbstractClassRuleTest.php b/tests/PHPStan/Rules/Methods/AbstractMethodInNonAbstractClassRuleTest.php index 7ec5a8d7f4..0b2f764b31 100644 --- a/tests/PHPStan/Rules/Methods/AbstractMethodInNonAbstractClassRuleTest.php +++ b/tests/PHPStan/Rules/Methods/AbstractMethodInNonAbstractClassRuleTest.php @@ -96,14 +96,6 @@ public function testBug11592(): void } $this->analyse([__DIR__ . '/../Classes/data/bug-11592.php'], [ - [ - 'Enum Bug11592\Test contains abstract method from().', - 9, - ], - [ - 'Enum Bug11592\Test contains abstract method tryFrom().', - 11, - ], [ 'Enum Bug11592\Test2 contains abstract method from().', 24, @@ -116,6 +108,14 @@ public function testBug11592(): void 'Enum Bug11592\EnumWithAbstractMethod contains abstract method foo().', 46, ], + [ + 'Enum Bug11592\Test contains abstract method from().', + 9, + ], + [ + 'Enum Bug11592\Test contains abstract method tryFrom().', + 11, + ], ]); } diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index bee0436a8d..ebed2e4679 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -1346,6 +1346,10 @@ public function testIterables(bool $checkNullables): void 'Parameter #1 $iterableWithoutTypehint of method CallMethodsIterables\Foo::doFoo() expects iterable, int given.', 62, ], + [ + 'Parameter #10 $mixeds of method CallMethodsIterables\Foo::doFoo() expects iterable, int given.', + 62, + ], [ 'Parameter #2 $iterableWithIterableTypehint of method CallMethodsIterables\Foo::doFoo() expects iterable, int given.', 62, @@ -1374,10 +1378,6 @@ public function testIterables(bool $checkNullables): void 'Parameter #9 $integers of method CallMethodsIterables\Foo::doFoo() expects iterable, int given.', 62, ], - [ - 'Parameter #10 $mixeds of method CallMethodsIterables\Foo::doFoo() expects iterable, int given.', - 62, - ], ]); } @@ -1844,14 +1844,6 @@ public function testNamedArguments(): void $this->checkUnionTypes = true; $this->analyse([__DIR__ . '/data/named-arguments.php'], [ - [ - 'Named argument cannot be followed by a positional argument.', - 21, - ], - [ - 'Named argument cannot be followed by a positional argument.', - 22, - ], [ 'Missing parameter $j (int) in call to method NamedArgumentsMethod\Foo::doFoo().', 19, @@ -1860,6 +1852,14 @@ public function testNamedArguments(): void 'Missing parameter $k (int) in call to method NamedArgumentsMethod\Foo::doFoo().', 19, ], + [ + 'Named argument cannot be followed by a positional argument.', + 21, + ], + [ + 'Named argument cannot be followed by a positional argument.', + 22, + ], [ 'Argument for parameter $i has already been passed.', 26, @@ -1901,11 +1901,11 @@ public function testNamedArguments(): void 75, ], [ - 'Named argument cannot be followed by a positional argument.', + 'Missing parameter $j (int) in call to method NamedArgumentsMethod\Foo::doFoo().', 77, ], [ - 'Missing parameter $j (int) in call to method NamedArgumentsMethod\Foo::doFoo().', + 'Named argument cannot be followed by a positional argument.', 77, ], [ @@ -1917,11 +1917,11 @@ public function testNamedArguments(): void 90, ], [ - 'Parameter $b of method NamedArgumentsMethod\Foo::doIpsum() expects int, string given.', + 'Named argument foo for variadic parameter ...$args of method NamedArgumentsMethod\Foo::doIpsum() expects string, int given.', 91, ], [ - 'Named argument foo for variadic parameter ...$args of method NamedArgumentsMethod\Foo::doIpsum() expects string, int given.', + 'Parameter $b of method NamedArgumentsMethod\Foo::doIpsum() expects int, string given.', 91, ], [ @@ -1937,11 +1937,11 @@ public function testNamedArguments(): void 94, ], [ - 'Named argument foo for variadic parameter ...$args of method NamedArgumentsMethod\Foo::doIpsum() expects string, int given.', + 'Named argument bar for variadic parameter ...$args of method NamedArgumentsMethod\Foo::doIpsum() expects string, int given.', 95, ], [ - 'Named argument bar for variadic parameter ...$args of method NamedArgumentsMethod\Foo::doIpsum() expects string, int given.', + 'Named argument foo for variadic parameter ...$args of method NamedArgumentsMethod\Foo::doIpsum() expects string, int given.', 95, ], ]); @@ -2421,10 +2421,6 @@ public function testEnums(): void 'Call to an undefined method CallMethodInEnum\Foo::doNonexistent().', 11, ], - [ - 'Call to an undefined method CallMethodInEnum\Bar::doNonexistent().', - 22, - ], [ 'Parameter #1 $countryName of method CallMethodInEnum\FooCall::hello() expects \'The Netherlands\'|\'United States\', CallMethodInEnum\CountryNo::NL given.', 63, @@ -2453,6 +2449,10 @@ public function testEnums(): void 'Parameter #1 $one of method CallMethodInEnum\TestPassingEnums::requireOne() expects CallMethodInEnum\TestPassingEnums::ONE, $this(CallMethodInEnum\TestPassingEnums)&CallMethodInEnum\TestPassingEnums given.', 106, ], + [ + 'Call to an undefined method CallMethodInEnum\Bar::doNonexistent().', + 22, + ], ]); } @@ -3188,11 +3188,11 @@ public function testNamedParametersForMultiVariantFunctions(): void $this->analyse([__DIR__ . '/data/call-methods-named-params-multivariant.php'], [ [ - 'Unknown parameter $options in call to method XSLTProcessor::setParameter().', + 'Missing parameter $name (array) in call to method XSLTProcessor::setParameter().', 10, ], [ - 'Missing parameter $name (array) in call to method XSLTProcessor::setParameter().', + 'Unknown parameter $options in call to method XSLTProcessor::setParameter().', 10, ], [ diff --git a/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php index 8b1a40dd21..64c477413a 100644 --- a/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php @@ -147,11 +147,11 @@ public function testCallStaticMethods(): void 120, ], [ - 'Class CallStaticMethods\Foo referenced with incorrect case: CallStaticMethods\FOO.', + 'Call to an undefined static method CallStaticMethods\Foo::unknownMethod().', 127, ], [ - 'Call to an undefined static method CallStaticMethods\Foo::unknownMethod().', + 'Class CallStaticMethods\Foo referenced with incorrect case: CallStaticMethods\FOO.', 127, ], [ @@ -163,11 +163,11 @@ public function testCallStaticMethods(): void 128, ], [ - 'Class CallStaticMethods\Foo referenced with incorrect case: CallStaticMethods\FOO.', + 'Call to private static method dolor() of class CallStaticMethods\Foo.', 129, ], [ - 'Call to private static method dolor() of class CallStaticMethods\Foo.', + 'Class CallStaticMethods\Foo referenced with incorrect case: CallStaticMethods\FOO.', 129, ], [ @@ -179,11 +179,11 @@ public function testCallStaticMethods(): void 130, ], [ - 'Class CallStaticMethods\Foo referenced with incorrect case: CallStaticMethods\FOO.', + 'Call to static method CallStaticMethods\Foo::test() with incorrect case: TEST', 131, ], [ - 'Call to static method CallStaticMethods\Foo::test() with incorrect case: TEST', + 'Class CallStaticMethods\Foo referenced with incorrect case: CallStaticMethods\FOO.', 131, ], [ diff --git a/tests/PHPStan/Rules/Methods/ConstructorReturnTypeRuleTest.php b/tests/PHPStan/Rules/Methods/ConstructorReturnTypeRuleTest.php index 335972e370..ae92f58196 100644 --- a/tests/PHPStan/Rules/Methods/ConstructorReturnTypeRuleTest.php +++ b/tests/PHPStan/Rules/Methods/ConstructorReturnTypeRuleTest.php @@ -23,14 +23,14 @@ public function testRule(): void 'Constructor of class ConstructorReturnType\Bar has a return type.', 17, ], - [ - 'Constructor of class ConstructorReturnType\UsesFooTrait has a return type.', - 26, - ], [ 'Original constructor of trait ConstructorReturnType\BarTrait has a return type.', 35, ], + [ + 'Constructor of class ConstructorReturnType\UsesFooTrait has a return type.', + 26, + ], ]); } diff --git a/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php b/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php index e42210014d..de5ded0bb5 100644 --- a/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php @@ -50,63 +50,63 @@ public function testExistingClassInTypehint(): void 13, ], [ - 'Parameter $bars of method TestMethodTypehints\FooMethodTypehints::lorem() has invalid type TestMethodTypehints\BarMethodTypehints.', + 'Method TestMethodTypehints\FooMethodTypehints::lorem() has invalid return type TestMethodTypehints\BazMethodTypehints.', 28, ], [ - 'Method TestMethodTypehints\FooMethodTypehints::lorem() has invalid return type TestMethodTypehints\BazMethodTypehints.', + 'Parameter $bars of method TestMethodTypehints\FooMethodTypehints::lorem() has invalid type TestMethodTypehints\BarMethodTypehints.', 28, ], [ - 'Parameter $bars of method TestMethodTypehints\FooMethodTypehints::ipsum() has invalid type TestMethodTypehints\BarMethodTypehints.', + 'Method TestMethodTypehints\FooMethodTypehints::ipsum() has invalid return type TestMethodTypehints\BazMethodTypehints.', 38, ], [ - 'Method TestMethodTypehints\FooMethodTypehints::ipsum() has invalid return type TestMethodTypehints\BazMethodTypehints.', + 'Parameter $bars of method TestMethodTypehints\FooMethodTypehints::ipsum() has invalid type TestMethodTypehints\BarMethodTypehints.', 38, ], [ - 'Parameter $bars of method TestMethodTypehints\FooMethodTypehints::dolor() has invalid type TestMethodTypehints\BarMethodTypehints.', + 'Method TestMethodTypehints\FooMethodTypehints::dolor() has invalid return type TestMethodTypehints\BazMethodTypehints.', 48, ], [ - 'Method TestMethodTypehints\FooMethodTypehints::dolor() has invalid return type TestMethodTypehints\BazMethodTypehints.', + 'Parameter $bars of method TestMethodTypehints\FooMethodTypehints::dolor() has invalid type TestMethodTypehints\BarMethodTypehints.', 48, ], [ - 'Parameter $parent of method TestMethodTypehints\FooMethodTypehints::parentWithoutParent() has invalid type parent.', + 'Method TestMethodTypehints\FooMethodTypehints::parentWithoutParent() has invalid return type parent.', 53, ], [ - 'Method TestMethodTypehints\FooMethodTypehints::parentWithoutParent() has invalid return type parent.', + 'Parameter $parent of method TestMethodTypehints\FooMethodTypehints::parentWithoutParent() has invalid type parent.', 53, ], [ - 'Parameter $parent of method TestMethodTypehints\FooMethodTypehints::phpDocParentWithoutParent() has invalid type parent.', + 'Method TestMethodTypehints\FooMethodTypehints::phpDocParentWithoutParent() has invalid return type parent.', 62, ], [ - 'Method TestMethodTypehints\FooMethodTypehints::phpDocParentWithoutParent() has invalid return type parent.', + 'Parameter $parent of method TestMethodTypehints\FooMethodTypehints::phpDocParentWithoutParent() has invalid type parent.', 62, ], [ - 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehints.', + 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehintS.', 67, ], [ - 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehintS.', + 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehints.', 67, ], [ - 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehints.', + 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehintS.', 76, ], [ - 'Class stdClass referenced with incorrect case: STDClass.', + 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehints.', 76, ], [ - 'Class TestMethodTypehints\FooMethodTypehints referenced with incorrect case: TestMethodTypehints\fOOMethodTypehintS.', + 'Class stdClass referenced with incorrect case: STDClass.', 76, ], [ @@ -152,11 +152,11 @@ public function testExistingClassInIterableTypehint(): void { $this->analyse([__DIR__ . '/data/typehints-iterable.php'], [ [ - 'Parameter $iterable of method TestMethodTypehints\IterableTypehints::doFoo() has invalid type TestMethodTypehints\NonexistentClass.', + 'Parameter $iterable of method TestMethodTypehints\IterableTypehints::doFoo() has invalid type TestMethodTypehints\AnotherNonexistentClass.', 11, ], [ - 'Parameter $iterable of method TestMethodTypehints\IterableTypehints::doFoo() has invalid type TestMethodTypehints\AnotherNonexistentClass.', + 'Parameter $iterable of method TestMethodTypehints\IterableTypehints::doFoo() has invalid type TestMethodTypehints\NonexistentClass.', 11, ], ]); @@ -290,11 +290,11 @@ public function dataRequiredParameterAfterOptional(): array 41, ], [ - 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 49, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.1: Required parameter $qux follows optional parameter $baz.', 49, ], ], @@ -339,7 +339,7 @@ public function dataRequiredParameterAfterOptional(): array 45, ], [ - 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', + 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', 49, ], [ @@ -347,7 +347,7 @@ public function dataRequiredParameterAfterOptional(): array 49, ], [ - 'Deprecated in PHP 8.0: Required parameter $quuz follows optional parameter $quux.', + 'Deprecated in PHP 8.3: Required parameter $bar follows optional parameter $foo.', 49, ], ], @@ -387,19 +387,19 @@ public function dataIntersectionTypes(): array 80100, [ [ - 'Parameter $a of method MethodIntersectionTypes\FooClass::doBar() has unresolvable native type.', + 'Method MethodIntersectionTypes\FooClass::doBar() has unresolvable native return type.', 33, ], [ - 'Method MethodIntersectionTypes\FooClass::doBar() has unresolvable native return type.', + 'Parameter $a of method MethodIntersectionTypes\FooClass::doBar() has unresolvable native type.', 33, ], [ - 'Parameter $a of method MethodIntersectionTypes\FooClass::doBaz() has unresolvable native type.', + 'Method MethodIntersectionTypes\FooClass::doBaz() has unresolvable native return type.', 38, ], [ - 'Method MethodIntersectionTypes\FooClass::doBaz() has unresolvable native return type.', + 'Parameter $a of method MethodIntersectionTypes\FooClass::doBaz() has unresolvable native type.', 38, ], ], @@ -532,15 +532,15 @@ public function testParamOutClasses(): void { $this->analyse([__DIR__ . '/data/param-out-classes.php'], [ [ - 'Parameter $p of method ParamOutClassesMethods\Bar::doFoo() has invalid type ParamOutClassesMethods\Nonexistent.', + 'Class ParamOutClassesMethods\Foo referenced with incorrect case: ParamOutClassesMethods\fOO.', 23, ], [ - 'Parameter $q of method ParamOutClassesMethods\Bar::doFoo() has invalid type ParamOutClassesMethods\FooTrait.', + 'Parameter $p of method ParamOutClassesMethods\Bar::doFoo() has invalid type ParamOutClassesMethods\Nonexistent.', 23, ], [ - 'Class ParamOutClassesMethods\Foo referenced with incorrect case: ParamOutClassesMethods\fOO.', + 'Parameter $q of method ParamOutClassesMethods\Bar::doFoo() has invalid type ParamOutClassesMethods\FooTrait.', 23, ], ]); diff --git a/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php b/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php index c63d2ea3eb..743e2336c7 100644 --- a/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php +++ b/tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php @@ -384,10 +384,6 @@ public function dataLessOverridenParametersWithVariadic(): array [ 70400, [ - [ - 'Parameter #1 $everything of method LessParametersVariadics\Bar::doFoo() is variadic but parameter #1 $many of method LessParametersVariadics\Foo::doFoo() is not variadic.', - 18, - ], [ 'Method LessParametersVariadics\Bar::doFoo() overrides method LessParametersVariadics\Foo::doFoo() but misses parameter #2 $parameters.', 18, @@ -397,8 +393,8 @@ public function dataLessOverridenParametersWithVariadic(): array 18, ], [ - 'Parameter #1 $everything of method LessParametersVariadics\Baz::doFoo() is variadic but parameter #1 $many of method LessParametersVariadics\Foo::doFoo() is not variadic.', - 28, + 'Parameter #1 $everything of method LessParametersVariadics\Bar::doFoo() is variadic but parameter #1 $many of method LessParametersVariadics\Foo::doFoo() is not variadic.', + 18, ], [ 'Method LessParametersVariadics\Baz::doFoo() overrides method LessParametersVariadics\Foo::doFoo() but misses parameter #2 $parameters.', @@ -409,13 +405,17 @@ public function dataLessOverridenParametersWithVariadic(): array 28, ], [ - 'Parameter #2 $everything of method LessParametersVariadics\Lorem::doFoo() is variadic but parameter #2 $parameters of method LessParametersVariadics\Foo::doFoo() is not variadic.', - 38, + 'Parameter #1 $everything of method LessParametersVariadics\Baz::doFoo() is variadic but parameter #1 $many of method LessParametersVariadics\Foo::doFoo() is not variadic.', + 28, ], [ 'Method LessParametersVariadics\Lorem::doFoo() overrides method LessParametersVariadics\Foo::doFoo() but misses parameter #3 $here.', 38, ], + [ + 'Parameter #2 $everything of method LessParametersVariadics\Lorem::doFoo() is variadic but parameter #2 $parameters of method LessParametersVariadics\Foo::doFoo() is not variadic.', + 38, + ], ], ], [ diff --git a/tests/PHPStan/Rules/PhpDoc/IncompatiblePhpDocTypeRuleTest.php b/tests/PHPStan/Rules/PhpDoc/IncompatiblePhpDocTypeRuleTest.php index e2c76ab516..ebbbaaaaa4 100644 --- a/tests/PHPStan/Rules/PhpDoc/IncompatiblePhpDocTypeRuleTest.php +++ b/tests/PHPStan/Rules/PhpDoc/IncompatiblePhpDocTypeRuleTest.php @@ -48,15 +48,15 @@ public function testRule(): void { $this->analyse([__DIR__ . '/data/incompatible-types.php'], [ [ - 'PHPDoc tag @param references unknown parameter: $unknown', + 'PHPDoc tag @param for parameter $b with type array is incompatible with native type string.', 12, ], [ - 'PHPDoc tag @param for parameter $b with type array is incompatible with native type string.', + 'PHPDoc tag @param for parameter $d with type float|int is not subtype of native type int.', 12, ], [ - 'PHPDoc tag @param for parameter $d with type float|int is not subtype of native type int.', + 'PHPDoc tag @param references unknown parameter: $unknown', 12, ], [ @@ -107,7 +107,7 @@ public function testRule(): void 'Write @template U of DateTime to fix this.', ], [ - 'PHPDoc tag @param for parameter $foo contains generic type InvalidPhpDocDefinitions\Foo but class InvalidPhpDocDefinitions\Foo is not generic.', + 'Generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $lorem specifies 3 template types, but class InvalidPhpDocDefinitions\FooGeneric supports only 2: T, U', 185, ], [ @@ -115,19 +115,19 @@ public function testRule(): void 185, ], [ - 'Generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $lorem specifies 3 template types, but class InvalidPhpDocDefinitions\FooGeneric supports only 2: T, U', + 'PHPDoc tag @param for parameter $foo contains generic type InvalidPhpDocDefinitions\Foo but class InvalidPhpDocDefinitions\Foo is not generic.', 185, ], [ - 'Type Throwable in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $ipsum is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', + 'PHPDoc tag @return contains generic type InvalidPhpDocDefinitions\Foo but class InvalidPhpDocDefinitions\Foo is not generic.', 185, ], [ - 'Type stdClass in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $dolor is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', + 'Type Throwable in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $ipsum is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', 185, ], [ - 'PHPDoc tag @return contains generic type InvalidPhpDocDefinitions\Foo but class InvalidPhpDocDefinitions\Foo is not generic.', + 'Type stdClass in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $dolor is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', 185, ], [ @@ -147,11 +147,11 @@ public function testRule(): void 225, ], [ - 'Type mixed in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $t is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', + 'Type Throwable in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $v is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', 242, ], [ - 'Type Throwable in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $v is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', + 'Type mixed in generic type InvalidPhpDocDefinitions\FooGeneric in PHPDoc tag @param for parameter $t is not subtype of template type U of Exception of class InvalidPhpDocDefinitions\FooGeneric.', 242, ], [ diff --git a/tests/PHPStan/Rules/PhpDoc/MethodAssertRuleTest.php b/tests/PHPStan/Rules/PhpDoc/MethodAssertRuleTest.php index c038a01891..e270b1ab2c 100644 --- a/tests/PHPStan/Rules/PhpDoc/MethodAssertRuleTest.php +++ b/tests/PHPStan/Rules/PhpDoc/MethodAssertRuleTest.php @@ -78,19 +78,19 @@ public function testRule(): void 94, ], [ - 'PHPDoc tag @phpstan-assert for $a contains unknown class MethodAssert\Nonexistent.', + 'Assert references unknown $this->barProp.', 105, ], [ - 'PHPDoc tag @phpstan-assert for $b contains invalid type MethodAssert\FooTrait.', + 'Class MethodAssert\Foo referenced with incorrect case: MethodAssert\fOO.', 105, ], [ - 'Class MethodAssert\Foo referenced with incorrect case: MethodAssert\fOO.', + 'PHPDoc tag @phpstan-assert for $a contains unknown class MethodAssert\Nonexistent.', 105, ], [ - 'Assert references unknown $this->barProp.', + 'PHPDoc tag @phpstan-assert for $b contains invalid type MethodAssert\FooTrait.', 105, ], [ diff --git a/tests/PHPStan/Rules/PhpDoc/WrongVariableNameInVarTagRuleTest.php b/tests/PHPStan/Rules/PhpDoc/WrongVariableNameInVarTagRuleTest.php index ea87452e90..9b38627f2c 100644 --- a/tests/PHPStan/Rules/PhpDoc/WrongVariableNameInVarTagRuleTest.php +++ b/tests/PHPStan/Rules/PhpDoc/WrongVariableNameInVarTagRuleTest.php @@ -112,11 +112,11 @@ public function testRule(): void 235, ], [ - 'Variable $foo in PHPDoc tag @var does not exist.', + 'Variable $bar in PHPDoc tag @var does not exist.', 249, ], [ - 'Variable $bar in PHPDoc tag @var does not exist.', + 'Variable $foo in PHPDoc tag @var does not exist.', 249, ], [ @@ -355,11 +355,11 @@ public function dataReportWrongType(): iterable 137, ], [ - 'PHPDoc tag @var with type string is not subtype of type int.', + 'PHPDoc tag @var with type int is not subtype of type string.', 137, ], [ - 'PHPDoc tag @var with type int is not subtype of type string.', + 'PHPDoc tag @var with type string is not subtype of type int.', 137, ], [ @@ -458,11 +458,11 @@ public function dataReportWrongType(): iterable 137, ], [ - 'PHPDoc tag @var with type string is not subtype of type int.', + 'PHPDoc tag @var with type int is not subtype of type string.', 137, ], [ - 'PHPDoc tag @var with type int is not subtype of type string.', + 'PHPDoc tag @var with type string is not subtype of type int.', 137, ], [ diff --git a/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php b/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php index 88834051bb..734fac3ee0 100644 --- a/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php +++ b/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php @@ -187,11 +187,11 @@ public function testAccessStaticProperties(): void 113, ], [ - 'Class FooAccessStaticProperties referenced with incorrect case: FOOAccessStaticPropertieS.', + 'Access to an undefined static property FooAccessStaticProperties::$unknownProperties.', 119, ], [ - 'Access to an undefined static property FooAccessStaticProperties::$unknownProperties.', + 'Class FooAccessStaticProperties referenced with incorrect case: FOOAccessStaticPropertieS.', 119, ], [ @@ -203,11 +203,11 @@ public function testAccessStaticProperties(): void 120, ], [ - 'Class FooAccessStaticProperties referenced with incorrect case: FOOAccessStaticPropertieS.', + 'Access to protected property $foo of class FooAccessStaticProperties.', 121, ], [ - 'Access to protected property $foo of class FooAccessStaticProperties.', + 'Class FooAccessStaticProperties referenced with incorrect case: FOOAccessStaticPropertieS.', 121, ], [ diff --git a/tests/PHPStan/Rules/Properties/ExistingClassesInPropertiesRuleTest.php b/tests/PHPStan/Rules/Properties/ExistingClassesInPropertiesRuleTest.php index cfe6972341..33acc33979 100644 --- a/tests/PHPStan/Rules/Properties/ExistingClassesInPropertiesRuleTest.php +++ b/tests/PHPStan/Rules/Properties/ExistingClassesInPropertiesRuleTest.php @@ -54,19 +54,18 @@ public function testNonexistentClass(): void 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Property PropertiesTypes\Foo::$dolors has unknown class PropertiesTypes\Ipsum as its type.', + 'Property PropertiesTypes\Foo::$dolors has unknown class PropertiesTypes\Dolor as its type.', 21, 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Property PropertiesTypes\Foo::$dolors has unknown class PropertiesTypes\Dolor as its type.', + 'Property PropertiesTypes\Foo::$dolors has unknown class PropertiesTypes\Ipsum as its type.', 21, 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Property PropertiesTypes\Foo::$fooWithWrongCase has unknown class PropertiesTypes\Fooo as its type.', + 'Class PropertiesTypes\Foo referenced with incorrect case: PropertiesTypes\FOO.', 24, - 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ 'Property PropertiesTypes\Foo::$fooWithWrongCase has unknown class PropertiesTypes\BAR as its type.', @@ -74,8 +73,9 @@ public function testNonexistentClass(): void 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Class PropertiesTypes\Foo referenced with incorrect case: PropertiesTypes\FOO.', + 'Property PropertiesTypes\Foo::$fooWithWrongCase has unknown class PropertiesTypes\Fooo as its type.', 24, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ 'Property PropertiesTypes\Foo::$withTrait has invalid type PropertiesTypes\SomeTrait.', @@ -86,12 +86,12 @@ public function testNonexistentClass(): void 30, ], [ - 'Property PropertiesTypes\Foo::$nonexistentClassInGenericObjectType has unknown class PropertiesTypes\Foooo as its type.', + 'Property PropertiesTypes\Foo::$nonexistentClassInGenericObjectType has unknown class PropertiesTypes\Barrrr as its type.', 33, 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], [ - 'Property PropertiesTypes\Foo::$nonexistentClassInGenericObjectType has unknown class PropertiesTypes\Barrrr as its type.', + 'Property PropertiesTypes\Foo::$nonexistentClassInGenericObjectType has unknown class PropertiesTypes\Foooo as its type.', 33, 'Learn more at https://phpstan.org/user-guide/discovering-symbols', ], diff --git a/tests/PHPStan/Rules/Pure/PureMethodRuleTest.php b/tests/PHPStan/Rules/Pure/PureMethodRuleTest.php index 19d1eed263..8accdbc9a7 100644 --- a/tests/PHPStan/Rules/Pure/PureMethodRuleTest.php +++ b/tests/PHPStan/Rules/Pure/PureMethodRuleTest.php @@ -160,11 +160,11 @@ public function testPureConstructor(): void $this->treatPhpDocTypesAsCertain = true; $this->analyse([__DIR__ . '/data/pure-constructor.php'], [ [ - 'Impure static property access in pure method PureConstructor\Foo::__construct().', + 'Impure property assignment in pure method PureConstructor\Foo::__construct().', 19, ], [ - 'Impure property assignment in pure method PureConstructor\Foo::__construct().', + 'Impure static property access in pure method PureConstructor\Foo::__construct().', 19, ], [ diff --git a/tests/PHPStan/Rules/Regexp/RegularExpressionPatternRuleTest.php b/tests/PHPStan/Rules/Regexp/RegularExpressionPatternRuleTest.php index 99f777b2ff..3c155ffd7a 100644 --- a/tests/PHPStan/Rules/Regexp/RegularExpressionPatternRuleTest.php +++ b/tests/PHPStan/Rules/Regexp/RegularExpressionPatternRuleTest.php @@ -75,11 +75,11 @@ public function testValidRegexPattern(): void 27, ], [ - sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), + 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', 29, ], [ - 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', + sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), 29, ], [ @@ -91,11 +91,11 @@ public function testValidRegexPattern(): void 33, ], [ - sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), + 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', 35, ], [ - 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', + sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), 35, ], [ @@ -107,19 +107,19 @@ public function testValidRegexPattern(): void 39, ], [ - sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), + 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', 41, ], [ - 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', + sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), 41, ], [ - sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), + 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', 43, ], [ - 'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~', + sprintf('Regex pattern is invalid: Delimiter must not be %s in pattern: nok', $messagePart), 43, ], [ diff --git a/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php b/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php index 71ad7280c8..7bae940640 100644 --- a/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php +++ b/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php @@ -115,19 +115,19 @@ public function testDefinedVariables(): void 156, ], [ - 'Undefined variable: $variableInIsset', + 'Undefined variable: $anotherVariableInIsset', 159, ], [ - 'Undefined variable: $anotherVariableInIsset', + 'Undefined variable: $variableInIsset', 159, ], [ - 'Undefined variable: $variableInIsset', + 'Undefined variable: $anotherVariableInIsset', 161, ], [ - 'Undefined variable: $anotherVariableInIsset', + 'Undefined variable: $variableInIsset', 161, ], [ @@ -227,11 +227,11 @@ public function testDefinedVariables(): void 384, ], [ - 'Variable $undefinedArrayIndex might not be defined.', + 'Variable $anotherUndefinedArrayIndex might not be defined.', 409, ], [ - 'Variable $anotherUndefinedArrayIndex might not be defined.', + 'Variable $undefinedArrayIndex might not be defined.', 409, ], [