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

PHP8 array_uintersect false positive #4530

Closed
Jurigag opened this issue Feb 12, 2021 · 5 comments
Closed

PHP8 array_uintersect false positive #4530

Jurigag opened this issue Feb 12, 2021 · 5 comments
Labels

Comments

@Jurigag
Copy link

Jurigag commented Feb 12, 2021

Bug report

When using array_uintersect in PHP8 phpstan returns error:

Parameter #3 ...$rest of function array_uintersect expects array, string given.

However the same error is not returned when using PHP7. Also what is interesting here https://3v4l.org/4MMeU that reflection api reports other parameters of the function for PHP 8, maybe it's actually PHP bug?

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
$array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red");

print_r(array_uintersect($array1, $array2, "strcasecmp"));

Here is link to playground - https://phpstan.org/r/fe236064-884e-48ae-bd28-fbd452c9ec7c

Expected output

No errors!

@Jurigag
Copy link
Author

Jurigag commented Feb 12, 2021

I've also created bug here https://bugs.php.net/bug.php?id=80736 because it seems like php8 bug actually.

@ondrejmirtes
Copy link
Member

Hi, this function is really weird so I'm not surprised it broke. It has a variadic parameter that's not its last parameter, which cannot be achieved by userland functions.

@Jurigag
Copy link
Author

Jurigag commented Feb 12, 2021

@ondrejmirtes someone answered on bug page and it seems intended way so i guess phpstan would need to somehow figure this out?

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@7bc35cd

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants