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 3131use PHPStan \Reflection \Type \UnresolvedPropertyPrototypeReflection ;
3232use PHPStan \ShouldNotHappenException ;
3333use PHPStan \TrinaryLogic ;
34+ use PHPStan \Type \Accessory \AccessoryNonEmptyStringType ;
35+ use PHPStan \Type \Accessory \AccessoryNumericStringType ;
3436use PHPStan \Type \Constant \ConstantArrayType ;
3537use PHPStan \Type \Constant \ConstantBooleanType ;
3638use PHPStan \Type \Constant \ConstantStringType ;
@@ -593,6 +595,14 @@ public function toFloat(): Type
593595
594596 public function toString (): Type
595597 {
598+ if ($ this ->isInstanceOf ('BcMath\Number ' )->yes ()) {
599+ return new IntersectionType ([
600+ new StringType (),
601+ new AccessoryNumericStringType (),
602+ new AccessoryNonEmptyStringType (),
603+ ]);
604+ }
605+
596606 $ classReflection = $ this ->getClassReflection ();
597607 if ($ classReflection === null ) {
598608 return new ErrorType ();
@@ -673,7 +683,10 @@ public function toArrayKey(): Type
673683
674684 public function toBoolean (): BooleanType
675685 {
676- if ($ this ->isInstanceOf ('SimpleXMLElement ' )->yes ()) {
686+ if (
687+ $ this ->isInstanceOf ('SimpleXMLElement ' )->yes ()
688+ || $ this ->isInstanceOf ('BcMath\Number ' )->yes ()
689+ ) {
677690 return new BooleanType ();
678691 }
679692
Original file line number Diff line number Diff line change @@ -195,6 +195,10 @@ private static function findTestFiles(): iterable
195195 yield __DIR__ . '/../Rules/Comparison/data/bug-9499.php ' ;
196196 }
197197
198+ if (PHP_VERSION_ID >= 80400 ) {
199+ yield __DIR__ . '/../Rules/Operators/data/bcmath-number.php ' ;
200+ }
201+
198202 yield __DIR__ . '/../Rules/PhpDoc/data/bug-8609-function.php ' ;
199203 yield __DIR__ . '/../Rules/Comparison/data/bug-5365.php ' ;
200204 yield __DIR__ . '/../Rules/Comparison/data/bug-6551.php ' ;
You can’t perform that action at this time.
0 commit comments