Skip to content

Fix BcMath\Number increment/decrement#4957

Merged
staabm merged 1 commit intophpstan:2.1.xfrom
mpesari:bcmath-inc-dec
Feb 17, 2026
Merged

Fix BcMath\Number increment/decrement#4957
staabm merged 1 commit intophpstan:2.1.xfrom
mpesari:bcmath-inc-dec

Conversation

@mpesari
Copy link
Contributor

@mpesari mpesari commented Feb 16, 2026

Partial fix for phpstan/phpstan#13965

This adds support for BcMath\Number increment/decrement operations on PHP >= 8.4.

php > $x = new BcMath\Number('3.14');
php > print $x;
3.14
php > $x++;
php > print $x;
4.14

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x.

@mpesari mpesari force-pushed the bcmath-inc-dec branch 2 times, most recently from eded554 to c369be5 Compare February 16, 2026 17:18
Copy link
Contributor

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to target 2.1.x

@mpesari mpesari changed the base branch from 2.2.x to 2.1.x February 16, 2026 17:48
@mpesari
Copy link
Contributor Author

mpesari commented Feb 16, 2026

Rebased and targeted to 2.1.x

@mpesari
Copy link
Contributor Author

mpesari commented Feb 16, 2026

Hmm.. I wanted to make sure that we report errors on PHP < 8.4 when the polyfill is installed, but looks like the test doesn't report any errors.

@mpesari mpesari force-pushed the bcmath-inc-dec branch 2 times, most recently from 85fd9f3 to 5f4370d Compare February 17, 2026 09:03
@VincentLanglet
Copy link
Contributor

Please take a new look @staabm with the changes

@staabm
Copy link
Contributor

staabm commented Feb 17, 2026

I like the PR so far.

per https://www.php.net/manual/en/class.bcmath-number.php

A class for an arbitrary precision number. These objects support overloaded arithmetic and comparison operators.

this class also has special comparison semantics. I think it would make sense to cover both aspects in this PR.
@mpesari could you look into comparisons?

@VincentLanglet
Copy link
Contributor

I like the PR so far.

per php.net/manual/en/class.bcmath-number.php

A class for an arbitrary precision number. These objects support overloaded arithmetic and comparison operators.

this class also has special comparison semantics. I think it would make sense to cover both aspects in this PR. @mpesari could you look into comparisons?

Isn't already handled by

final class BcMathNumberOperatorTypeSpecifyingExtension implements OperatorTypeSpecifyingExtension
?

@staabm
Copy link
Contributor

staabm commented Feb 17, 2026

you are right. its covered in tests/PHPStan/Analyser/nsrt/bcmath-number.php

@staabm
Copy link
Contributor

staabm commented Feb 17, 2026

thank you @mpesari

@staabm staabm merged commit 40b3f24 into phpstan:2.1.x Feb 17, 2026
638 of 643 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants