Skip to content

Commit 150f511

Browse files
nanasessclaude
andcommitted
refactor(bcround): Remove unsupported RoundingMode implementations
Remove version-dependent support for TowardsZero, AwayFromZero, and NegativeInfinity RoundingMode enums. These modes now consistently throw ValueError with clear error messages across all PHP versions, preparing for future proper implementation. Changes: - Update convertRoundingMode() to throw ValueError for unsupported modes - Remove PHP version checks for these specific modes - Update all related test cases to expect ValueError exceptions - Improve test coverage for supported modes (HalfAwayFromZero, HalfTowardsZero, HalfEven, HalfOdd) - Add comprehensive enum compatibility tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 442eb87 commit 150f511

File tree

2 files changed

+260
-103
lines changed

2 files changed

+260
-103
lines changed

src/BCMath.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,15 +1015,10 @@ private static function convertRoundingMode($mode): int
10151015
\RoundingMode::HalfTowardsZero => PHP_ROUND_HALF_DOWN,
10161016
\RoundingMode::HalfEven => PHP_ROUND_HALF_EVEN,
10171017
\RoundingMode::HalfOdd => PHP_ROUND_HALF_ODD,
1018-
\RoundingMode::TowardsZero => version_compare(PHP_VERSION, '8.4', '>=')
1019-
? PHP_ROUND_HALF_DOWN
1020-
: throw new \ValueError('RoundingMode::TowardsZero is not supported in PHP < 8.4'),
1021-
\RoundingMode::AwayFromZero => version_compare(PHP_VERSION, '8.4', '>=')
1022-
? PHP_ROUND_HALF_UP
1023-
: throw new \ValueError('RoundingMode::AwayFromZero is not supported in PHP < 8.4'),
1024-
\RoundingMode::NegativeInfinity => version_compare(PHP_VERSION, '8.4', '>=')
1025-
? PHP_ROUND_HALF_DOWN
1026-
: throw new \ValueError('RoundingMode::NegativeInfinity is not supported in PHP < 8.4'),
1018+
// TODO: Support additional modes if needed
1019+
\RoundingMode::NegativeInfinity => throw new \ValueError('RoundingMode::NegativeInfinity is not supported'),
1020+
\RoundingMode::TowardsZero => throw new \ValueError('RoundingMode::TowardsZero is not supported'),
1021+
\RoundingMode::AwayFromZero => throw new \ValueError('RoundingMode::AwayFromZero is not supported'), // @phpstan-ignore-line
10271022
default => throw new \ValueError('Unsupported RoundingMode')
10281023
};
10291024
}

0 commit comments

Comments
 (0)