forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugScopeRuleTest.php
More file actions
75 lines (68 loc) · 1.5 KB
/
DebugScopeRuleTest.php
File metadata and controls
75 lines (68 loc) · 1.5 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
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Debug;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use function implode;
/**
* @extends RuleTestCase<DebugScopeRule>
*/
class DebugScopeRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new DebugScopeRule(self::createReflectionProvider());
}
public function testRuleInPhpStanNamespace(): void
{
$this->analyse([__DIR__ . '/data/debug-scope.php'], [
[
'Scope is empty',
7,
],
[
implode("\n", [
'$a (Yes): int',
'$b (Yes): int',
'$debug (Yes): bool',
'$this (Yes): object',
'native $a (Yes): int',
'native $b (Yes): int',
'native $debug (Yes): bool',
'native $this (Yes): object',
]),
10,
],
[
implode("\n", [
'$a (Yes): int',
'$b (Yes): int',
'$debug (Yes): bool',
'$this (Yes): object',
'$c (Maybe): 1',
'native $a (Yes): int',
'native $b (Yes): int',
'native $debug (Yes): bool',
'native $this (Yes): object',
'native $c (Maybe): 1',
'condition about $c #1: if $debug=false then $c is *ERROR* (No)',
'condition about $c #2: if $debug=true then $c is 1 (Yes)',
]),
16,
],
]);
}
public function testPr4663(): void
{
$this->analyse([__DIR__ . '/data/pr-4663.php'], [
[
implode("\n", [
'$this (Yes): object',
"\$result (Yes): 'no matches!'",
'native $this (Yes): object',
"native \$result (Yes): 'no matches!'",
]),
11,
],
]);
}
}