Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arg #1 of array_walk and array_walk_recursive #573

Closed
wants to merge 1 commit into from

Conversation

niconoe-
Copy link
Contributor

@niconoe- niconoe- commented Jul 8, 2021

Add the type object as a possible type for the first argument of array_walk and array_walk_recursive.

The ability to use an object instead of an array in those functions is available since at least PHP 7.0.
Eval: https://3v4l.org/E36RP

I think I heard about an incoming restriction that array_walk and array_walk_recursive could only works with arrays and not objects, but this is not yet how it is designed.

@ondrejmirtes
Copy link
Member

Hi, I'm looking into this and this change isn't sufficient. What caught my eyes is that the error is reported even on PHP 8: https://phpstan.org/r/eb2d3854-334c-4ed6-b6bf-a5ca917e0de0

But it shouldn't since PHPStan uses these stubs with the correct typehint: https://github.com/phpstan/php-8-stubs/blob/main/stubs/ext/standard/array_walk.php

This fixes the problem: 902899d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants