Skip to content

RuleTestCase: Order errors #3931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Testing/RuleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
[
Expand Down
18 changes: 9 additions & 9 deletions tests/PHPStan/Rules/Classes/ClassConstantRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
[
Expand Down Expand Up @@ -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,
],
]);
Expand Down Expand Up @@ -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,
],
[
Expand All @@ -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,
],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
Expand Down
20 changes: 10 additions & 10 deletions tests/PHPStan/Rules/Classes/InstantiationRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
[
Expand Down Expand Up @@ -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,
Expand Down
36 changes: 18 additions & 18 deletions tests/PHPStan/Rules/Classes/LocalTypeAliasesRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
[
Expand All @@ -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,
],
[
Expand All @@ -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,
],
[
Expand Down
22 changes: 11 additions & 11 deletions tests/PHPStan/Rules/Classes/LocalTypeTraitAliasesRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
[
Expand All @@ -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,
],
[
Expand Down
24 changes: 12 additions & 12 deletions tests/PHPStan/Rules/Classes/MethodTagRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand All @@ -56,20 +56,20 @@ 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<int> but class Exception is not generic.',
'Generic type MethodTag\Generic<int, string, float> 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,
],
[
'Generic type MethodTag\Generic<int> in PHPDoc tag @method for method MethodTag\TestGenerics::doB() return type does not specify all template types of class MethodTag\Generic: T, U',
39,
],
[
'Generic type MethodTag\Generic<int, string, float> 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<int> but class Exception is not generic.',
39,
],
[
Expand All @@ -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,
],
]);
Expand Down
Loading
Loading