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

allowParamsAnywhere named parameters #140

Closed ilazaridis closed 1 year ago

ilazaridis commented 1 year ago

Hello,

it would be awesome if instead of the order of the parameter declared as an integer, the named parameter could be used.

So for example in

function: 'json_decode()'
message: ''
allowParamsAnywhere:
    4: ::JSON_THROW_ON_ERROR

instead of 4, flags could be used, so that we don't need to define all the ommited parameters before flags.

spaze commented 1 year ago

Hi, yeah, that makes sense. I even thought it's already supported but I was wrong :-) I§ll look at it for some of the next releases but feel free to send a PR, the param type and value is figured around here (note to mostly myself, but feel free to follow it too) https://github.com/spaze/phpstan-disallowed-calls/blob/332969d0aa67ddb8597c2f1248268d69ebf5f9c7/src/DisallowedHelper.php#L121-L125 and some tests in https://github.com/spaze/phpstan-disallowed-calls/blob/332969d0aa67ddb8597c2f1248268d69ebf5f9c7/tests/Calls/FunctionCallsTest.php

ilazaridis commented 1 year ago

Awesome! I will have a look, thank you.

ilazaridis commented 1 year ago

Changes are ready, 2 problems though:

In any case php 7.2 is not supported anymore and even 7.4 support is ending in 4 days.

Wdyt ? Do you consider changing the php version in composer soon ?

spaze commented 1 year ago

I'd very much like to jump straight to supporting just PHP 8.1+ but as PHPStan itself supports ^7.2|^8.0 I think we should support the same versions.