szepeviktor/phpstan-wordpress

Replace `TypeSpecifyingExtension` with `@phpstan-assert` for type narrowing

swissspidy opened this issue ยท 4 comments

Now that this package requires PHPStan 1.10.0+, It seems like IsWpErrorFunctionTypeSpecifyingExtension, AssertWpErrorTypeSpecifyingExtension, and AssertNotWpErrorTypeSpecifyingExtension extensions could be replaced with @phpstan-assert annotations, which were introduced in PHPStan 1.9.0.

These annotations would need to be added in php-stubs/wordpress-tests-stubs / php-stubs/wordpress-stubs of course.

Increase it? ๐ŸŽ‰

PR for is_wp_error: php-stubs/wordpress-stubs#69

That annotation probably doesn't work for assertWPError because it neither throws nor returns a bool, so we still need that extension.

But at least it means we could get rid of IsWpErrorFunctionTypeSpecifyingExtension at some point

Done ๐Ÿ