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

Detect undefined functions on PullRequests #1087

Closed
Flyingmana opened this issue Jul 2, 2020 · 6 comments · Fixed by #2035
Closed

Detect undefined functions on PullRequests #1087

Flyingmana opened this issue Jul 2, 2020 · 6 comments · Fixed by #2035

Comments

@Flyingmana
Copy link
Contributor

Flyingmana commented Jul 2, 2020

With the PR #966 we introduced a function call, to a non defined function by accident.
The error was reported/fixed in #1084

It should be possible to detect this case with a static analyses, and have this triggering an error as one of the Checks running on a PR

possible tools?
https://github.com/vimeo/psalm
https://github.com/phan/phan
https://github.com/phpstan/phpstan

@Flyingmana
Copy link
Contributor Author

Phan is outputting a lot, but it contains:

lib/Varien/Io/File.php:490 PhanUndeclaredFunction Call to undeclared function \char() (Did you mean \chr())

my config I used:
https://gist.github.com/Flyingmana/484003b1887ae71ce6a96146cc4a73fa

not sure yet how I limit the results to only specific errors

Also it does not know context, so also has false positives like in Mage_PageCache_Model_Control_Zend

Also it finds some cases where I think its not an issue?

lib/Cm/Cache/Backend/Redis.php:866 PhanUndeclaredFunction Call to undeclared function \snappy_compress()
lib/Cm/Cache/Backend/Redis.php:868 PhanUndeclaredFunction Call to undeclared function \lz4_compress() (Did you mean \gzcompress() or \gzuncompress())
lib/Cm/Cache/Backend/Redis.php:888 PhanUndeclaredFunction Call to undeclared function \snappy_uncompress()
lib/Cm/Cache/Backend/Redis.php:890 PhanUndeclaredFunction Call to undeclared function \lz4_uncompress() (Did you mean \gzuncompress())
lib/Mage/Connect/Validator.php:411 PhanUndeclaredFunction Call to undeclared function \version_compate() (Did you mean \version_compare())

@sreichel
Copy link
Contributor

sreichel commented Jul 2, 2020

Maybe you want to test phpStan too .... https://phpstan.org/r/940d1f01-5b1e-43e5-9a28-3ec530e1cd9f

@Flyingmana
Copy link
Contributor Author

Ahh nice, I did not find thisnrule when I initially searched, so tried out the other first.
Can I limit phpstan to only do this one check?

@sreichel
Copy link
Contributor

sreichel commented Jul 2, 2020

Ahh nice, I did not find thisnrule when I initially searched, so tried out the other first.
Can I limit phpstan to only do this one check?

Linked example uses highest severity level (8) ... but undefined mehtods are also detected on lowest level (0).

Maybe run phpStan with level 0 and add all other errors to ignore list (or fix them :P)

@tmotyl
Copy link
Contributor

tmotyl commented Sep 27, 2021

working setup with phpstan: #1837

@tmotyl
Copy link
Contributor

tmotyl commented Mar 9, 2022

I believe this can be closed once we got #2035 merged, don't you think?

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

Successfully merging a pull request may close this issue.

3 participants