I have a Bedrock-based WordPress project that is Dockerized (WordPress core is pulled as a Composer dependency on local project). Among the dependencies, there is PHPStan, which works correctly without any errors locally. However, when the GitLab pipeline is run, it fails with multiple errors like Function add_filter invoked with 2 parameters, 0 required
, even though all function calls are correct according to the specifications and mentions in the WordPress core. What could be causing that failure?
P.S. Sometimes, the pipeline can be successfully "greened" by rebuilding the image and rerunning the job with PHPStan without any additional commits, indicating that the issue is not in the code.
Turned out two things:
scanDirectories
directory written like that ./directory/
, it should be directory/
So, the problem was solved by changing phpstan.neon config-file from this:parameters:
scanDirectories:
- ./wp-content/mu-plugins/
- ./wp-content/plugins/
to this:
parameters:
scanDirectories:
- wp-content/mu-plugins/
- wp-content/plugins/