Files
PHPStan will run on files with the following extensions:.php
Configuration
PHPStan is enabled by default. Enable or disable it and set its rule level with.coderabbit.yaml or the CodeRabbit web UI:
- .coderabbit.yaml
- Web UI
.coderabbit.yaml
level option accepts default, 0 through 9, or max and defaults to default. With default, CodeRabbit uses level 3 in Chill mode and level 8 in Assertive mode. A level: value in the repository’s PHPStan config takes precedence over this setting.
PHPStan supports the following config files:
phpstan.neonphpstan.neon.distphpstan.dist.neon
What CodeRabbit runs
PHPStan runs in a sandbox with the project config if present. If a project config is present, we parse and validate the config before execution.Analysis scope
CodeRabbit-generated config files always setpaths: to the changed-file scope. For repository-provided config files, CodeRabbit narrows paths: to changed files only when composer.json is present and Composer dependency installation succeeds. Otherwise, CodeRabbit keeps the analysis paths declared by the config file to avoid false unresolved-symbol findings.
For large changed-file sets, CodeRabbit analyzes the files in bounded parts and combines the findings.
Composer dependencies
When a repository-provided config file needs Composer dependencies for symbol resolution, CodeRabbit installs them in the review sandbox. During installation, Composer uses a writable cache inside the review sandbox. After 120 seconds, Composer installation stops. After the run, CodeRabbit removes the PHPStan and Composer cache directories.When Composer setup fails
If Composer dependency installation fails, the review explains the failure. The message distinguishes private-package access, dependency resolution, outdated lock files, unreachable registries, unavailable packages, sandbox cache failures, timeouts, and unclassified failures. It does not expose raw package names or host names. When private dependencies are not accessible, disable the built-in PHPStan check and rely on PHPStan output from your own CI pipeline instead.Profile behavior
- With
level: defaultand a generated config, Chill uses level 3 and reports findings as errors. - With
level: defaultand a generated config, Assertive uses level 8 and reports findings as warnings.
constructor.unusedParameterclosure.unusedUseclass.nameCasemethod.nameCasephpDoc.parseErrorphpDoc.phpstanTagreturn.phpDocTypemissingType.genericsmissingType.iterableValuephpDoc.variancegenerics.varianceclass.notFoundmethod.notFoundfunction.notFoundattribute.notFoundproperty.notFoundvariable.undefined
method.unusedclassConstant.unusedproperty.unusedreturn.unusedTypeproperty.unusedTypetrait.unusedmissingType.returnmissingType.parametermissingType.propertymissingType.callable
property.notFound and variable.undefined from review comments, including when the repository supplies its own config.
Security policy and restrictions
- We reject
phpstan.neon/phpstan.neon.distthat declarebootstrapFileorbootstrapFilesto prevent executing arbitrary project bootstrap code. - Blocked configuration keys include:
bootstrapFilesbootstrapFile
- If a config declares
includes:, CodeRabbit does not resolve the included files. It discards the repository config and uses a generated profile config for the run. - Composer dependency installation disables plugins and scripts.
When we skip PHPStan
CodeRabbit will skip running PHPStan when:- The config file does not contain a
paths:parameter. - The config contains
bootstrapFileorbootstrapFiles. - PHPStan is already running in GitHub Actions, GitLab CI, CircleCI, or Azure Pipelines.
- Config parsing fails or appears unsafe.