roave/no-floaters
PHPStan plugin that bans floats: no float properties, parameters, return types, or assigning float values. Optional strict mode disallows any float-producing expression. Helps prevent rounding errors in domains like money, grading, or scientific calculations.
roave/no-floaters package remains a static analysis tool (PHPStan extension) for detecting IEEE-754 floating-point precision errors. Its architectural fit in Laravel/PHP ecosystems is unchanged, particularly for applications requiring strict type safety, financial/scientific calculations, or adherence to coding standards.phpstan.neon with the package’s extension.level or ignoreErrors is still required.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| False Positives | Medium | Test with a subset of math-heavy logic first. Use ignoreErrors. |
| PHPStan Version Lock | Low | Pin PHPStan version (e.g., ^1.8 or higher). |
| Legacy Codebase | High | Incremental adoption; start with non-critical modules. |
| Custom Math Libraries | Medium | Exclude vendor paths in phpstan.neon. |
| CI/CD Pipeline Breaks | Low | Run in pre-commit hooks before CI. |
| Conditional Return Types | Low | New: Improved handling of floating-point expressions in generics/conditionals may reduce false positives. Monitor for edge cases. |
| PHP 8.3 Incompatibility | High | New: Drop of PHP 8.3 support requires explicit version pinning to 8.0–8.2. |
brianium/paradoxx).level (unchanged).phpstan.neon.roave/no-floaters to composer.json:
composer require --dev roave/no-floaters
phpstan.neon (unchanged).| Failure Mode | Impact | Detection/Recovery |
|---|---|---|
| PHP 8.3 Incompatibility | High | Downgrade to PHP 8.0–8.2 or update package if PHP 8.3 is used. |
| False Positives | Medium | Test subsets; use ignoreErrors. |
| CI/CD Pipeline Breaks | Low | Run pre-commit hooks. |
| Configuration Drift | Medium | Document and review phpstan.neon regularly. |
| Conditional Type Errors | Low | New: Monitor for false positives in complex generics/conditionals. |
| PHPUnit v13 Issues | Medium | New: Test suite compatibility checks; update tests if needed. |
How can I help you explore Laravel packages today?