Skip to content

Commit 21f8220

Browse files
committed
Simplify 8.3 logic
1 parent b5c1c72 commit 21f8220

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/Type/Php/DateIntervalDynamicReturnTypeExtension.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,10 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
5050
foreach ($strings as $string) {
5151
try {
5252
$result = @DateInterval::createFromDateString($string->getValue());
53-
if ($this->phpVersion->hasDateTimeExceptions()) {
54-
return new ObjectType(DateInterval::class);
55-
}
5653
} catch (Throwable) {
57-
if ($this->phpVersion->hasDateTimeExceptions()) {
58-
return new NeverType();
59-
}
6054
$possibleReturnTypes[] = false;
6155
continue;
6256
}
63-
// @phpstan-ignore instanceof.alwaysTrue (should only run for < 8.3 and then statement isn't true)
6457
$possibleReturnTypes[] = $result instanceof DateInterval ? DateInterval::class : false;
6558
}
6659

@@ -74,6 +67,9 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
7467
}
7568

7669
if (in_array(false, $possibleReturnTypes, true)) {
70+
if ($this->phpVersion->hasDateTimeExceptions()) {
71+
return new NeverType();
72+
}
7773
return new ConstantBooleanType(false);
7874
}
7975

0 commit comments

Comments
 (0)