Skip to content

Add env as a forbidden function #1

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

Open
phillipdebruin opened this issue Aug 21, 2018 · 1 comment
Open

Add env as a forbidden function #1

phillipdebruin opened this issue Aug 21, 2018 · 1 comment

Comments

@phillipdebruin
Copy link
Contributor

phillipdebruin commented Aug 21, 2018

Laravel config cache is great, but when it's enabled .env values are all null. We tend not to enable it on our dev environment, but on production. The use of the env() helper could easily slip into our code. A sniffer for it would be a good idea then.

@williamdes
Copy link

    <!-- Ban some functions -->
    <rule ref="Generic.PHP.ForbiddenFunctions">
        <properties>
            <property name="forbiddenFunctions" type="array">
                <!-- https://github.com/flickerleap/phpcs/issues/1#issue-352498247 -->
                <!-- DO NOT USE env() or getenv() because it will break laravel env/config caching -->
                <element key="env" value="config"/>
                <element key="getenv" value="config"/>
            </property>
        </properties>
    </rule>

    <rule ref="Generic.PHP.ForbiddenFunctions">
        <exclude-pattern>config/*.php</exclude-pattern>
    </rule>

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

2 participants