Skip to content

Commit 9588c08

Browse files
authored
Merge branch 'main' into dependabot/github_actions/peter-evans/find-comment-4
2 parents cde2847 + 17e54d0 commit 9588c08

18 files changed

Lines changed: 279 additions & 88 deletions

.github/workflows/benchmark-manual.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
strategy:
4040
matrix:
41-
php-version: ['8.1', '8.2', '8.3', '8.4']
41+
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
4242

4343
name: PHP ${{ matrix.php-version }} Benchmark
4444

@@ -136,7 +136,7 @@ jobs:
136136
137137
- name: Post results to PR
138138
if: github.event_name == 'workflow_dispatch' && github.event.inputs.post_comment == 'true' && github.event.inputs.pr_number
139-
uses: actions/github-script@v7
139+
uses: actions/github-script@v8
140140
with:
141141
script: |
142142
const fs = require('fs');

.github/workflows/benchmark-on-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
echo "EOF" >> $GITHUB_OUTPUT
9797
9898
- name: Post benchmark results to PR
99-
uses: actions/github-script@v7
99+
uses: actions/github-script@v8
100100
with:
101101
script: |
102102
const fs = require('fs');

.github/workflows/benchmark-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
- name: Fetch PR details for comment trigger
4848
if: github.event_name == 'issue_comment'
49-
uses: actions/github-script@v7
49+
uses: actions/github-script@v8
5050
id: pr_details
5151
with:
5252
script: |
@@ -152,7 +152,7 @@ jobs:
152152
# to avoid issues with multiline strings
153153
154154
- name: Create or update comment
155-
uses: peter-evans/create-or-update-comment@v4
155+
uses: peter-evans/create-or-update-comment@v5
156156
with:
157157
comment-id: ${{ steps.fc.outputs.comment-id }}
158158
issue-number: ${{ steps.pr.outputs.number }}

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
fail-fast: false
5555
matrix:
5656
os: [ubuntu-latest, windows-latest, macos-latest]
57-
php-version: ['8.1', '8.2', '8.3', '8.4']
57+
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
5858

5959
tests-without-bcmath:
6060
name: Tests (without BCMath extension)
@@ -76,7 +76,7 @@ jobs:
7676
strategy:
7777
fail-fast: false
7878
matrix:
79-
php-version: ['8.1', '8.2', '8.3', '8.4']
79+
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
8080

8181
docker-phpt-tests:
8282
name: Docker PHPT Tests
@@ -96,8 +96,9 @@ jobs:
9696
- name: Run Docker-based PHPT tests
9797
run: |
9898
# scale_ini test skipped: bcmath.scale INI setting ignored without native extension
99-
docker run --rm -v $PWD:/app bcmath-phpt-test:${{ matrix.php-version }} --skip bcdivmod,bug54598,bug72093,bug75178,gh15968,gh16262,scale_ini,bcmul_check_overflow,bug78878,bcpow_error1,bcpow_error2,bcpow_error3,bcpowmod_error,bcpowmod_with_mod_1,bcpowmod_zero_modulus,bcround_all,bcround_away_from_zero,bcround_ceiling,bcround_early_return,bcround_floor,bcround_toward_zero,bcscale_variation003,bcdivmod_by_zero
99+
# gh20006 test skipped: requires BcMath\Number OOP API (not supported by polyfill)
100+
docker run --rm -v $PWD:/app bcmath-phpt-test:${{ matrix.php-version }} --skip bcdivmod,bug54598,bug72093,bug75178,gh15968,gh16262,scale_ini,bcmul_check_overflow,bug78878,bcpow_error1,bcpow_error2,bcpow_error3,bcpowmod_error,bcpowmod_with_mod_1,bcpowmod_zero_modulus,bcround_all,bcround_away_from_zero,bcround_ceiling,bcround_early_return,bcround_floor,bcround_toward_zero,bcscale_variation003,bcdivmod_by_zero,gh20006
100101
strategy:
101102
fail-fast: false
102103
matrix:
103-
php-version: ['8.1', '8.2', '8.3', '8.4']
104+
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']

.github/workflows/claude-code-review.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Claude Code Review
22

33
on:
44
pull_request:
5-
types: [opened, synchronize]
5+
types: [opened, synchronize, ready_for_review, reopened]
66
# Optional: Only run on specific file changes
77
# paths:
88
# - "src/**/*.ts"
@@ -36,18 +36,9 @@ jobs:
3636
uses: anthropics/claude-code-action@v1
3737
with:
3838
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39-
prompt: |
40-
Please review this pull request and provide feedback on:
41-
- Code quality and best practices
42-
- Potential bugs or issues
43-
- Performance considerations
44-
- Security concerns
45-
- Test coverage
46-
47-
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
48-
49-
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
50-
39+
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
40+
plugins: 'code-review@claude-code-plugins'
41+
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
5142
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
52-
# or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
53-
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
43+
# or https://code.claude.com/docs/en/cli-reference for available options
44+

.github/workflows/claude.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ on:
1313
jobs:
1414
claude:
1515
if: |
16-
github.repository_owner == github.actor &&
17-
(
18-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
19-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
20-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
21-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
22-
)
16+
github.repository_owner == github.actor &&
17+
(
18+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
19+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
21+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
22+
)
2323
runs-on: ubuntu-latest
2424
permissions:
2525
contents: read
@@ -48,5 +48,6 @@ jobs:
4848

4949
# Optional: Add claude_args to customize behavior and configuration
5050
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
51-
# or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
52-
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
51+
# or https://code.claude.com/docs/en/cli-reference for available options
52+
# claude_args: '--allowed-tools Bash(gh pr *)'
53+

.php-cs-fixer.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
'@PhpCsFixer:risky' => true,
2323
'native_function_invocation' => false,
2424
'php_unit_test_case_static_method_calls' => false,
25+
// Tests verify implicit int/bool→string coercion matching the native bcmath
26+
// extension, so enforcing strict types would break intentional compatibility checks.
27+
'declare_strict_types' => false,
2528
])
2629
->setFinder($finder)
2730
;

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
## 🚀 Features
1818

1919
- ✅ Complete bcmath extension polyfill for PHP 8.1+
20-
- ✅ Supports all PHP 8.4 bcmath functions including `bcfloor()`, `bcceil()`, and `bcround()`
20+
- ✅ Supports all PHP 8.4+ bcmath functions including `bcfloor()`, `bcceil()`, and `bcround()`
21+
- ✅ PHP 8.5 compatibility tested and verified
2122
- ✅ Zero dependencies in production (uses phpseclib for arbitrary precision math)
2223
- ✅ Seamless fallback when bcmath extension is not available
2324
- ✅ 100% compatible with native bcmath functions
@@ -165,7 +166,7 @@ Automatically runs when PRs are merged to main:
165166
#### 3. Manual Benchmarks
166167
Trigger via GitHub Actions UI:
167168
- Customizable iteration count
168-
- Multi-PHP version testing (8.1, 8.2, 8.3, 8.4)
169+
- Multi-PHP version testing (8.1, 8.2, 8.3, 8.4, 8.5)
169170
- Results saved as artifacts
170171

171172
### Performance Considerations
@@ -219,7 +220,7 @@ While the polyfill is significantly slower than native bcmath:
219220
| **PHP 8.2+ deprecations** | ⚠️ Warnings | ✅ Fixed |
220221
| **Test suite pollution** | ⚠️ Issues | ✅ Fixed |
221222
| **Active maintenance** | ❌ Limited | ✅ Active |
222-
| **CI/CD (PHP versions)** | GitHub Actions (8.1, 8.2, 8.3) | GitHub Actions (8.1, 8.2, 8.3, 8.4) |
223+
| **CI/CD (PHP versions)** | GitHub Actions (8.1, 8.2, 8.3) | GitHub Actions (8.1, 8.2, 8.3, 8.4, 8.5) |
223224

224225
### Migration from phpseclib/bcmath_compat
225226

@@ -281,7 +282,7 @@ docker run --rm bcmath-phpt-test --help
281282
- `--help, -h` - Show usage information
282283

283284
#### Supported PHP Versions
284-
- PHP 8.1, 8.2, 8.3, 8.4
285+
- PHP 8.1, 8.2, 8.3, 8.4, 8.5
285286

286287
The Docker PHPT tests automatically run on GitHub Actions CI across all supported PHP versions to ensure comprehensive compatibility with the official PHP core bcmath test suite.
287288

lib/RoundingMode.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
*
1010
* The enum is only defined if:
1111
* - PHP version is 8.1 or higher (enum support)
12-
* - Native RoundingMode enum doesn't already exist (PHP < 8.4)
12+
* - No class/enum named RoundingMode is already declared in the global namespace.
13+
* Since PHP 8.1 `class_exists()` returns true for enums too, this single check
14+
* covers both the native PHP 8.4+ RoundingMode enum and the Rector 2.4+
15+
* scoped polyfill that exposes a class via class_alias.
1316
*/
14-
// @phpstan-ignore-next-line
15-
if (!enum_exists('RoundingMode') && version_compare(PHP_VERSION, '8.1', '>=')) {
17+
// The version_compare check is defensive runtime safety. composer.json constrains
18+
// PHP to >=8.1, so PHPStan always infers this as always-true; silence that.
19+
// @phpstan-ignore-next-line booleanAnd.rightAlwaysTrue
20+
if (!class_exists('RoundingMode', false) && version_compare(PHP_VERSION, '8.1', '>=')) {
1621
enum RoundingMode: string
1722
{
1823
case HalfAwayFromZero = 'half_away_from_zero';

lib/bcmath.php

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,117 +36,97 @@
3636
/**
3737
* Add two arbitrary precision numbers.
3838
*
39-
* @param string $left_operand
40-
* @param string $right_operand
4139
* @param null|int $scale optional
4240
*/
43-
function bcadd($left_operand, $right_operand, $scale = null): string
41+
function bcadd(string $left_operand, string $right_operand, ?int $scale = null): string
4442
{
4543
return BCMath::add($left_operand, $right_operand, $scale);
4644
}
4745

4846
/**
4947
* Compare two arbitrary precision numbers.
5048
*
51-
* @param string $left_operand
52-
* @param string $right_operand
5349
* @param null|int $scale optional
5450
*/
55-
function bccomp($left_operand, $right_operand, $scale = null): int
51+
function bccomp(string $left_operand, string $right_operand, ?int $scale = null): int
5652
{
5753
return BCMath::comp($left_operand, $right_operand, $scale);
5854
}
5955

6056
/**
6157
* Divide two arbitrary precision numbers.
6258
*
63-
* @param string $dividend
64-
* @param string $divisor
6559
* @param null|int $scale optional
6660
*/
67-
function bcdiv($dividend, $divisor, $scale = null): string
61+
function bcdiv(string $dividend, string $divisor, ?int $scale = null): string
6862
{
6963
return BCMath::div($dividend, $divisor, $scale);
7064
}
7165

7266
/**
7367
* Get modulus of an arbitrary precision number.
7468
*
75-
* @param string $dividend
76-
* @param string $divisor
7769
* @param null|int $scale optional
7870
*/
79-
function bcmod($dividend, $divisor, $scale = null): string
71+
function bcmod(string $dividend, string $divisor, ?int $scale = null): string
8072
{
8173
return BCMath::mod($dividend, $divisor, $scale);
8274
}
8375

8476
/**
8577
* Multiply two arbitrary precision numbers.
8678
*
87-
* @param string $dividend
88-
* @param string $divisor
8979
* @param null|int $scale optional
9080
*/
91-
function bcmul($dividend, $divisor, $scale = null): string
81+
function bcmul(string $dividend, string $divisor, ?int $scale = null): string
9282
{
9383
return BCMath::mul($dividend, $divisor, $scale);
9484
}
9585

9686
/**
9787
* Raise an arbitrary precision number to another.
9888
*
99-
* @param string $base
100-
* @param string $exponent
10189
* @param null|int $scale optional
10290
*/
103-
function bcpow($base, $exponent, $scale = null): string
91+
function bcpow(string $num, string $exponent, ?int $scale = null): string
10492
{
105-
return BCMath::pow($base, $exponent, $scale);
93+
return BCMath::pow($num, $exponent, $scale);
10694
}
10795

10896
/**
10997
* Raise an arbitrary precision number to another, reduced by a specified modulus.
11098
*
111-
* @param string $base
112-
* @param string $exponent
113-
* @param string $modulus
11499
* @param null|int $scale optional
115100
*/
116-
function bcpowmod($base, $exponent, $modulus, $scale = null): string
101+
function bcpowmod(string $num, string $exponent, string $modulus, ?int $scale = null): string
117102
{
118-
return BCMath::powmod($base, $exponent, $modulus, $scale);
103+
return BCMath::powmod($num, $exponent, $modulus, $scale);
119104
}
120105

121106
/**
122107
* Set or get default scale parameter for all bc math functions.
123-
*
124-
* @param null|int $scale
125108
*/
126-
function bcscale($scale = null): ?int
109+
function bcscale(?int $scale = null): ?int
127110
{
128111
return BCMath::scale($scale);
129112
}
130113

131114
/**
132115
* Get the square root of an arbitrary precision number.
133116
*
134-
* @param string $operand
135117
* @param null|int $scale optional
136118
*/
137-
function bcsqrt($operand, $scale = null): string
119+
function bcsqrt(string $operand, ?int $scale = null): string
138120
{
139121
return BCMath::sqrt($operand, $scale);
140122
}
141123

142124
/**
143125
* Subtract one arbitrary precision number from another.
144126
*
145-
* @param string $left_operand
146-
* @param string $right_operand
147127
* @param null|int $scale optional
148128
*/
149-
function bcsub($left_operand, $right_operand, $scale = null): string
129+
function bcsub(string $left_operand, string $right_operand, ?int $scale = null): string
150130
{
151131
return BCMath::sub($left_operand, $right_operand, $scale);
152132
}
@@ -155,10 +135,8 @@ function bcsub($left_operand, $right_operand, $scale = null): string
155135
if (!function_exists('bcfloor')) {
156136
/**
157137
* Round down to the nearest integer (PHP 8.4+).
158-
*
159-
* @param string $operand
160138
*/
161-
function bcfloor($operand): string
139+
function bcfloor(string $operand): string
162140
{
163141
return BCMath::floor($operand);
164142
}
@@ -167,10 +145,8 @@ function bcfloor($operand): string
167145
if (!function_exists('bcceil')) {
168146
/**
169147
* Round up to the nearest integer (PHP 8.4+).
170-
*
171-
* @param string $operand
172148
*/
173-
function bcceil($operand): string
149+
function bcceil(string $operand): string
174150
{
175151
return BCMath::ceil($operand);
176152
}
@@ -180,11 +156,10 @@ function bcceil($operand): string
180156
/**
181157
* Round to a given decimal place (PHP 8.4+).
182158
*
183-
* @param string $operand
184159
* @param int $precision optional
185160
* @param int $mode optional
186161
*/
187-
function bcround($operand, $precision = 0, $mode = PHP_ROUND_HALF_UP): string
162+
function bcround(string $operand, int $precision = 0, $mode = PHP_ROUND_HALF_UP): string
188163
{
189164
return BCMath::round($operand, $precision, $mode);
190165
}

0 commit comments

Comments
 (0)