Closed IanDelMar closed 10 months ago
WordPress is so weird PHPStan cannot follow.
There seems to be no setEarlyTerminating
method in PHPStan.
https://github.com/search?q=repo%3Aphpstan%2Fphpstan-src%20earlyTerminating&type=code
What is your plan?
Never use ['exit' => false]
again? 🙃
What is your plan? Never use
['exit' => false]
again? 🙃
:laughing:
Don't know. Maybe putting 'wp_die' => ['($args is not non-empty-array ? never : void)'],
into the functionMap.php of WordPress stubs?
Or adding an extension checking for the exit key in $args
and then either use the never or the void type.
Okay! I am in! Please add that and add a few (2) tests too.
Thank you.
wp_die()
is treated as if it terminated script execution early: https://github.com/szepeviktor/phpstan-wordpress/blob/76f783564edc0bd8f4f3a2e44f6c09a1092702d5/extension.neon#L126-L127But for
wp_die('', '', ['exit' => false])
the script execution will not be terminated in any of WP's wp_die handlers.