vendor/bin/phpstan instead when available.
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.
CodeRabbit looks for the following PHPStan config files in the repository root:
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
With a generated config, CodeRabbit passes the changed PHP files to PHPStan as the analysis scope. With a repository-provided config, CodeRabbit narrows analysis to changed files when a rootcomposer.json is present and dependency installation succeeds. Without composer.json, CodeRabbit keeps the analysis paths declared by the repository config to avoid false unresolved-symbol findings. If Composer installation fails, PHPStan does not run.
For large changed-file sets, CodeRabbit analyzes the files in bounded parts and combines the findings.
Composer dependencies
When the repository root containscomposer.json, CodeRabbit installs Composer dependencies in the review sandbox, including when CodeRabbit generates the PHPStan config. Composer uses a writable cache inside the sandbox, and each installation attempt has a 120-second timeout. After analysis, 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 any supported PHPStan config that declares
bootstrapFileorbootstrapFilesto 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:- PHPStan is disabled in your CodeRabbit configuration.
- No supported changed PHP files remain in the sandbox worktree.
- 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.