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

allowParams* reports invalid configuration #153

Closed eithed closed 1 year ago

eithed commented 1 year ago

Trying to use any of the allowParams* configuration parameters results in Invalid configuration: error; using the configuration from examples:

parameters:
    disallowedFunctionCalls:
        -
            method: 'PotentiallyDangerous\Logger::log()'
            message: 'use our own logger instead'
            allowIn:
                - path/to/some/file-*.php
                - tests/*.test.php
            allowParamsInAllowed:
                -
                    position: 1
                    name: 'message'
                    value: 'foo'
                -
                    position: 2
                    name: 'alert'
                    value: true
            allowParamsAnywhere:
                -
                    position: 2
                    name: 'alert'
                    value: true

results in:

Invalid configuration:
The item 'parameters › disallowedFunctionCalls › 18 › allowParamsInAllowed › 0' expects to be string, array given.
Invalid configuration:
The item 'parameters › disallowedFunctionCalls › 18 › allowParamsInAllowed › 1' expects to be string, array given.
Invalid configuration:
The item 'parameters › disallowedFunctionCalls › 18 › allowParamsInAllowed › 0' expects to be int|string|bool, array given.
Invalid configuration:
The item 'parameters › disallowedFunctionCalls › 18 › allowParamsInAllowed › 1' expects to be int|string|bool, array given.
Invalid configuration:
The item 'parameters › disallowedFunctionCalls › 18 › allowParamsAnywhere › 0' expects to be string, array given.
Invalid configuration:
The item 'parameters › disallowedFunctionCalls › 18 › allowParamsAnywhere › 0' expects to be int|string|bool, array given.

Can you please advise?

spaze commented 1 year ago

Hi, this is a bug introduced in 2.11.0 when the named params support was introduced in #141. Sorry for that, I'll fix it like now. Mean while the non-named params should work, if you'd like to carry on :-)

spaze commented 1 year ago

The fix was released in 2.11.1 now, should be ok for you, let me know if not (or even if yes 😊).

Again, thanks & sorry.

eithed commented 1 year ago

No worries - thank you for resolving this so quickly! Will proceed with testing what I've touched on in discussion and will get in touch if it's not working. Thanks again!