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

Deprecated/not available functions not reported #6935

Open
kkmuffme opened this issue Nov 16, 2021 · 4 comments · May be fixed by #10771
Open

Deprecated/not available functions not reported #6935

kkmuffme opened this issue Nov 16, 2021 · 4 comments · May be fixed by #10771
Labels
bug hard problems Problems without an obvious easy solution

Comments

@kkmuffme
Copy link
Contributor

kkmuffme commented Nov 16, 2021

Assuming psalm.dev runs on PHP 7.4.x (phpVersion=7.4 in config, since I cannot see the actual config)

https://psalm.dev/r/5201b68036

Should give an error:
https://www.php.net/manual/en/migration72.deprecated.php

EDIT: when tested again in 03/2024 with psalm 5.22 this correctly reports UndefinedFunction => this is bc since PHP 8.0.0 the function was completely removed, therefore it's reported as "UndefinedFunction". This works correctly as it should, as psalm reports undefined but not only deprecated functions

===

Also vice versa, if phpVersion=7.0, I expect to get an error for this:
https://psalm.dev/r/208b2cb781

as the array_key_first function was added in 7.3.0 https://www.php.net/manual/de/function.array-key-first.php

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/5201b68036
<?php

each( $array );
Psalm output (using commit aabd96c):

No issues!
https://psalm.dev/r/208b2cb781
<?php

$array = array( rand( 10, 20 ) => 'bar');

echo array_key_first( $array );
Psalm output (using commit aabd96c):

No issues!

@weirdan
Copy link
Collaborator

weirdan commented Nov 17, 2021

It appears Psalm reflects the runtime function definition when it can't find the requested function in callmap:
image

@weirdan weirdan added bug hard problems Problems without an obvious easy solution labels Nov 17, 2021
@kkmuffme
Copy link
Contributor Author

@weirdan I guess there is no way around hardcoding all deprecated/newly introduced functions and just checking against that in psalm?

There is a (non-maintained?) tool, that already has all that data collected up to PHP 8.0 (I think PHP 8.0 isn't fully complete, but before that I'm sure it is): https://github.com/wapmorgan/PhpDeprecationDetector/tree/master/data

@weirdan
Copy link
Collaborator

weirdan commented Nov 17, 2021

We have most of that data in callmaps (added and removed functions). If we're going to add deprecations for internal functions, it would make sense to have them there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug hard problems Problems without an obvious easy solution
Projects
None yet
2 participants