phpstan-banned-code
phpstan-banned-code copied to clipboard
How can I disable detection of die/exit ?
Hi Ekino,
As the detection of die/exit is enabled by default in the extension.neon. Is it possible to disable such detection in my project? If so, how to do it?
Best regards, Weichao
Hi,
You can find different solutions in the official documentation: https://phpstan.org/user-guide/ignoring-errors
If you want to disable it globally, I think you can redeclare the parameter in your project.
Hi @mremi ,
Thank you for the explanation, I want to disable it globally. I have tried to re-declare the parameter in my project like this:
banned_code:
nodes:
# enable detection of a set of functions
-
type: Expr_FuncCall
functions:
- dump
- var_dump
I just want to detect these functions: "dump" and "var_dump", not "exit" or "eval". But this did not work, it still show errors for "exit" and "eval". I think it is because this config is already defined in https://github.com/ekino/phpstan-banned-code/blob/master/extension.neon, we can not override it in our own project. Can you advise me?
Best regards, Weichao
Hi, I want the same thing than @ywcdiao : disable the default functions detect in errors. I can edit the extension.neon file and it works well but it's just a temporary solution because this file is often refreshed Is it possible to overwrite properly the rules defined in this file and not just add rules to this default rules ?
EDIT -> I found a solution, do not include vendor/ekino/phpstan-banned-code/extension.neon in PHPStan config and just include my own file with the same template that extension.neon (parametersSchema, parameters and services tags)
Best regards, Valentin
Hi @ValentinLorand ,
Thank you for providing the solution. By the way, did you add phpstan/extension-installer in your composer.json file? I think this package includes vendor/ekino/phpstan-banned-code/extension.neon automatically, am I right?
Best regards, Weichao
Hi @ywcdiao yes exactly, as described in the README.md it will include extension.neon for you.
Hi, I haven't add phpstan/extension-installer in my composer.json, this explain why my solution works. I hope it's working for you.
Hi @ValentinLorand
Thank you. Maybe I need to remove phpstan/extension-installer to solve this. However this package is really helpful to add some phpstan extensions, it includes extension.neon automatically.