forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDuplicateDeclarationRuleTest.php
More file actions
88 lines (80 loc) · 1.78 KB
/
DuplicateDeclarationRuleTest.php
File metadata and controls
88 lines (80 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Classes;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;
/**
* @extends RuleTestCase<DuplicateDeclarationRule>
*/
class DuplicateDeclarationRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new DuplicateDeclarationRule(new DuplicateDeclarationHelper());
}
public function testDuplicateDeclarations(): void
{
$this->analyse(
[
__DIR__ . '/data/duplicate-declarations.php',
],
[
[
'Cannot redeclare constant DuplicateDeclarations\Foo::CONST1.',
8,
],
[
'Cannot redeclare constant DuplicateDeclarations\Foo::CONST2.',
10,
],
[
'Cannot redeclare property DuplicateDeclarations\Foo::$prop1.',
17,
],
[
'Cannot redeclare property DuplicateDeclarations\Foo::$prop2.',
20,
],
[
'Cannot redeclare method DuplicateDeclarations\Foo::func1().',
27,
],
[
'Cannot redeclare method DuplicateDeclarations\Foo::Func1().',
35,
],
],
);
}
public function testDuplicatePromotedProperty(): void
{
$this->analyse([__DIR__ . '/data/duplicate-promoted-property.php'], [
[
'Cannot redeclare property DuplicatedPromotedProperty\Foo::$foo.',
11,
],
[
'Cannot redeclare property DuplicatedPromotedProperty\Foo::$bar.',
13,
],
]);
}
#[RequiresPhp('>= 8.1')]
public function testDuplicateEnumCase(): void
{
$this->analyse([__DIR__ . '/data/duplicate-enum-cases.php'], [
[
'Cannot redeclare enum case DuplicatedEnumCase\Foo::BAR.',
10,
],
[
'Cannot redeclare enum case DuplicatedEnumCase\Boo::BAR.',
17,
],
[
'Cannot redeclare constant DuplicatedEnumCase\Hoo::BAR.',
23,
],
]);
}
}