getenv() in src/). This aligns with Laravel’s evolving best practices (e.g., Symfony’s DI container, Illuminate\Contracts\Container\BindingResolutionException).NoDirectDbMutationInFunctionalTestsRector and NoDirectDispatchInFunctionalTestsRector enforce Laravel’s recommended testing practices (e.g., using HttpTestCase, DatabaseTransactions, or RefreshDatabase traits).RectorConfig::skip()).match expressions) may require Laravel 11+ for full integration.rector.php can coexist with Laravel’s phpunit.xml and composer.json scripts).// RECTOR-BAN markers), making them ideal for CI gates (e.g., GitHub Actions, GitLab CI) without breaking builds during initial adoption.config/*.php or config/*.yaml), though Laravel primarily uses PHP arrays for configs.assert(), superglobals, or getenv()) may require significant refactoring. Mitigate by:
rector process --dry-run) first.RectorConfig::skip() to exclude problematic directories (e.g., migrations/, vendor/).NoTodoCommentRector or NoCommentsOutsideInterfaceMethodDocBlockRector may clash with Laravel’s convention of using PHPDoc in controllers or service providers. Solution: Disable specific rules or adjust paths.rector.php)// RECTOR-BAN markers?composer.json?match expressions, typed properties).NoAssertInsideIfInFunctionalTestsRector) may need adjustments for match expressions.rector/rector for PHP 8.0+ migrations).phpstan-baseline can be phased out via NoPhpstanIgnoreRector).NoDirectDbMutationInFunctionalTestsRector align with Pest’s refreshDatabase() or Laravel’s DatabaseMigrations.rector process --dry-run).rector process --dry-run on main branch to identify violations.migrations/, legacy controllers).assert(), getenv()) via deprecation warnings.main if Rector fails.rector.php with comments.app/Providers/: Some providers use getenv() or superglobals for legacy config.tests/Feature/ and tests/Unit/ may need custom skips.now()/Carbon with Psr\Clock\ClockInterface (use symfony/clock or spatie/laravel-psr-clock).vendor/ directory in rector.php.RectorConfig::skip() for known problematic packages (e.g., old Laravel addons).database/migrations/ to avoid breaking existing logic.| Priority | Rule | Why | Example Laravel Impact |
|---|---|---|---|
| High | NoSuperglobalAccessRector |
Critical for DI and testability. | Replace $_ENV['APP_KEY'] with config binding. |
| High | NoPhpstanIgnoreRector |
Reduces technical debt from silenced errors. | Fix type errors instead of ignoring them. |
| High | RequirePsrClockInterfaceRector |
Future-proofs time handling (aligns with Symfony’s PSR-31). | Replace Carbon::now() with injected clock. |
| Medium | NoAssertCallInSrcRector |
Improves error visibility in production. | Replace assert() with explicit throw. |
| Medium | NoDirectDbMutationInFunctionalTestsRector |
Enforces Laravel’s testing best practices. | Use DatabaseTransactions instead of raw DB calls. |
| Low | NoCommentsOutsideInterfaceMethodDocBlockRector |
Opinionated but non-breaking. | Strip docblocks in services; keep them in interfaces. |
| Low | YamlNoCommentsRector |
Only relevant if using YAML configs (e.g., config/packages/*.yaml). |
Strip comments in third-party config files. |
NoPhpstanIgnoreRectorHow can I help you explore Laravel packages today?