Skip to content

Commit

Permalink
isSuperTypeOf() returns IsSuperTypeOfResult
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Nov 14, 2024
1 parent 91239bd commit 7c2e0e4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/DoctrineReflection/DoctrineResultObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Result;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Type\IsSuperTypeOfResult;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;

Expand Down Expand Up @@ -51,10 +52,10 @@ public function equals(Type $type): bool
return parent::equals($type);
}

public function isSuperTypeOf(Type $type): TrinaryLogic
public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
{
if ($type instanceof self) {
return TrinaryLogic::createFromBoolean(
return IsSuperTypeOfResult::createFromBoolean(
$type->rowType !== null
&& $this->rowType !== null
&& $type->rowType->equals($this->rowType)
Expand Down
5 changes: 3 additions & 2 deletions src/DoctrineReflection/DoctrineStatementObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Statement;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Type\IsSuperTypeOfResult;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;

Expand Down Expand Up @@ -51,10 +52,10 @@ public function equals(Type $type): bool
return parent::equals($type);
}

public function isSuperTypeOf(Type $type): TrinaryLogic
public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
{
if ($type instanceof self) {
return TrinaryLogic::createFromBoolean(
return IsSuperTypeOfResult::createFromBoolean(
$type->rowType !== null
&& $this->rowType !== null
&& $type->rowType->equals($this->rowType)
Expand Down
5 changes: 3 additions & 2 deletions src/MysqliReflection/MysqliResultObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace staabm\PHPStanDba\MysqliReflection;

use PHPStan\TrinaryLogic;
use PHPStan\Type\IsSuperTypeOfResult;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;

Expand Down Expand Up @@ -40,10 +41,10 @@ public function equals(Type $type): bool
return parent::equals($type);
}

public function isSuperTypeOf(Type $type): TrinaryLogic
public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
{
if ($type instanceof self) {
return TrinaryLogic::createFromBoolean(
return IsSuperTypeOfResult::createFromBoolean(
$type->rowType !== null
&& $this->rowType !== null
&& $type->rowType->equals($this->rowType)
Expand Down
5 changes: 3 additions & 2 deletions src/PdoReflection/PdoStatementObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerRangeType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\IsSuperTypeOfResult;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
Expand Down Expand Up @@ -165,10 +166,10 @@ public function equals(Type $type): bool
return parent::equals($type);
}

public function isSuperTypeOf(Type $type): TrinaryLogic
public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
{
if ($type instanceof self) {
return TrinaryLogic::createFromBoolean(
return IsSuperTypeOfResult::createFromBoolean(
$type->fetchType !== null
&& $type->bothType !== null
&& $this->bothType !== null
Expand Down
2 changes: 1 addition & 1 deletion src/QueryReflection/QueryReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function isResolvable(Expr $queryExpr, Scope $scope): TrinaryLogic
}
$isStringOrMixed = $type->isSuperTypeOf(new StringType());

return $isStringOrMixed->negate();
return $isStringOrMixed->negate()->result;
}

/**
Expand Down

0 comments on commit 7c2e0e4

Please sign in to comment.