php-stubs / wordpress-stubs

Up-to-date WordPress function and class declaration stubs for static analysis by PHPStan
https://packagist.org/packages/php-stubs/wordpress-stubs
MIT License
151 stars 19 forks source link

wp_die return type is wrong #248

Closed kkmuffme closed 1 month ago

kkmuffme commented 1 month ago

https://github.com/php-stubs/wordpress-stubs/blame/v6.6.2/functionMap.php#L56

https://developer.wordpress.org/reference/functions/wp_die/

kkmuffme commented 1 month ago

This same mistake is there for other stuff too - e.g. wp_list_bookmarks, wp_list_categories,... since those all are for sealed array shapes but should be unsealed

szepeviktor commented 1 month ago

@kkmuffme How many laser eyes do you have? 🙃

IanDelMar commented 1 month ago
  • array{exit: false} is wrong, since the array can have other keys in it too, e.g. code and the correct type would be array{exit: false}&array

Each of these is tested with an additional key. None of the tests are failing. Why is this?

kkmuffme commented 1 month ago

Maybe because phpstan doesn't seal arrays by default (like how it was in psalm pre-v5)?

IanDelMar commented 1 month ago

For PHPStan array{exit: false}&array = array{exit: false}. This is different in Psalm?

kkmuffme commented 1 month ago

Yes (as it should be, since that behavior you just described was a bad design choice taken in psalm initially and copied by everybody)

IanDelMar commented 1 month ago

The problem is that you’re using Psalm, and therefore array{exit: false} doesn’t work as expected?

@szepeviktor Perhaps we could add support for this? See https://github.com/phpstan/phpdoc-parser/pull/169.

kkmuffme commented 1 month ago

No, the problem is not that I'm using Psalm, it's that your type is wrong. If you want to know why, look up why we changed the behavior in psalm

szepeviktor commented 1 month ago

I do not want to work on this package & I keep a distance from Psalm.

kkmuffme commented 1 month ago

I do not want to work on this package

Don't need to, the fix will be PRed anyway. Maybe add other maintainers?

I keep a distance from Psalm

Why? :-)

szepeviktor commented 1 month ago

I keep a distance from Psalm

Why? :-)

It has dark roots. That is all. I do not want to spark emotions.

kkmuffme commented 1 month ago

If I may ask bc I'm unaware (and have contributed quite a bit to psalm): bc of initial funding of psalm? or personal experience with psalm's team?

szepeviktor commented 1 month ago

Sorry. That is all. I've read it on psalm.dev many years ago.

IanDelMar commented 1 month ago

@kkmuffme I’d appreciate it if you could have a look at #251.