Skip to content

Commit

Permalink
Merge pull request #23 from ergebnis/feature/constant
Browse files Browse the repository at this point in the history
Enhancement: Use `PHP_FLOAT_EPSILON`
  • Loading branch information
localheinz authored Jan 24, 2022
2 parents 053949b + 128106b commit 1f6fb03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For a full diff see [`1.0.0...main`][1.0.0...main].
### Changed

- Dropped support for PHP 7.3 ([#21]), by [@localheinz]
- Started using `PHP_FLOAT_EPSILON` instead of `0.1` in `FloatProvider` ([#23]), by [@localheinz]

## [`1.0.0`][1.0.0]

Expand Down
3 changes: 3 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
</MoreSpecificReturnType>
</file>
<file src="src/FloatProvider.php">
<InvalidOperand occurrences="1">
<code>-1 * \PHP_FLOAT_EPSILON</code>
</InvalidOperand>
<MoreSpecificReturnType occurrences="7">
<code>\Generator&lt;string, array{0: float}&gt;</code>
<code>\Generator&lt;string, array{0: float}&gt;</code>
Expand Down
4 changes: 2 additions & 2 deletions src/FloatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ private static function values(): array
$faker = self::faker();

return [
'float-less-than-minus-one' => -0.01 - $faker->randomFloat(null, 1),
'float-less-than-minus-one' => (-1 * \PHP_FLOAT_EPSILON) - $faker->randomFloat(null, 1),
'float-minus-one' => -1.0,
'float-zero' => 0.0,
'float-plus-one' => 1.0,
'float-greater-than-plus-one' => 0.01 + $faker->randomFloat(null, 1),
'float-greater-than-plus-one' => \PHP_FLOAT_EPSILON + $faker->randomFloat(null, 1),
];
}
}

0 comments on commit 1f6fb03

Please sign in to comment.