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

How can I disable detection of die/exit ? #35

Open
ywcdiao opened this issue Jul 7, 2020 · 7 comments
Open

How can I disable detection of die/exit ? #35

ywcdiao opened this issue Jul 7, 2020 · 7 comments

Comments

@ywcdiao
Copy link

ywcdiao commented Jul 7, 2020

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

@mremi
Copy link
Member

mremi commented Jul 20, 2020

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.

@ywcdiao
Copy link
Author

ywcdiao commented Jul 31, 2020

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

@ValentinLorand
Copy link

ValentinLorand commented Aug 4, 2020

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

@ywcdiao
Copy link
Author

ywcdiao commented Aug 7, 2020

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

@mremi
Copy link
Member

mremi commented Aug 7, 2020

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

@ValentinLorand
Copy link

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.

@ywcdiao
Copy link
Author

ywcdiao commented Aug 10, 2020

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.

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