Skip to content

Commit

Permalink
Fix numeric-string negated intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffycondor committed Aug 30, 2022
1 parent 41be802 commit 493284c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/Type/Php/IsNumericFunctionTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n
$numericTypes = [
new IntegerType(),
new FloatType(),
];

if ($context->truthy()) {
$numericTypes[] = new IntersectionType([
new IntersectionType([
new StringType(),
new AccessoryNumericStringType(),
]);
}
]),
];

return $this->typeSpecifier->create($node->getArgs()[0]->value, new UnionType($numericTypes), $context, false, $scope);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/TypeSpecifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function dataCondition(): array
[
$this->createFunctionCall('is_numeric'),
['$foo' => 'float|int|numeric-string'],
['$foo' => '~float|int'],
['$foo' => '~float|int|numeric-string'],
],
[
$this->createFunctionCall('is_scalar'),
Expand Down

0 comments on commit 493284c

Please sign in to comment.