-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathInheritanceOfDeprecatedClassRuleTest.php
More file actions
62 lines (55 loc) · 1.73 KB
/
InheritanceOfDeprecatedClassRuleTest.php
File metadata and controls
62 lines (55 loc) · 1.73 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
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Deprecations;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
/**
* @extends RuleTestCase<InheritanceOfDeprecatedClassRule>
*/
class InheritanceOfDeprecatedClassRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new InheritanceOfDeprecatedClassRule(
$this->createReflectionProvider(),
new DeprecatedScopeHelper([new DefaultDeprecatedScopeResolver()]),
);
}
public function testInheritanceOfDeprecatedClassInClasses(): void
{
require_once __DIR__ . '/data/inheritance-of-deprecated-class-definition.php';
$this->analyse(
[__DIR__ . '/data/inheritance-of-deprecated-class-in-classes.php'],
[
[
'Class InheritanceOfDeprecatedClass\Bar2 extends deprecated class InheritanceOfDeprecatedClass\DeprecatedFoo.',
10,
],
[
"Class InheritanceOfDeprecatedClass\Bar3 extends deprecated class InheritanceOfDeprecatedClass\DeprecatedWithDescription:\nInheritance is deprecated.",
15,
],
[
"Class InheritanceOfDeprecatedClass\Bar4 extends deprecated class InheritanceOfDeprecatedClass\DeprecatedWithDescription:\nInheritance is deprecated.",
21,
],
],
);
}
public function testInheritanceOfDeprecatedClassInAnonymousClasses(): void
{
require_once __DIR__ . '/data/inheritance-of-deprecated-class-definition.php';
$this->analyse(
[__DIR__ . '/data/inheritance-of-deprecated-class-in-anonymous-classes.php'],
[
[
'Anonymous class extends deprecated class InheritanceOfDeprecatedClass\DeprecatedFoo.',
9,
],
[
"Anonymous class extends deprecated class InheritanceOfDeprecatedClass\DeprecatedWithDescription:\nInheritance is deprecated.",
13,
],
],
);
}
}