vendor/bin/phpstan instead when available.
CodeRabbit runs PHPStan v2.2.16.
Files
PHPStan will run on files with the following extensions:.php
Configuration
boolean
default:true
Enable PHPStan: PHPStan requires config file in your repository root. Please ensure that this file contains the
paths: parameter.enum
default:"default"
Level: Specify the rule level to run. When set to
default, the level is determined by the review profile: chill uses level 3 (real bugs only — return/property type mismatches, array offset errors) and assertive uses level 8 (adds dead code detection, argument type checking, null safety, and typehint checks). This setting is ignored if your configuration file already has a level: parameter.One of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, default, max- .coderabbit.yaml
- Web UI
.coderabbit.yaml
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.