{"id":13828386,"url":"https://github.com/Roave/no-floaters","last_synced_at":"2025-07-09T06:31:43.897Z","repository":{"id":46246769,"uuid":"164595831","full_name":"Roave/no-floaters","owner":"Roave","description":":mag_right: static analysis rules to prevent IEEE-754 floating point errors","archived":false,"fork":false,"pushed_at":"2025-07-04T10:39:37.000Z","size":1273,"stargazers_count":211,"open_issues_count":3,"forks_count":12,"subscribers_count":7,"default_branch":"1.14.x","last_synced_at":"2025-07-04T11:42:23.492Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Roave.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"tidelift":"packagist/roave/no-floaters"}},"created_at":"2019-01-08T07:59:33.000Z","updated_at":"2025-07-02T05:42:19.000Z","dependencies_parsed_at":"2024-01-22T17:38:03.448Z","dependency_job_id":"ea029735-47cc-4d5a-84c0-395e61e8e828","html_url":"https://github.com/Roave/no-floaters","commit_stats":{"total_commits":219,"total_committers":13,"mean_commits":"16.846153846153847","dds":0.639269406392694,"last_synced_commit":"e0387cfd8cd5c4c82c9649579cda620986a4d91f"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/Roave/no-floaters","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roave%2Fno-floaters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roave%2Fno-floaters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roave%2Fno-floaters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roave%2Fno-floaters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Roave","download_url":"https://codeload.github.com/Roave/no-floaters/tar.gz/refs/heads/1.14.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roave%2Fno-floaters/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263507588,"owners_count":23477387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:02:44.109Z","updated_at":"2025-07-09T06:31:43.466Z","avatar_url":"https://github.com/Roave.png","language":"PHP","funding_links":["https://tidelift.com/funding/github/packagist/roave/no-floaters","https://tidelift.com/subscription/pkg/packagist-roave-no-floaters?utm_source=packagist-roave-no-floaters\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo"],"categories":["PHP"],"sub_categories":[],"readme":"# roave/no-floaters\n\n![`roave/no-floaters`](logo/roave-no-floaters.png)\n\n[![Latest Stable Version](https://poser.pugx.org/roave/no-floaters/v/stable.png)](https://packagist.org/packages/roave/no-floaters)\n\nThis library is a [PHPStan](https://github.com/phpstan/phpstan) plugin\nthat disallows:\n\n* declaration of `float` properties\n* `float` method parameters\n* `float` method return types\n* assignment of `float` values to variables or properties\n\nThe reason for this restriction is that rounding errors coming\nfrom floating point arithmetic operations are not acceptable in\ncertain business logic scenario, such as dealing with money,\nevaluating exam results, rocket science, etc.\n\nAn example of such problems can be seen with the following typical\n[example](https://3v4l.org/MJqJe):\n\n```php\nvar_dump((0.7 + 0.1) === 0.8); // output: bool(false)\n```\n\nThis can mean no trouble at all, or a lot of trouble, depending\non how many numbers you are running through your system, so it\nis advisable to avoid `float` for domains where rounding can\npotentially lead to trouble.\n\n`float` is still perfectly acceptable in many programming contexts,\nand this ruleset should only be applied where it is critical not\nto introduce rounding errors.\n\n## Installation\n\n```sh\ncomposer require --dev roave/no-floaters\n```\n\n## Configuration\n\nIn your `phpstan.neon` configuration, add following section:\n\n```neon\nincludes:\n    - vendor/roave/no-floaters/rules.neon\n```\n\nOptionally, you can configure the library to disallow any\n`float`-producing expression at all, by adding following to your\n`phpstan.neon`:\n\n```neon\nparameters:\n    disallowFloatsEverywhere: true\n```\n\nIf the above is enabled, given the following `example-file.php`\ncontents:\n\n```php\n\u003c?php\n\n$a = 1 / 3;\n```\n\nYou should get something like following:\n\n```cli\nvendor/bin/phpstan analyse example-file.php -l 7\n 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\n\n ------ -----------------------------------------------------\n  Line   example-file.php\n ------ -----------------------------------------------------\n  3      Cannot assign float to $a - floats are not allowed.\n ------ -----------------------------------------------------\n\n\n [ERROR] Found 1 error\n\n```\n\n## roave/no-floaters for enterprise\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of roave/no-floaters and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-roave-no-floaters?utm_source=packagist-roave-no-floaters\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo).\n\nIf you need help with setting up this library in your project,\nyou can contact us at \u003cteam@roave.com\u003e for consulting/support.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRoave%2Fno-floaters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRoave%2Fno-floaters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRoave%2Fno-floaters/lists"}