Skip to content

Commit db3bfb7

Browse files
committed
RuleTestCase: Order errors
1 parent 375f68e commit db3bfb7

File tree

49 files changed

+371
-371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+371
-371
lines changed

src/Testing/RuleTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private function gatherAnalyserErrorsWithDelayedErrors(array $files): array
241241
);
242242

243243
return [
244-
$finalizer->finalize($analyserResult, false, true)->getAnalyserResult()->getUnorderedErrors(),
244+
$finalizer->finalize($analyserResult, false, true)->getAnalyserResult()->getErrors(),
245245
array_merge($classRule->getDelayedErrors(), $traitRule->getDelayedErrors()),
246246
];
247247
}

tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ public function testBug6315(): void
8181
20,
8282
],
8383
[
84-
'Invalid array key type Bug6315\FooEnum::B.',
84+
'Invalid array key type Bug6315\FooEnum::A.',
8585
21,
8686
],
8787
[
88-
'Invalid array key type Bug6315\FooEnum::A.',
88+
'Invalid array key type Bug6315\FooEnum::B.',
8989
21,
9090
],
9191
[

tests/PHPStan/Rules/Classes/ClassConstantRuleTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ public function testClassConstant(): void
7777
26,
7878
],
7979
[
80-
'Class ClassConstantNamespace\Foo referenced with incorrect case: ClassConstantNamespace\FOO.',
80+
'Access to undefined constant ClassConstantNamespace\Foo::DOLOR.',
8181
27,
8282
],
8383
[
84-
'Access to undefined constant ClassConstantNamespace\Foo::DOLOR.',
84+
'Class ClassConstantNamespace\Foo referenced with incorrect case: ClassConstantNamespace\FOO.',
8585
27,
8686
],
8787
[
@@ -155,11 +155,11 @@ public function testClassConstantVisibility(): void
155155
129,
156156
],
157157
[
158-
'Class ClassConstantVisibility\Foo referenced with incorrect case: ClassConstantVisibility\FOO.',
158+
'Access to private constant PRIVATE_FOO of class ClassConstantVisibility\Foo.',
159159
135,
160160
],
161161
[
162-
'Access to private constant PRIVATE_FOO of class ClassConstantVisibility\Foo.',
162+
'Class ClassConstantVisibility\Foo referenced with incorrect case: ClassConstantVisibility\FOO.',
163163
135,
164164
],
165165
]);
@@ -445,11 +445,11 @@ public function testDynamicAccess(): void
445445

446446
$this->analyse([__DIR__ . '/data/dynamic-constant-access.php'], [
447447
[
448-
'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.',
448+
'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.',
449449
20,
450450
],
451451
[
452-
'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.',
452+
'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.',
453453
20,
454454
],
455455
[
@@ -465,15 +465,15 @@ public function testDynamicAccess(): void
465465
41,
466466
],
467467
[
468-
'Access to undefined constant ClassConstantDynamicAccess\Foo::QUX.',
468+
'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.',
469469
44,
470470
],
471471
[
472-
'Access to undefined constant ClassConstantDynamicAccess\Foo::BUZ.',
472+
'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.',
473473
44,
474474
],
475475
[
476-
'Access to undefined constant ClassConstantDynamicAccess\Foo::FOO.',
476+
'Access to undefined constant ClassConstantDynamicAccess\Foo::QUX.',
477477
44,
478478
],
479479
]);

tests/PHPStan/Rules/Classes/ExistingClassesInEnumImplementsRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ public function testRule(): void
5858
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
5959
],
6060
[
61-
'Enum EnumImplements\FooEnum referenced with incorrect case: EnumImplements\FOOEnum.',
61+
'Enum EnumImplements\Foo7 implements enum EnumImplements\FooEnum.',
6262
55,
6363
],
6464
[
65-
'Enum EnumImplements\Foo7 implements enum EnumImplements\FooEnum.',
65+
'Enum EnumImplements\FooEnum referenced with incorrect case: EnumImplements\FOOEnum.',
6666
55,
6767
],
6868
]);

tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ public function testInstanceof(): void
111111
228,
112112
],
113113
[
114-
'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Foo will always evaluate to true.',
114+
'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Bar will always evaluate to true.',
115115
232,
116116
$tipText,
117117
],
118118
[
119-
'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Bar will always evaluate to true.',
119+
'Instanceof between ImpossibleInstanceOf\Bar&ImpossibleInstanceOf\Foo and ImpossibleInstanceOf\Foo will always evaluate to true.',
120120
232,
121121
$tipText,
122122
],

tests/PHPStan/Rules/Classes/InstantiationRuleTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ public function testInstantiation(): void
9494
57,
9595
],
9696
[
97-
'Class TestInstantiation\FooInstantiation referenced with incorrect case: TestInstantiation\FOOInstantiation.',
97+
'Class TestInstantiation\FooInstantiation does not have a constructor and must be instantiated without any parameters.',
9898
64,
9999
],
100100
[
101-
'Class TestInstantiation\FooInstantiation does not have a constructor and must be instantiated without any parameters.',
101+
'Class TestInstantiation\FooInstantiation referenced with incorrect case: TestInstantiation\FOOInstantiation.',
102102
64,
103103
],
104104
[
105-
'Class TestInstantiation\BarInstantiation referenced with incorrect case: TestInstantiation\BARInstantiation.',
105+
'Class TestInstantiation\BarInstantiation constructor invoked with 0 parameters, 1 required.',
106106
65,
107107
],
108108
[
109-
'Class TestInstantiation\BarInstantiation constructor invoked with 0 parameters, 1 required.',
109+
'Class TestInstantiation\BarInstantiation referenced with incorrect case: TestInstantiation\BARInstantiation.',
110110
65,
111111
],
112112
[
@@ -408,22 +408,22 @@ public function testBug7048(): void
408408
}
409409

410410
$this->analyse([__DIR__ . '/data/bug-7048.php'], [
411-
[
412-
'Unknown parameter $recurrences in call to DatePeriod constructor.',
413-
21,
414-
],
415411
[
416412
'Missing parameter $end (DateTimeInterface|int) in call to DatePeriod constructor.',
417413
18,
418414
],
419415
[
420-
'Unknown parameter $isostr in call to DatePeriod constructor.',
421-
25,
416+
'Unknown parameter $recurrences in call to DatePeriod constructor.',
417+
21,
422418
],
423419
[
424420
'Missing parameter $start (string) in call to DatePeriod constructor.',
425421
24,
426422
],
423+
[
424+
'Unknown parameter $isostr in call to DatePeriod constructor.',
425+
25,
426+
],
427427
[
428428
'Parameter #3 $end of class DatePeriod constructor expects DateTimeInterface|int, string given.',
429429
41,

tests/PHPStan/Rules/Classes/LocalTypeAliasesRuleTest.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@ public function testRule(): void
4646
{
4747
$this->analyse([__DIR__ . '/data/local-type-aliases.php'], [
4848
[
49-
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Bar.',
49+
'Circular definition detected in type alias CircularTypeAlias1.',
5050
23,
5151
],
5252
[
53-
'Type alias GlobalTypeAlias already exists as a global type alias.',
53+
'Circular definition detected in type alias CircularTypeAlias2.',
5454
23,
5555
],
5656
[
57-
'Type alias has an invalid name: int.',
57+
'Circular definition detected in type alias RecursiveTypeAlias.',
5858
23,
5959
],
6060
[
61-
'Circular definition detected in type alias RecursiveTypeAlias.',
61+
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Bar.',
6262
23,
6363
],
6464
[
65-
'Circular definition detected in type alias CircularTypeAlias1.',
65+
'Type alias GlobalTypeAlias already exists as a global type alias.',
6666
23,
6767
],
6868
[
69-
'Circular definition detected in type alias CircularTypeAlias2.',
69+
'Type alias has an invalid name: int.',
7070
23,
7171
],
7272
[
@@ -82,23 +82,23 @@ public function testRule(): void
8282
39,
8383
],
8484
[
85-
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Baz.',
85+
'Circular definition detected in type alias CircularTypeAliasImport2.',
8686
39,
8787
],
8888
[
89-
'Type alias GlobalTypeAlias already exists as a global type alias.',
89+
'Imported type alias ExportedTypeAlias has an invalid name: int.',
9090
39,
9191
],
9292
[
93-
'Imported type alias ExportedTypeAlias has an invalid name: int.',
93+
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeAliases\Baz.',
9494
39,
9595
],
9696
[
97-
'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.',
97+
'Type alias GlobalTypeAlias already exists as a global type alias.',
9898
39,
9999
],
100100
[
101-
'Circular definition detected in type alias CircularTypeAliasImport2.',
101+
'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.',
102102
39,
103103
],
104104
[
@@ -110,29 +110,29 @@ public function testRule(): void
110110
62,
111111
],
112112
[
113-
'Class LocalTypeAliases\MissingTypehints has type alias NoIterableValue with no value type specified in iterable type array.',
113+
'Class LocalTypeAliases\MissingTypehints has type alias NoCallable with no signature specified for callable.',
114114
77,
115-
'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type',
116115
],
117116
[
118117
'Class LocalTypeAliases\MissingTypehints has type alias NoGenerics with generic class LocalTypeAliases\Generic but does not specify its types: T',
119118
77,
120119
],
121120
[
122-
'Class LocalTypeAliases\MissingTypehints has type alias NoCallable with no signature specified for callable.',
121+
'Class LocalTypeAliases\MissingTypehints has type alias NoIterableValue with no value type specified in iterable type array.',
123122
77,
123+
'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type',
124124
],
125125
[
126-
'Type alias A contains unknown class LocalTypeAliases\Nonexistent.',
126+
'Class LocalTypeAliases\Foo referenced with incorrect case: LocalTypeAliases\fOO.',
127127
87,
128-
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
129128
],
130129
[
131-
'Type alias B contains invalid type LocalTypeTraitAliases\Foo.',
130+
'Type alias A contains unknown class LocalTypeAliases\Nonexistent.',
132131
87,
132+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
133133
],
134134
[
135-
'Class LocalTypeAliases\Foo referenced with incorrect case: LocalTypeAliases\fOO.',
135+
'Type alias B contains invalid type LocalTypeTraitAliases\Foo.',
136136
87,
137137
],
138138
[

tests/PHPStan/Rules/Classes/LocalTypeTraitAliasesRuleTest.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@ public function testRule(): void
4646
{
4747
$this->analyse([__DIR__ . '/data/local-type-trait-aliases.php'], [
4848
[
49-
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Bar.',
49+
'Circular definition detected in type alias CircularTypeAlias1.',
5050
23,
5151
],
5252
[
53-
'Type alias GlobalTypeAlias already exists as a global type alias.',
53+
'Circular definition detected in type alias CircularTypeAlias2.',
5454
23,
5555
],
5656
[
57-
'Type alias has an invalid name: int.',
57+
'Circular definition detected in type alias RecursiveTypeAlias.',
5858
23,
5959
],
6060
[
61-
'Circular definition detected in type alias RecursiveTypeAlias.',
61+
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Bar.',
6262
23,
6363
],
6464
[
65-
'Circular definition detected in type alias CircularTypeAlias1.',
65+
'Type alias GlobalTypeAlias already exists as a global type alias.',
6666
23,
6767
],
6868
[
69-
'Circular definition detected in type alias CircularTypeAlias2.',
69+
'Type alias has an invalid name: int.',
7070
23,
7171
],
7272
[
@@ -82,23 +82,23 @@ public function testRule(): void
8282
39,
8383
],
8484
[
85-
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Baz.',
85+
'Circular definition detected in type alias CircularTypeAliasImport2.',
8686
39,
8787
],
8888
[
89-
'Type alias GlobalTypeAlias already exists as a global type alias.',
89+
'Imported type alias ExportedTypeAlias has an invalid name: int.',
9090
39,
9191
],
9292
[
93-
'Imported type alias ExportedTypeAlias has an invalid name: int.',
93+
'Type alias ExistingClassAlias already exists as a class in scope of LocalTypeTraitAliases\Baz.',
9494
39,
9595
],
9696
[
97-
'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.',
97+
'Type alias GlobalTypeAlias already exists as a global type alias.',
9898
39,
9999
],
100100
[
101-
'Circular definition detected in type alias CircularTypeAliasImport2.',
101+
'Type alias OverwrittenTypeAlias overwrites an imported type alias of the same name.',
102102
39,
103103
],
104104
[

tests/PHPStan/Rules/Classes/MethodTagRuleTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function testRule(): void
4343
$fooClassLine = 12;
4444
$this->analyse([__DIR__ . '/data/method-tag.php'], [
4545
[
46-
'PHPDoc tag @method for method MethodTag\Foo::doFoo() return type contains unknown class MethodTag\intt.',
47-
$fooClassLine,
48-
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
46+
'Class MethodTag\Foo has PHPDoc tag @method for method doMissingIterablueValue() return type with no value type specified in iterable type array.',
47+
12,
48+
MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP,
4949
],
5050
[
5151
'PHPDoc tag @method for method MethodTag\Foo::doBar() parameter #1 $a contains unresolvable type.',
@@ -56,20 +56,20 @@ public function testRule(): void
5656
12,
5757
],
5858
[
59-
'Class MethodTag\Foo has PHPDoc tag @method for method doMissingIterablueValue() return type with no value type specified in iterable type array.',
60-
12,
61-
MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP,
59+
'PHPDoc tag @method for method MethodTag\Foo::doFoo() return type contains unknown class MethodTag\intt.',
60+
$fooClassLine,
61+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
6262
],
6363
[
64-
'PHPDoc tag @method for method MethodTag\TestGenerics::doA() return type contains generic type Exception<int> but class Exception is not generic.',
64+
'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',
6565
39,
6666
],
6767
[
6868
'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',
6969
39,
7070
],
7171
[
72-
'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',
72+
'PHPDoc tag @method for method MethodTag\TestGenerics::doA() return type contains generic type Exception<int> but class Exception is not generic.',
7373
39,
7474
],
7575
[
@@ -90,16 +90,16 @@ public function testRule(): void
9090
63,
9191
],
9292
[
93-
'PHPDoc tag @method for method MethodTag\NonexistentClasses::doA() return type contains unknown class MethodTag\Nonexistent.',
93+
'Class MethodTag\Foo referenced with incorrect case: MethodTag\fOO.',
9494
73,
95-
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
9695
],
9796
[
98-
'PHPDoc tag @method for method MethodTag\NonexistentClasses::doB() return type contains invalid type PropertyTagTrait\Foo.',
97+
'PHPDoc tag @method for method MethodTag\NonexistentClasses::doA() return type contains unknown class MethodTag\Nonexistent.',
9998
73,
99+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
100100
],
101101
[
102-
'Class MethodTag\Foo referenced with incorrect case: MethodTag\fOO.',
102+
'PHPDoc tag @method for method MethodTag\NonexistentClasses::doB() return type contains invalid type PropertyTagTrait\Foo.',
103103
73,
104104
],
105105
]);

0 commit comments

Comments
 (0)