Fix wrong signature for DateInterval::createFromDateString in 8.3+#5483
Fix wrong signature for DateInterval::createFromDateString in 8.3+#5483sunkan wants to merge 4 commits intophpstan:2.1.xfrom
Conversation
|
The linked issue is closed. Please first create an issue from one of the templates at https://github.com/phpstan/phpstan/issues/new/choose and provide a failing playground example. |
|
I did use the "Function signature mismatch" And it says |
|
Exemple of the issue https://phpstan.org/r/213cc168-576f-49eb-b1e3-f32de3fdf0bd The DateIntervalDynamicReturnTypeExtension need to be updated too |
| use function count; | ||
|
|
||
| #[AutowiredService] | ||
| final class DateIntervalCreateFromDateStringMethodThrowTypeExtension implements DynamicStaticMethodThrowTypeExtension |
There was a problem hiding this comment.
this extension needs testing.
see e.g. 5645c04#diff-0ec4f831901651eabb90c05586b3404e02c820361f0df02b7789a381c65d1f7d on how other *ThrowTypeExtensions have been tested in the past
| $possibleReturnTypes[] = false; | ||
| continue; | ||
| } | ||
| // @phpstan-ignore instanceof.alwaysTrue (should only run for < 8.3 and then statement isn't true) |
There was a problem hiding this comment.
I think you can get arround this by moving the above newly added return cases after the try/catch into the if/else block, which also does the return-type determination for the PHP < 8.3 case
|
You're getting I'm working on it JetBrains/phpstorm-stubs#1874 |
Fixes phpstan/phpstan#14479
Summary
In php8.3 the signature changed from
to
now it instead throws an DateMalformedStringException
Reference: https://www.php.net/manual/en/dateinterval.createfromdatestring.php
This pr collides with the fix for phpstan/phpstan#8442 but I don't know how to solve that.