Skip to content

Commit

Permalink
CompoundTypeHelper is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 11, 2021
1 parent 1b48f43 commit fff85f3
Show file tree
Hide file tree
Showing 20 changed files with 22 additions and 26 deletions.
3 changes: 1 addition & 2 deletions src/Type/Accessory/AccessoryLiteralStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use PHPStan\TrinaryLogic;
use PHPStan\Type\BooleanType;
use PHPStan\Type\CompoundType;
use PHPStan\Type\CompoundTypeHelper;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\ErrorType;
Expand Down Expand Up @@ -47,7 +46,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
return TrinaryLogic::createNo();
}
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return $type->isLiteralString();
Expand Down
3 changes: 1 addition & 2 deletions src/Type/Accessory/AccessoryNonEmptyStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPStan\TrinaryLogic;
use PHPStan\Type\CompoundType;
use PHPStan\Type\CompoundTypeHelper;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\ErrorType;
Expand Down Expand Up @@ -44,7 +43,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return $type->isNonEmptyString();
Expand Down
3 changes: 1 addition & 2 deletions src/Type/Accessory/AccessoryNumericStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPStan\TrinaryLogic;
use PHPStan\Type\CompoundType;
use PHPStan\Type\CompoundTypeHelper;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\ErrorType;
Expand Down Expand Up @@ -44,7 +43,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return $type->isNumericString();
Expand Down
3 changes: 1 addition & 2 deletions src/Type/Accessory/HasOffsetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPStan\TrinaryLogic;
use PHPStan\Type\CompoundType;
use PHPStan\Type\CompoundTypeHelper;
use PHPStan\Type\ConstantScalarType;
use PHPStan\Type\ErrorType;
use PHPStan\Type\IntersectionType;
Expand Down Expand Up @@ -49,7 +48,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return $type->isOffsetAccessible()
Expand Down
3 changes: 1 addition & 2 deletions src/Type/Accessory/NonEmptyArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPStan\TrinaryLogic;
use PHPStan\Type\CompoundType;
use PHPStan\Type\CompoundTypeHelper;
use PHPStan\Type\Constant\ConstantFloatType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\ErrorType;
Expand Down Expand Up @@ -40,7 +39,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return $type->isArray()
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

if ($type instanceof ConstantArrayType) {
Expand Down
2 changes: 1 addition & 1 deletion src/Type/CallableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType && !$type instanceof self) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return $this->isSuperTypeOfInternal($type, true);
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ClosureType.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

if (!$type instanceof ClosureType) {
Expand Down
3 changes: 3 additions & 0 deletions src/Type/CompoundTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use PHPStan\TrinaryLogic;

/**
* @deprecated
*/
class CompoundTypeHelper
{

Expand Down
3 changes: 1 addition & 2 deletions src/Type/Generic/TemplateTypeParameterStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPStan\TrinaryLogic;
use PHPStan\Type\CompoundType;
use PHPStan\Type\CompoundTypeHelper;
use PHPStan\Type\Type;

/**
Expand All @@ -16,7 +15,7 @@ class TemplateTypeParameterStrategy implements TemplateTypeStrategy
public function accepts(TemplateType $left, Type $right, bool $strictTypes): TrinaryLogic
{
if ($right instanceof CompoundType) {
return CompoundTypeHelper::accepts($right, $left, $strictTypes);
return $right->isAcceptedBy($left, $strictTypes);
}

return $left->getBound()->accepts($right, $strictTypes);
Expand Down
2 changes: 1 addition & 1 deletion src/Type/IntegerRangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return TrinaryLogic::createNo();
Expand Down
2 changes: 1 addition & 1 deletion src/Type/IterableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return TrinaryLogic::createNo();
Expand Down
2 changes: 1 addition & 1 deletion src/Type/JustNullableTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return TrinaryLogic::createNo();
Expand Down
2 changes: 1 addition & 1 deletion src/Type/NullType.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return TrinaryLogic::createNo();
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

if ($type instanceof ClosureType) {
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ObjectWithoutClassType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getReferencedClasses(): array
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return TrinaryLogic::createFromBoolean(
Expand Down
2 changes: 1 addition & 1 deletion src/Type/StaticType.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getBaseClass(): string
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
{
if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

if (!$type instanceof static) {
Expand Down
2 changes: 1 addition & 1 deletion src/Type/StringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

if ($type instanceof TypeWithClassName && !$strictTypes) {
Expand Down
3 changes: 1 addition & 2 deletions src/Type/Traits/ConstantScalarTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPStan\TrinaryLogic;
use PHPStan\Type\CompoundType;
use PHPStan\Type\CompoundTypeHelper;
use PHPStan\Type\ConstantScalarType;
use PHPStan\Type\GeneralizePrecision;
use PHPStan\Type\Type;
Expand All @@ -19,7 +18,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

return TrinaryLogic::createNo();
Expand Down
2 changes: 1 addition & 1 deletion src/Type/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
}

if ($type instanceof CompoundType && !$type instanceof CallableType) {
return CompoundTypeHelper::accepts($type, $this, $strictTypes);
return $type->isAcceptedBy($this, $strictTypes);
}

$results = [];
Expand Down

0 comments on commit fff85f3

Please sign in to comment.