forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNullsafePropertyFetchRuleTest.php
More file actions
84 lines (70 loc) · 1.84 KB
/
NullsafePropertyFetchRuleTest.php
File metadata and controls
84 lines (70 loc) · 1.84 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
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Properties;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;
/**
* @extends RuleTestCase<NullsafePropertyFetchRule>
*/
class NullsafePropertyFetchRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new NullsafePropertyFetchRule();
}
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/nullsafe-property-fetch-rule.php'], [
[
'Using nullsafe property access on non-nullable type Exception. Use -> instead.',
16,
],
]);
}
public function testBug6020(): void
{
$this->analyse([__DIR__ . '/data/bug-6020.php'], []);
}
#[RequiresPhp('>= 8.0')]
public function testBug7109(): void
{
$this->analyse([__DIR__ . '/data/bug-7109.php'], []);
}
#[RequiresPhp('>= 8.0')]
public function testBug5172(): void
{
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-5172.php'], []);
}
#[RequiresPhp('>= 8.1')]
public function testBug7980(): void
{
$this->analyse([__DIR__ . '/../../Analyser/data/bug-7980.php'], []);
}
public function testBug8517(): void
{
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-8517.php'], []);
}
public function testBug14150(): void
{
$this->analyse([__DIR__ . '/data/bug-14150-nullsafe.php'], [
[
'Using nullsafe property access on non-nullable type $this(Bug14150NullsafeProperty\HelloWorld). Use -> instead.',
20,
],
[
'Using nullsafe property access on non-nullable type $this(Bug14150NullsafeProperty\HelloWorld). Use -> instead.',
27,
],
]);
}
#[RequiresPhp('>= 8.0')]
public function testBug9105(): void
{
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-9105.php'], []);
}
#[RequiresPhp('>= 8.1')]
public function testBug6922(): void
{
$this->analyse([__DIR__ . '/data/bug-6922.php'], []);
}
}