phpstan-banned-code icon indicating copy to clipboard operation
phpstan-banned-code copied to clipboard

How can I disable detection of die/exit ?

Open ywcdiao opened this issue 5 years ago • 8 comments

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

ywcdiao avatar Jul 07 '20 07:07 ywcdiao

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.

mremi avatar Jul 20 '20 11:07 mremi

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

ywcdiao avatar Jul 31 '20 03:07 ywcdiao

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

ValentinLorand avatar Aug 04 '20 09:08 ValentinLorand

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

ywcdiao avatar Aug 07 '20 01:08 ywcdiao

Hi @ywcdiao yes exactly, as described in the README.md it will include extension.neon for you.

mremi avatar Aug 07 '20 06:08 mremi

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.

ValentinLorand avatar Aug 07 '20 10:08 ValentinLorand

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.

ywcdiao avatar Aug 10 '20 01:08 ywcdiao