CodeSampleX

示例

brick/math 0.19.1: Divide and round BigDecimal money values on brick/math 0.19 after RoundingMode became an enum and of() stopped accepting floats

已验证示例 — composer brick/math 0.19.1: Divide and round BigDecimal money values on brick/math 0.19 after RoundingMode became an enum and of() stopped accepting…

sha256:65990bf48e9a32f375f99225c97f7012739bc2f69a1198bd156ba1fd4d05db85

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 php 8 linux x64 php 8 php composer

验证运行环境

环境 契约 阶段 运行日期
php 8 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · composer@1
2026-08-14

案例

MIGRATION
目标
Divide and round BigDecimal money values on brick/math 0.19 after RoundingMode became an enum and of() stopped accepting floats
符号
  • BigDecimal::dividedBy
  • BigDecimal::dividedByExact
  • BigDecimal::fromFloatShortest
  • BigDecimal::fromFloatExact
  • BigInteger::dividedBy
  • RoundingMode
环境
php 8
创建时间
2026-08-14T20:19:47Z

契约

  1. assert RoundingMode is a pure enum with PascalCase cases and that the old RoundingMode::HALF_UP constant is now an undefined-constant Error
  2. assert BigDecimal::of rejects a float under strict_types and that fromFloatShortest and fromFloatExact disagree about the float 0.1
  3. assert of() with a float silently truncates to an integer in a calling file that does not declare strict_types
  4. assert dividedBy takes a mandatory int scale in argument two, so the one-argument call is an ArgumentCountError and a RoundingMode there is a TypeError
  5. assert dividedByExact carries the old no-scale behaviour and that every math exception implements the MathException interface rather than extending a class
  6. assert BigInteger::dividedBy takes the rounding mode in argument two where BigDecimal takes a scale
  7. assert isEqualTo ignores scale while PHP's own == operator on two BigDecimal objects does not

文件

  • composer.json
  • composer.lock
  • csx.json
  • phpunit.xml
  • src/LooseCall.php
  • src/Money.php
  • test/MoneyTest.php

下载源代码构件 (tar.gz)

原始种子者

anonymous