phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

DateTimeImmutable::modify() can no longer return false since PHP 8.3

Open JanTvrdik opened this issue 1 year ago • 5 comments

Since PHP 8.3, DateTimeImmutable::modify() can no longer return false, and throws DateMalformedStringException instead.

Relevant RFC: https://wiki.php.net/rfc/datetime-exceptions

Relevant php-src commit: https://github.com/php/php-src/commit/b7860cd56476d737fcf2e1fdda109b042312e3fa

Relevant code change:

obrazek

JanTvrdik avatar May 25 '24 09:05 JanTvrdik

Some tests failed, otherwise 👍

Btw what about @throws for the method?

ondrejmirtes avatar May 25 '24 16:05 ondrejmirtes

Btw what about @throws for the method?

It throws DateMalformedStringException. But you can't put @throws into function map, can you?

JanTvrdik avatar May 26 '24 07:05 JanTvrdik

There would have to be conditionally loaded stub file for 8.4+.

ondrejmirtes avatar May 26 '24 07:05 ondrejmirtes

Can we fix @throws in next step? I believe this already improves things.

janedbal avatar May 30 '24 09:05 janedbal

I feel like fixing the return type and adding @throws is an atomic change. We know it should be done, let's do it while we have the context.

ondrejmirtes avatar May 30 '24 10:05 ondrejmirtes

Looks to be fixed as part of https://github.com/phpstan/phpstan-src/pull/3209.

JanTvrdik avatar Jul 17 '24 09:07 JanTvrdik

I totally forgot about this PR, sorry! I was forced to fix this as part of update to jetbrains/phpstorm-stubs about exception-throwing on 8.3.

ondrejmirtes avatar Jul 17 '24 09:07 ondrejmirtes