Skip to content

Commit 8342041

Browse files
committed
Merge remote-tracking branch 'origin/1.1.x' into 1.2.x
2 parents e9ea332 + d457b73 commit 8342041

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

src/Rules/Deprecations/FetchingDeprecatedConstRule.php

-19
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use PHPStan\Rules\Rule;
1010
use PHPStan\Rules\RuleErrorBuilder;
1111
use function sprintf;
12-
use const PHP_VERSION_ID;
1312

1413
/**
1514
* @implements Rule<ConstFetch>
@@ -23,19 +22,10 @@ class FetchingDeprecatedConstRule implements Rule
2322
/** @var DeprecatedScopeHelper */
2423
private $deprecatedScopeHelper;
2524

26-
/** @var array<string,string> */
27-
private $deprecatedConstants = [];
28-
2925
public function __construct(ReflectionProvider $reflectionProvider, DeprecatedScopeHelper $deprecatedScopeHelper)
3026
{
3127
$this->reflectionProvider = $reflectionProvider;
3228
$this->deprecatedScopeHelper = $deprecatedScopeHelper;
33-
34-
// phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed
35-
if (PHP_VERSION_ID >= 70300) {
36-
$this->deprecatedConstants['FILTER_FLAG_SCHEME_REQUIRED'] = 'Use of constant %s is deprecated since PHP 7.3.';
37-
$this->deprecatedConstants['FILTER_FLAG_HOST_REQUIRED'] = 'Use of constant %s is deprecated since PHP 7.3.';
38-
}
3929
}
4030

4131
public function getNodeType(): string
@@ -64,15 +54,6 @@ public function processNode(Node $node, Scope $scope): array
6454
];
6555
}
6656

67-
if (isset($this->deprecatedConstants[$constantReflection->getName()])) {
68-
return [
69-
RuleErrorBuilder::message(sprintf(
70-
$this->deprecatedConstants[$constantReflection->getName()],
71-
$constantReflection->getName()
72-
))->identifier('constant.deprecated')->build(),
73-
];
74-
}
75-
7657
return [];
7758
}
7859

tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ public function testFetchingDeprecatedConst(): void
3131

3232
if (PHP_VERSION_ID >= 70300) {
3333
$expectedErrors[] = [
34-
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated since PHP 7.3.',
34+
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.',
3535
5,
3636
];
3737
$expectedErrors[] = [
38-
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated since PHP 7.3.',
38+
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.',
3939
6,
4040
];
4141
$expectedErrors[] = [
42-
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated since PHP 7.3.',
42+
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.',
4343
7,
4444
];
4545
$expectedErrors[] = [
46-
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated since PHP 7.3.',
46+
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.',
4747
8,
4848
];
4949
$expectedErrors[] = [
50-
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated since PHP 7.3.',
50+
'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.',
5151
37,
5252
];
5353
$expectedErrors[] = [
54-
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated since PHP 7.3.',
54+
'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.',
5555
38,
5656
];
5757
}

0 commit comments

Comments
 (0)