Skip to content

Commit 94b3785

Browse files
phpstan-botclaude
andcommitted
Replace raw version check with PhpVersion::hasFilterThrowOnFailureConstant()
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fa75094 commit 94b3785

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/Php/PhpVersion.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,9 @@ public function supportsObjectsInArraySumProduct(): bool
501501
return $this->versionId >= 80300;
502502
}
503503

504+
public function hasFilterThrowOnFailureConstant(): bool
505+
{
506+
return $this->versionId >= 80500;
507+
}
508+
504509
}

src/Rules/Functions/FilterVarRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function processNode(Node $node, Scope $scope): array
4646

4747
$args = $node->getArgs();
4848

49-
if ($this->phpVersion->getVersionId() >= 80500 && $this->reflectionProvider->hasConstant(new Name\FullyQualified('FILTER_THROW_ON_FAILURE'), null)) {
49+
if ($this->phpVersion->hasFilterThrowOnFailureConstant() && $this->reflectionProvider->hasConstant(new Name\FullyQualified('FILTER_THROW_ON_FAILURE'), null)) {
5050
if (count($args) < 3) {
5151
return [];
5252
}

src/Type/Php/FilterFunctionReturnTypeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function getType(Type $inputType, ?Type $filterType, ?Type $flagsType): T
151151

152152
$inputIsArray = $inputType->isArray();
153153
$hasRequireArrayFlag = $this->hasFlag('FILTER_REQUIRE_ARRAY', $flagsType);
154-
$hasThrowOnFailureFlag = $this->phpVersion->getVersionId() >= 80500
154+
$hasThrowOnFailureFlag = $this->phpVersion->hasFilterThrowOnFailureConstant()
155155
? $this->hasFlag('FILTER_THROW_ON_FAILURE', $flagsType)
156156
: TrinaryLogic::createNo();
157157
if ($inputIsArray->no() && $hasRequireArrayFlag->yes()) {

src/Type/Php/FilterVarThrowTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function isFunctionSupported(
3131
): bool
3232
{
3333
return $functionReflection->getName() === 'filter_var'
34-
&& $this->phpVersion->getVersionId() >= 80500
34+
&& $this->phpVersion->hasFilterThrowOnFailureConstant()
3535
&& $this->reflectionProvider->hasConstant(new Name\FullyQualified('FILTER_THROW_ON_FAILURE'), null);
3636
}
3737

0 commit comments

Comments
 (0)