-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathFetchingDeprecatedConstRuleTest.php
More file actions
97 lines (85 loc) · 2.07 KB
/
FetchingDeprecatedConstRuleTest.php
File metadata and controls
97 lines (85 loc) · 2.07 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
89
90
91
92
93
94
95
96
97
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Deprecations;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use function defined;
use const PHP_VERSION_ID;
/**
* @extends RuleTestCase<FetchingDeprecatedConstRule>
*/
class FetchingDeprecatedConstRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new FetchingDeprecatedConstRule(
$this->createReflectionProvider(),
new DeprecatedScopeHelper([new DefaultDeprecatedScopeResolver()]),
);
}
public function testFetchingDeprecatedConst(): void
{
if (!defined('FILTER_FLAG_SCHEME_REQUIRED') || !defined('FILTER_FLAG_HOST_REQUIRED')) {
$this->markTestSkipped('Required constants are not available, PHP≥8?');
}
$expectedErrors = [];
$expectedErrors[] = [
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.',
5,
];
$expectedErrors[] = [
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.',
6,
];
$expectedErrors[] = [
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.',
7,
];
$expectedErrors[] = [
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.',
8,
];
$expectedErrors[] = [
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.',
37,
];
$expectedErrors[] = [
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.',
38,
];
require_once __DIR__ . '/data/fetching-deprecated-const-definition.php';
$this->analyse(
[__DIR__ . '/data/fetching-deprecated-const.php'],
$expectedErrors,
);
}
public function testEstrictWithVersionGuard(): void
{
$errors = [];
if (PHP_VERSION_ID >= 80400) {
$errors = [
[
'Use of constant E_STRICT is deprecated.',
7,
],
[
'Use of constant E_STRICT is deprecated.',
18,
],
];
}
require_once __DIR__ . '/data/bug-162.php';
$this->analyse(
[__DIR__ . '/data/bug-162.php'],
$errors,
);
}
public function testEstrictWithVersionCompareGuard(): void
{
$errors = [];
require_once __DIR__ . '/data/bug-162b.php';
$this->analyse(
[__DIR__ . '/data/bug-162b.php'],
$errors,
);
}
}