|
2 | 2 |
|
3 | 3 | namespace PHPStan\Rules\Methods;
|
4 | 4 |
|
5 |
| -use PHPStan\Php\PhpVersion; |
6 | 5 | use PHPStan\Rules\Rule;
|
7 | 6 | use PHPStan\Testing\RuleTestCase;
|
8 | 7 |
|
9 | 8 | /** @extends RuleTestCase<FinalPrivateMethodRule> */
|
10 | 9 | class FinalPrivateMethodRuleTest extends RuleTestCase
|
11 | 10 | {
|
12 | 11 |
|
13 |
| - private int $phpVersionId; |
14 |
| - |
15 | 12 | protected function getRule(): Rule
|
16 | 13 | {
|
17 |
| - return new FinalPrivateMethodRule( |
18 |
| - new PhpVersion($this->phpVersionId), |
19 |
| - ); |
| 14 | + return new FinalPrivateMethodRule(); |
20 | 15 | }
|
21 | 16 |
|
22 |
| - public function dataRule(): array |
| 17 | + public function testRule(): void |
23 | 18 | {
|
24 |
| - return [ |
| 19 | + $this->analyse([__DIR__ . '/data/final-private-method.php'], [ |
25 | 20 | [
|
26 |
| - 70400, |
27 |
| - [], |
| 21 | + 'Private method FinalPrivateMethod\Foo::foo() cannot be final as it is never overridden by other classes.', |
| 22 | + 8, |
28 | 23 | ],
|
29 | 24 | [
|
30 |
| - 80000, |
31 |
| - [ |
32 |
| - [ |
33 |
| - 'Private method FinalPrivateMethod\Foo::foo() cannot be final as it is never overridden by other classes.', |
34 |
| - 8, |
35 |
| - ], |
36 |
| - ], |
| 25 | + 'Private method FinalPrivateMethod\FooBarPhp8orHigher::foo() cannot be final as it is never overridden by other classes.', |
| 26 | + 39, |
37 | 27 | ],
|
38 |
| - ]; |
39 |
| - } |
40 |
| - |
41 |
| - /** |
42 |
| - * @dataProvider dataRule |
43 |
| - * @param list<array{0: string, 1: int, 2?: string}> $errors |
44 |
| - */ |
45 |
| - public function testRule(int $phpVersion, array $errors): void |
46 |
| - { |
47 |
| - $this->phpVersionId = $phpVersion; |
48 |
| - $this->analyse([__DIR__ . '/data/final-private-method.php'], $errors); |
| 28 | + [ |
| 29 | + 'Private method FinalPrivateMethod\FooBarPhp74OrHigher::foo() cannot be final as it is never overridden by other classes.', |
| 30 | + 59, |
| 31 | + ], |
| 32 | + ]); |
49 | 33 | }
|
50 | 34 |
|
51 | 35 | }
|
0 commit comments