Skip to content

Commit

Permalink
better handling of having arguments provided
Browse files Browse the repository at this point in the history
  • Loading branch information
verfriemelt-dot-org committed Dec 15, 2022
1 parent 93e479e commit e0aa795
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Type/Php/DateIntervalDynamicReturnTypeExtension.php
Expand Up @@ -31,7 +31,13 @@ public function isStaticMethodSupported(MethodReflection $methodReflection): boo

public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): ?Type
{
$strings = $scope->getType($methodCall->getArgs()[0]->value)->getConstantStrings();
$arguments = $methodCall->getArgs();

if (!isset($arguments[0])) {
return null;
}

$strings = $scope->getType($arguments[0]->value)->getConstantStrings();

$possibleReturnTypes = array_map(
static fn (ConstantStringType $s): string => gettype(@DateInterval::createFromDateString($s->getValue())),
Expand Down
2 changes: 2 additions & 0 deletions tests/PHPStan/Analyser/data/bug-8442.php
Expand Up @@ -32,5 +32,7 @@ function () {
}

assertType('false', DateInterval::createFromDateString($interval));

DateInterval::createFromDateString();
};

0 comments on commit e0aa795

Please sign in to comment.