spaze / phpstan-disallowed-calls

PHPStan rules to detect disallowed method & function calls, constant, namespace, attribute & superglobal usages
MIT License
255 stars 17 forks source link

Feature Request: Configure SuperGlobals as array #110

Closed pableu closed 2 years ago

pableu commented 2 years ago

This would allow me to make the config significantly easier and shorter:

    disallowedSuperglobals:
        -
            superglobal: '$_GET'
            allowIn:
                - lib/*
                - admin/legacy/*
        -
            superglobal: '$_POST'
            allowIn:
                - lib/*
                - admin/legacy/*
        -
            superglobal: '$_REQUEST'
            allowIn:
                - lib/*
                - admin/legacy/*
        -
            superglobal: '$_COOKIE'
            allowIn:
                - lib/*
                - admin/legacy/*
        -
            superglobal: '$_SERVER'
            allowIn:
                - lib/*
                - admin/legacy/*
    disallowedSuperglobals:
        -
            superglobal: ['$_GET', '$_POST', '$_REQUEST', '$_COOKIE', '$_SERVER']
            allowIn:
                - lib/*
                - admin/legacy/*

Or is this already possible and I just missed it?

spaze commented 2 years ago

Currently this isn't possible but seems useful (not just for disallowedSuperglobals but also for other disallowed* config keys) so I may add it one day. Feel free to send a pull request :-)

spaze commented 2 years ago

Today is the day when I realized it would also save me some config lines so I've added the feature, thanks for the idea! Release soon.

pableu commented 2 years ago

Very cool, thank you @spaze!

spaze commented 2 years ago

Now released in 2.4.0.