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

Improve `sprintf` return type inference

Open staabm opened this issue 1 year ago • 8 comments

closes https://github.com/phpstan/phpstan/issues/11201 closes https://github.com/phpstan/phpstan/issues/10493

staabm avatar Jun 19 '24 09:06 staabm

the composer error is valid, as we previously inferred a non-empty-string return type, even though the sprintf pattern is not known at static analysis time.

other errors are the same ones are unrelated

staabm avatar Jun 20 '24 07:06 staabm

This pull request has been marked as ready for review.

phpstan-bot avatar Jun 20 '24 07:06 phpstan-bot

the reported phpstan error is interesstig.. it seems - depending on some unknown factor - reports that we are catching a non-throwable but ignoring this very same error by identifer leads to a "No error with identifier catch.notThrowable is reported on line 200."

see the 2 variants at

  • https://github.com/phpstan/phpstan-src/pull/3168/commits/ff9189e5e14e3cbe3dc1b87eba1cd09763cb52da
  • https://github.com/phpstan/phpstan-src/pull/3168/commits/fd5e76270f38ebf0e04137fff4426d4db264d7d7

(its unrelated to this PR though)

staabm avatar Jun 22 '24 07:06 staabm

I think its related to this Consistency::flexEntity call in the exception classes.. some class-alias stuff is going on there.. this might lead to a race condition depending on the order which classes will be scanned when

staabm avatar Jun 22 '24 07:06 staabm

There's an opportunity to grab the code from Hoa packages and make a small single modern library with no magic and simple PSR-4 autoloading and replace Hoa in phpstan-src. I might look into it this summer.

ondrejmirtes avatar Jun 22 '24 07:06 ondrejmirtes

I might look into it this summer.

ok, what can we do to fix the build until then?

staabm avatar Jun 22 '24 13:06 staabm

Try to rebase on top of: https://github.com/phpstan/phpstan-src/commit/323315554048a22e6c01d635d6c5bb68f10d5aa1

ondrejmirtes avatar Jun 24 '24 13:06 ondrejmirtes

Try to rebase on top of: 3233155

looks great, thanks

staabm avatar Jun 24 '24 13:06 staabm