refactor(bcmath): 浮動小数点演算をbcmath関数に置換#6557
Open
nanasess wants to merge 6 commits intoEC-CUBE:4.3-symfony7from
Open
refactor(bcmath): 浮動小数点演算をbcmath関数に置換#6557nanasess wants to merge 6 commits intoEC-CUBE:4.3-symfony7from
nanasess wants to merge 6 commits intoEC-CUBE:4.3-symfony7from
Conversation
金額・ポイント・数量の計算処理において、浮動小数点演算の精度問題を 回避するためbcmath関数を使用するよう修正。 - PointProcessor: ポイント比較・加算にbccomp/bcaddを使用 - OrderStateMachine: ポイント加算・減算にbcadd/bcsubを使用 - DeliveryController: 支払条件の計算にbcsub/bcaddを使用 - CartController: カート数量の合計にbcaddを使用 - OrderType: 支払金額の比較にbccompを使用 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
以下のファイルで数量・金額計算をbcmath関数に変更: - ShippingMultipleController: bcadd を使用(4箇所) - AdminController: bcadd を使用(売上集計) - DeliveryFeeFreeByShippingPreprocessor: bcadd/bcmul を使用 - StockDiffProcessor: bcadd を使用 - ShippingMultipleItemType: bcadd を使用 - EntryController: bcadd を使用 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- StockDiffProcessor: getDiffOfQuantitiesの演算をbcsub/bcmulに置換 - StockDiffProcessor: getQuantityByProductClassのPHPDoc型を修正 - AdminController: getPaymentTotal()に(string)キャスト追加 - CartController: 金額計算をbcsub/bcaddに置換 - ShippingMultipleController: bcadd引数に(string)キャスト追加 - PointProcessor: getTotal()の冗長な(string)キャストを削除 - PurchaseFlow: reduce内の冗長な(string)キャストを削除 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bcadd()はstringを返すため、返り値の型宣言をintからstringに変更 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.3-symfony7 #6557 +/- ##
================================================
- Coverage 82.33% 82.29% -0.04%
================================================
Files 482 482
Lines 25691 25691
================================================
- Hits 21152 21142 -10
- Misses 4539 4549 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要(Overview・Refs Issue)
金額・ポイント・数量の計算処理において、浮動小数点演算の精度問題を回避するためbcmath関数を使用するよう修正しました。
対象ファイル:
方針(Policy)
PHPの浮動小数点演算では精度の問題が発生する可能性があります。金額やポイントなど正確な計算が必要な箇所でbcmath関数を使用することで、この問題を回避します。
既存のコードで
// @phpstan-ignore-line TODO bcmath-polyfill を使用するというコメントがあった箇所を中心に修正しています。実装に関する補足(Appendix)
bcmath関数の使用方法:
bccomp($a, $b): 比較(戻り値: -1, 0, 1)bcadd($a, $b): 加算bcsub($a, $b): 減算bcmul($a, $b): 乗算コミット履歴
7b305b928a- refactor(bcmath): 浮動小数点演算をbcmath関数に置換3fc19f2c10- refactor(bcmath): 追加の浮動小数点演算をbcmath関数に置換4903f18a05- refactor(bcmath): getDiffOfQuantities等の追加bcmath対応とphp-cs-fixer/rector適用テスト(Test)
相談(Discussion)
特になし
マイナーバージョン互換性保持のための制限事項チェックリスト
🤖 Generated with Claude Code