Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
No Floaters

No Floaters Laravel Package

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.

View on GitHub
Deep Wiki
Context7

:mag_right: static analysis rules to prevent IEEE-754 floating point errors

Frequently asked questions about No Floaters
How does roave/no-floaters integrate with Laravel’s dependency management?
This package is a PHPStan extension, not a Composer plugin, so it doesn’t directly manage dependencies. Instead, it scans your codebase during static analysis to flag `float` types in properties, methods, or assignments. Use it alongside Laravel’s `composer.lock` to ensure reproducible builds by avoiding floating-point precision issues in critical logic.
Will this break existing Laravel apps using floats (e.g., Carbon timestamps, Eloquent decimals)?
Yes, it will flag floats in properties, methods, or assignments. For Laravel-specific cases like Carbon timestamps or Eloquent decimal fields, exclude vendor paths in `phpstan.neon` or use `ignoreErrors` for those lines. Focus enforcement on custom business logic where precision matters.
Does roave/no-floaters support Laravel 7 or older versions?
Officially, it requires PHPStan 1.0+ and PHP 8.0–8.2, which aligns with Laravel 8+. For Laravel 7 or older, you’d need to manually install PHPStan (e.g., via `composer require --dev phpstan/phpstan`) and configure it separately, but this isn’t recommended due to compatibility risks.
How do I configure it to ignore floats in specific files or classes?
Add `ignoreErrors: true` to your `phpstan.neon` for entire files or use `#phpstan-ignore-next-line` comments above problematic lines. For broader exclusions, list paths under `excludePaths` in the config. Example: `excludePaths: [vendor/, tests/Unit/FloatTests.php]`.
Can I use this in CI/CD pipelines for Laravel Forge/Sail deployments?
Absolutely. Add it to your CI workflow (e.g., GitHub Actions, GitLab CI) as a static analysis step before testing. For Forge/Sail, run it in a pre-deploy hook or as part of your `phpunit.xml` setup. Expect minor CI slowdowns (~5–15%) due to PHPStan’s overhead.
What alternatives exist for handling floating-point precision in Laravel?
For financial/scientific apps, consider libraries like `brianium/paradoxx` (decimal arithmetic) or `ramsey/uuid` for IDs. For Laravel-specific needs, use Eloquent’s `decimal` columns or Carbon’s `createFromFormat` with strings. This package is best for enforcing strict float-free coding standards.
How do I test if roave/no-floaters catches all precision issues in my Laravel app?
Start by running it on a subset of math-heavy logic (e.g., payment calculations, scientific models) with `phpstan analyse --level 7`. Compare results with manual tests for edge cases like `(0.7 + 0.1) === 0.8`. Gradually expand coverage, excluding vendor paths where needed.
Will this package slow down my Laravel application in production?
No, this is a static analysis tool with zero runtime impact. It only runs during development or CI. The performance cost is negligible in production, but CI/CD pipelines may see slight slowdowns (~5–15%) due to PHPStan’s analysis.
How do I handle third-party libraries that use floats (e.g., Laravel’s Carbon or Symfony components)?
Exclude vendor paths in `phpstan.neon` by adding `excludePaths: [vendor/]`. For libraries you control, refactor to avoid floats or use `ignoreErrors`. Document these exclusions in your team’s static analysis guidelines.
Does roave/no-floaters work with PHP 8.3, or should I stick to PHP 8.2?
This package currently supports PHP 8.0–8.2. PHP 8.3 compatibility isn’t guaranteed, so pin your PHP version to `^8.2` in `composer.json` to avoid issues. If you must use PHP 8.3, test thoroughly or consider alternatives like `brianium/paradoxx` for decimal arithmetic.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager