Support for BcMath\Number objects#121
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #121 +/- ##
============================================
+ Coverage 99.00% 99.04% +0.04%
- Complexity 142 159 +17
============================================
Files 15 16 +1
Lines 402 421 +19
============================================
+ Hits 398 417 +19
Misses 4 4 ☔ View full report in Codecov by Sentry. |
| @@ -1,5 +1,10 @@ | |||
| parameters: | |||
| level: 10 | |||
| phpVersion: 80402 | |||
There was a problem hiding this comment.
Without this setting, PHPStan would report BcMath\Number as an unknown class and we would lose type coverage for the new NumberComparator class.
There was a problem hiding this comment.
I just updated PHPStan to version 2.1.1 on main. Maybe that solves this?
There was a problem hiding this comment.
No. PHPStan 2.0.1 does already know about the Number class, so upgrading to 2.1.1 doesn't change anything for me.
The problem is that PHPStan needs a target PHP version for its analysis. If we don't set it here, it will guess it from the composer.json file and assume PHP 8.2.0 because of this setting:
Lines 41 to 43 in 07ba41d
The Number class simply does not exist on PHP 8.2 yet, so PHPStan technically correct when complaining about this.
There was a problem hiding this comment.
BC Number support is tracked here: phpstan/phpstan#12099
There was a problem hiding this comment.
@staabm That's for the overloaded operators only which is a different issue. Once the issue you've linked is resolved, I can remove the one ignored error from the PHPStan configuration file.
73d4b3e to
4146077
Compare
BCMath\Number objects
BCMath\Number objectsBcMath\Number objects
4146077 to
dcff245
Compare
|
I've rebased the PR to make the CI run with the updated tools. |
|
@derrabus Thank you! Do you think |
This PR adds support for the new
BcMath\Numbervalue objects (php/php-src#13741). It allows comparing two numbers as well as comparing a number to an integer or a numeric string. The goal is to make the following assertions pass in PHPUnit:The PR also allows to compare to numbers with a delta.