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

Unexpected item 'parameters › disallowedFunctionCalls'. #264

Closed welly closed 2 weeks ago

welly commented 2 weeks ago

I'm running phpstan with phpstan-disallowed-calls in a bitbucket pipeline but getting the error in the title. Output from the pipeline looks like this:

+ php ./vendor/bin/phpstan analyse --memory-limit 1G
Note: Using configuration file /opt/atlassian/pipelines/agent/build/phpstan.neon.
Invalid configuration:
Unexpected item 'parameters › disallowedFunctionCalls'.
Invalid configuration:
Unexpected item 'parameters › disallowedMethodCalls'.

My phpstan.neon looks like:

parameters:
  customRulesetUsed: true
  reportUnmatchedIgnoredErrors: false
  paths:
    - drush
    - scripts
    - src

includes:
  - 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

I've got phpstan/extension-installer installed. If I run

./vendor/bin/phpstan analyze --memory-limit 2048M src/modules/custom in my local environment, it works as expected.

Any ideas what might be causing this?

Many thanks!

spaze commented 2 weeks ago

This happens when the phpstan-disallowed-calls/extension.neon file is not loaded. Is the extension-installer working correctly in the pipeline? Check vendor/phpstan/extension-installer/src/GeneratedConfig.php if it contains spaze/phpstan-disallowed-calls in both the pipeline and on your local.

welly commented 2 weeks ago

That makes sense! Thanks very much. I think what's happening is phpstan/extension-installer is not being installed in our pipeline as it's in dev and as such when composer install is run, it ignores dev modules. I'll move it out of dev and I think that should fix it!

Thanks!

welly commented 2 weeks ago

That fixed it! Thank you.