- How do I install this package in a Laravel project?
- Run `composer require --dev wyrihaximus/phpstan-rules-wrapper` in your project root. The package uses `phpstan/extension-installer`, so no additional configuration is needed for basic usage. Ensure PHPStan is already installed (`phpstan/phpstan`).
- Does this work with Laravel 10/11, or only specific versions?
- This package is Laravel-agnostic and works with any Laravel version (10, 11, or older). It’s designed for PHPStan integration, which runs on your codebase regardless of the Laravel framework. No Laravel-specific dependencies exist.
- What PHP versions are supported by this wrapper?
- The wrapper requires **PHP 8.4+** due to underlying dependencies like PHPStan 2.x. If your Laravel project uses PHP 8.1/8.2, you’ll need to upgrade PHP first. Check compatibility with your PHPStan version in the [README](https://github.com/WyriHaximus/php-phpstan-rules-wrapper).
- Can I disable specific rulesets (e.g., strict-rules) after installation?
- Yes. Edit your `.phpstan.neon` file to exclude unwanted rulesets. For example, add `excludeRules: ['StrictRules\*']` to disable all strict rules. The wrapper bundles rules but lets you fine-tune via PHPStan’s native configuration.
- Will this slow down my CI/CD pipeline significantly?
- Potentially. The wrapper bundles 10+ rule sets, which may increase static analysis time. Start by running PHPStan on a subset of files (e.g., `phpstan analyse app/Http`) to benchmark performance. Disable non-critical rules (e.g., `type-coverage`) if needed.
- Are there Laravel-specific rules (e.g., for Eloquent, Blade) included?
- No. This package focuses on general PHPStan rules (strictness, deprecations, testing). For Laravel-specific analysis, pair it with tools like `nunomaduro/phpinsights` or `phpstan/extension-installer` for custom Laravel rules.
- How do I handle false positives from rules like dead-code-detector?
- False positives are common with strict rules. Start by reviewing the output and excluding specific files/directories in `.phpstan.neon` (e.g., `paths: ['app', '!tests']`). For dead-code detection, whitelist test files or dynamic code paths.
- What if I already use some of these rules individually (e.g., phpstan/phpstan-strict-rules)?
- The wrapper bundles these rules but won’t conflict if they’re already installed. However, it may duplicate dependencies. Audit your `composer.json` to avoid bloat. Use `composer why-not wyrihaximus/phpstan-rules-wrapper` to check for overlaps.
- Can I use this in a monorepo with multiple Laravel projects?
- Yes. The wrapper standardizes rules across repositories. Install it in each project’s `composer.json` and configure `.phpstan.neon` identically. This ensures consistent static analysis, though you may need to adjust rules per project.
- What’s the alternative if I don’t want to use this wrapper?
- Install the rules individually via Composer (e.g., `phpstan/phpstan-strict-rules`, `symplify/phpstan-extensions`). However, this requires manual configuration and maintenance. The wrapper simplifies adoption by bundling 10+ rules with zero setup.