Fix Psalm incompatibility in callable type#412
Conversation
|
The incompatibility appears to be limited to cases where the parameter is optional. For example, |
|
Another option is that I can fix this in WordPress core, but is it possible to release a new version of wordpress-stubs based on a WordPress nightly release? |
|
If it is in 1 file please remove it from core. |
|
There are only two callable types with parameter names: |
|
Please tell me guys, what to do! |
|
This has been a known Psalm issue since November last year (see vimeo/psalm#11588). I’d suggest:
@johnbillion When you say “nightly release”, do you mean something like pulling WordPress source via Off topic: |
|
Fixed the underlying psalm issue in vimeo/psalm#11647 now - should get merged before the next psalm 6.x release, which means the changes of this PR can get reverted then. |
Unlike PHPStan, Psalm does not support a callable type with parameter name.
While both
callable(mixed $input=): (bool|WP_Error)andcallable(mixed=): (bool|WP_Error)are supported by PHPStan (see PHPStan documentation on callables), Psalm only supportscallable(mixed=): (bool|WP_Error)(see Psalm documentation on callables).See Psalm failing with Internal Psalm error for a callable with parameter name and see Psalm passing for the same callable without parameter name. See PHPStan passing for both.
The callable type
callable(mixed $input=): (bool|WP_Error)is used in the Abilities API that was introduced in WordPress 6.9.Fixes #410
cc @johnbillion