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

False positives for array functions #89

Open
Stadly opened this issue Sep 22, 2023 · 2 comments
Open

False positives for array functions #89

Stadly opened this issue Sep 22, 2023 · 2 comments

Comments

@Stadly
Copy link

Stadly commented Sep 22, 2023

$a = [1,2,3];
key($a);
reset($a);
end($a);

The above code falsely produces errors:

Function key() is removed.
Consider replace with use with objects is deprecated()

Function reset() is removed.
Consider replace with use with objects is deprecated()

Function end() is removed.
Consider replace with use with objects is deprecated()

There may be other similar functions producing this error as well. These are the ones I had in my code base.

@sharpchi
Copy link

sharpchi commented Nov 9, 2023

This is from PHP 8.1, and it's a strange one, because it's only deprecated if an object, rather than an array is supplied. But this tool doesn't know what you're feeding it.
I think it's worth checking that you're only supplying arrays to these functions. Then there's an option to --skip-checks, so you can use something like:
phpdd scan --skip-checks reset,end PATH

@codewise-nicolas
Copy link

We got this too when using current().

I think the problem is the wording from the tool: 'Function XXXX() is removed'.
The function is not removed from PHP. The function isnt even deprecated as a whole - only a specific use case is deprecated.
This should be a warning and not an error outright.

Then the second line "Consider replace with use with objects is deprecated()" is not gramatically correct so reading it several times over is still confusing as to what its telling the user to do.
I believe the intent was to say that the 'use with objects is deprecated' as an note/warning, but instead its being presented as a replacement consideration.

The main line should be replaced with something like
'Function XXX() use with objects is deprecated.'

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

No branches or pull requests

3 participants