szepeviktor / phpstan-wordpress

WordPress extensions for PHPStan ⛏️
https://packagist.org/packages/szepeviktor/phpstan-wordpress
MIT License
267 stars 25 forks source link

Improve/fix type StringOrArray extension #167

Closed herndlm closed 1 year ago

herndlm commented 1 year ago

Closes https://github.com/szepeviktor/phpstan-wordpress/issues/154

Successor of https://github.com/szepeviktor/phpstan-wordpress/pull/163

szepeviktor commented 1 year ago

Does PHP allow $this in a closure? I would not allow it!

herndlm commented 1 year ago

Does PHP allow $this in a closure? I would not allow it!

sure, there's no reason against it. without such code (and also e.g. with the weird Neutron CS rule that forbids to have a callable assigned to a var) PHPStan wouldn't be able to efficiently parse and handle the AST to figure out types

herndlm commented 1 year ago

@IanDelMar let me/us know please what you think of this. I did briefly confirm the test cases with a real WordPress, but I don't know the internals of the escaping function well enough. Maybe @johnbillion can quickly check too :)

IanDelMar commented 1 year ago

@herndlm Looks good to me!

szepeviktor commented 1 year ago

Is it ready to merge?