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

Invalid configuration: Unexpected item 'parameters › disallowedFunctionCalls'. #148

Closed k00ni closed 1 year ago

k00ni commented 1 year ago

I am calling PHPStan (v1.9.2, using PHP 8.1.6) with:

vendor/bin/phpstan analyse -c phpstan.neon

and I get the following error when using one of your neon-files:

Invalid configuration: Unexpected item 'parameters › disallowedFunctionCalls'.

My PHPStan config is:

includes:
    - vendor/phpstan/phpstan-phpunit/extension.neon
    - vendor/phpstan/phpstan-strict-rules/rules.neon
    - vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
    # - vendor/phpstan/phpstan/conf/bleedingEdge.neon

parameters:
    bootstrapFiles:
        - vendor/autoload.php
    scanFiles:
      - config/bootstrap.php

    fileExtensions:
        - php

    level: 8

    paths:
        - src
        - test

    parallel:
        maximumNumberOfProcesses: 2

    tmpDir: ./var/cache/phpstan

    reportUnmatchedIgnoredErrors: true

    checkGenericClassInNonGenericObjectType: true

    ignoreErrors:
        - '/Variable method call on/'
        - '/Variable property access on DateInterval/'
        - '/Variable property access on App\\Service\\Statistics\\Class\\OrderPack/'

When only using vendor/spaze/phpstan-disallowed-calls/extension.neon it doesn't report anything (tested it with a blunt var_dump).

I would like to check out your PHPStan rules, but can't get it to work. Help is appreciated.

spaze commented 1 year ago

You need to load both extension.neon and say disallowed-dangerous-calls.neon, see my example.

Loading just extension.neon doesn't report anything because you may want to have only your own disallowed config, and loading just disallowed-dangerous-calls.neon doesn't load the extension config because you may want to include multiple disallowed-*-calls.neon files.

Let me know if that helps and if yes, please close the issue :-)

k00ni commented 1 year ago

Thanks, that works!