diff --git a/src/Type/StaticType.php b/src/Type/StaticType.php index c379e5b873..21cf102515 100644 --- a/src/Type/StaticType.php +++ b/src/Type/StaticType.php @@ -399,6 +399,15 @@ public function toBoolean(): BooleanType public function traverse(callable $cb): Type { + $subtractedType = $this->subtractedType !== null ? $cb($this->subtractedType) : null; + + if ($subtractedType !== $this->subtractedType) { + return new self( + $this->classReflection, + $subtractedType, + ); + } + return $this; } diff --git a/src/Type/ThisType.php b/src/Type/ThisType.php index 004b5137a3..5a5b00e554 100644 --- a/src/Type/ThisType.php +++ b/src/Type/ThisType.php @@ -57,6 +57,20 @@ public function changeSubtractedType(?Type $subtractedType): Type return $type; } + public function traverse(callable $cb): Type + { + $subtractedType = $this->getSubtractedType() !== null ? $cb($this->getSubtractedType()) : null; + + if ($subtractedType !== $this->getSubtractedType()) { + return new self( + $this->getClassReflection(), + $subtractedType, + ); + } + + return $this; + } + /** * @param mixed[] $properties */