File tree Expand file tree Collapse file tree 4 files changed +483
-465
lines changed Expand file tree Collapse file tree 4 files changed +483
-465
lines changed Original file line number Diff line number Diff line change 31
31
use PHPStan \Reflection \Type \UnresolvedPropertyPrototypeReflection ;
32
32
use PHPStan \ShouldNotHappenException ;
33
33
use PHPStan \TrinaryLogic ;
34
+ use PHPStan \Type \Accessory \AccessoryNonEmptyStringType ;
35
+ use PHPStan \Type \Accessory \AccessoryNumericStringType ;
34
36
use PHPStan \Type \Constant \ConstantArrayType ;
35
37
use PHPStan \Type \Constant \ConstantBooleanType ;
36
38
use PHPStan \Type \Constant \ConstantStringType ;
@@ -593,6 +595,14 @@ public function toFloat(): Type
593
595
594
596
public function toString (): Type
595
597
{
598
+ if ($ this ->isInstanceOf ('BcMath\Number ' )->yes ()) {
599
+ return new IntersectionType ([
600
+ new StringType (),
601
+ new AccessoryNumericStringType (),
602
+ new AccessoryNonEmptyStringType (),
603
+ ]);
604
+ }
605
+
596
606
$ classReflection = $ this ->getClassReflection ();
597
607
if ($ classReflection === null ) {
598
608
return new ErrorType ();
@@ -673,7 +683,10 @@ public function toArrayKey(): Type
673
683
674
684
public function toBoolean (): BooleanType
675
685
{
676
- if ($ this ->isInstanceOf ('SimpleXMLElement ' )->yes ()) {
686
+ if (
687
+ $ this ->isInstanceOf ('SimpleXMLElement ' )->yes ()
688
+ || $ this ->isInstanceOf ('BcMath\Number ' )->yes ()
689
+ ) {
677
690
return new BooleanType ();
678
691
}
679
692
Original file line number Diff line number Diff line change @@ -195,6 +195,10 @@ private static function findTestFiles(): iterable
195
195
yield __DIR__ . '/../Rules/Comparison/data/bug-9499.php ' ;
196
196
}
197
197
198
+ if (PHP_VERSION_ID >= 80400 ) {
199
+ yield __DIR__ . '/../Rules/Operators/data/bcmath-number.php ' ;
200
+ }
201
+
198
202
yield __DIR__ . '/../Rules/PhpDoc/data/bug-8609-function.php ' ;
199
203
yield __DIR__ . '/../Rules/Comparison/data/bug-5365.php ' ;
200
204
yield __DIR__ . '/../Rules/Comparison/data/bug-6551.php ' ;
You can’t perform that action at this time.
0 commit comments