Skip to content

Commit

Permalink
IntersectionType - support tryRemove
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 22, 2022
1 parent 68e6443 commit 6bc1fb5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Type/IntersectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use PHPStan\Type\Generic\TemplateType;
use PHPStan\Type\Generic\TemplateTypeMap;
use PHPStan\Type\Generic\TemplateTypeVariance;
use PHPStan\Type\Traits\NonRemoveableTypeTrait;
use function array_map;
use function count;
use function implode;
Expand All @@ -35,8 +34,6 @@
class IntersectionType implements CompoundType
{

use NonRemoveableTypeTrait;

/** @var Type[] */
private array $types;

Expand Down Expand Up @@ -557,6 +554,11 @@ public function traverse(callable $cb): Type
return $this;
}

public function tryRemove(Type $typeToRemove): ?Type
{
return $this->intersectTypes(static fn (Type $type): Type => TypeCombinator::remove($type, $typeToRemove));
}

/**
* @param mixed[] $properties
*/
Expand Down

0 comments on commit 6bc1fb5

Please sign in to comment.