Skip to content

Commit d1b3ef8

Browse files
committed
Add BcMath\Number to ObjectType
1 parent adcabb3 commit d1b3ef8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Type/ObjectType.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
3131
use PHPStan\ShouldNotHappenException;
3232
use PHPStan\TrinaryLogic;
33+
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
34+
use PHPStan\Type\Accessory\AccessoryNumericStringType;
3335
use PHPStan\Type\Constant\ConstantArrayType;
3436
use PHPStan\Type\Constant\ConstantBooleanType;
3537
use PHPStan\Type\Constant\ConstantStringType;
@@ -542,6 +544,10 @@ private function describeCache(): string
542544

543545
public function toNumber(): Type
544546
{
547+
// if ($this->isInstanceOf('BcMath\Number')->yes()) {
548+
// return $this;
549+
// }
550+
545551
if ($this->isInstanceOf('SimpleXMLElement')->yes()) {
546552
return new UnionType([
547553
new FloatType(),
@@ -580,6 +586,14 @@ public function toFloat(): Type
580586

581587
public function toString(): Type
582588
{
589+
if ($this->isInstanceOf('BcMath\Number')->yes()) {
590+
return new IntersectionType([
591+
new StringType(),
592+
new AccessoryLowercaseStringType(),
593+
new AccessoryNumericStringType(),
594+
]);
595+
}
596+
583597
$classReflection = $this->getClassReflection();
584598
if ($classReflection === null) {
585599
return new ErrorType();

0 commit comments

Comments
 (0)