solido/phpstan-rules
Custom PHPStan ruleset for Solido-based projects. Adds extra static analysis for enhanced DTOs with simple phpstan.neon config to declare DTO namespaces and excluded interfaces, helping catch type and structure issues across your application.
solido/phpstan-rules package is highly specialized for enforcing Solido-specific DTO and domain-driven design (DDD) patterns within PHPStan. It bridges the gap between static analysis and architectural constraints, making it ideal for projects leveraging Solido’s enhanced DTOs, repositories, or domain layers.phpstan/extension-installer) for a modular static analysis pipeline.phpstan.neon), allowing teams to incrementally adopt or customize enforcement without modifying the package itself. Supports excluded interfaces and namespace scoping, reducing false positives.phpstan.neon to define DTO namespaces and exclusions.| Risk Category | Description | Mitigation Strategy |
|---|---|---|
| False Positives | Rules may flag legitimate dynamic behavior (e.g., magic methods, excluded interfaces). | Configure excluded_interfaces and suppress rules selectively via PHPDoc comments. |
| Rule Obsolescence | Solido’s DTO conventions may evolve, rendering rules outdated. | Monitor Solido’s release notes and update rules or configurations proactively. |
| Performance Impact | Additional rules increase static analysis time, especially for large codebases. | Benchmark with --memory-limit and --parallel flags; limit scope to critical paths. |
| Configuration Errors | Incorrect dto_namespaces or level settings may break CI/CD. |
Start with level=warning in CI, then enforce level=error after validation. |
| Limited Community | Low stars (2) and dependents (0) indicate niche adoption. | Rely on Solido’s documentation and internal testing; contribute fixes if needed. |
level=warning to gauge impact.)| Phase | Action Items | Success Criteria |
|---|---|---|
| 1. Assessment | - Audit DTO usage (namespaces, interfaces, instantiation patterns). | Identify scope of DTOs and current violations (if any). |
- Verify PHPStan setup (composer.json, phpstan.neon). |
Ensure PHPStan 1.x+ is installed and configurable. | |
| 2. Configuration | - Add solido/phpstan-rules to composer.json. |
Package installs without conflicts. |
- Configure phpstan.neon with dto_namespaces and excluded_interfaces. |
Rules detect expected DTOs without false positives. | |
| 3. Validation | - Run PHPStan locally (--level=5) to identify violations. |
No critical false positives; violations are actionable. |
- Adjust level (e.g., warning → error) incrementally. |
CI/CD fails only on intentional violations. | |
| 4. CI/CD Integration | - Add PHPStan to pre-commit hooks or pipeline. | Builds fail on violations without manual intervention. |
| 5. Enforcement | - Document rules for the team (e.g., Confluence, README). | Developers understand and comply with DTO constraints. |
| 6. Optimization | - Suppress rules for legitimate edge cases (e.g., dynamic properties). | Minimal false positives; rules add real value. |
composer.json).composer.json to avoid surprises:
"require-dev": {
"phpstan/phpstan": "^1.10",
"solido/phpstan-rules": "^1.0"
}
php.ini or Docker config if using older PHP.level=warning in CI (non-blocking).level=error for high-priority DTOs (e.g., critical APIs).How can I help you explore Laravel packages today?