spaze / phpstan-disallowed-calls

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

`disallowed-loose-calls.neon` broke with PHPStan 1.10.58 #249

Closed Rockylars closed 9 months ago

Rockylars commented 9 months ago

The other 3 work fine, but including this one with PHPStan 1.10.58 will break it. Will work fine with PHPStan 1.10.57. Tested with v3.1.1 through PHP 8.2 and 8.3.

Invalid configuration:
The mandatory item 'parameters › disallowedFunctionCalls' is missing.

Broken:

parameters:
    level: 8
    tmpDir: output/cache/phpstan
    paths:
        - src

    disallowedFunctionCalls:
        -
            function:
                - 'dump()'
            message: 'you probably left a debug statement active in the code'

includes:
    - vendor/spaze/phpstan-disallowed-calls/extension.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon

Also broken:

parameters:
    level: 8
    tmpDir: output/cache/phpstan
    paths:
        - src

includes:
    - vendor/spaze/phpstan-disallowed-calls/extension.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon

Works fine:

parameters:
    level: 8
    tmpDir: output/cache/phpstan
    paths:
        - src

    disallowedFunctionCalls:
        -
            function:
                - 'dump()'
            message: 'you probably left a debug statement active in the code'

includes:
    - vendor/spaze/phpstan-disallowed-calls/extension.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon

Also works fine:

parameters:
    level: 8
    tmpDir: output/cache/phpstan
    paths:
        - src

includes:
    - vendor/spaze/phpstan-disallowed-calls/extension.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon
spaze commented 9 months ago

Hi, thanks. I've changed the config file and added scheduled tests so next time I could detect it hopefully before you do 😅 The fix is in just released 3.1.2.

FYI @ondrejmirtes, re the ::constant(...) support in the .neon config files:

So hopefully this isn't gonna break any time soon :) https://github.com/phpstan/phpstan/issues/10223#issuecomment-1831326007

I think it just did :-) But I'm fine with that.

ondrejmirtes commented 8 months ago

I've tried reverting nette/di to a version that worked best for us: https://github.com/phpstan/phpstan-src/commit/969ff31ab29cd424aab2b2e32344a1825093bdea

It might make this work again.

spaze commented 8 months ago

Yeah, thanks, it started working again, but I'll leave it that way just in case it will stop working again one day 😅 (note to self: basically the same problem reported in https://github.com/phpstan/phpstan/issues/10727)