From 07fcf5399c95be68446b2afa89627ee90388e5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Fri, 14 Apr 2023 21:25:37 +0200 Subject: [PATCH] qa: mark `TTypeAlias#extra_types` and `TTypeAlias#setIntersectionTypes` as deprecated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the way how this patch modifies the type alias handling, intersection types of aliases are directly expanded and thus, the referencing types are being used rather than intersecting aliases. Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/Psalm/Internal/Type/TypeExpander.php | 1 + src/Psalm/Type/Atomic/TTypeAlias.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/Psalm/Internal/Type/TypeExpander.php b/src/Psalm/Internal/Type/TypeExpander.php index 13e635032..e329f92b6 100644 --- a/src/Psalm/Internal/Type/TypeExpander.php +++ b/src/Psalm/Internal/Type/TypeExpander.php @@ -324,6 +324,7 @@ class TypeExpander ]; } + /** @psalm-suppress DeprecatedProperty For backwards compatibility, we have to keep this here. */ foreach ($return_type->extra_types ?? [] as $alias) { $more_recursively_fleshed_out_types = self::expandAtomic( $codebase, diff --git a/src/Psalm/Type/Atomic/TTypeAlias.php b/src/Psalm/Type/Atomic/TTypeAlias.php index f8ed8013b..e15c442c2 100644 --- a/src/Psalm/Type/Atomic/TTypeAlias.php +++ b/src/Psalm/Type/Atomic/TTypeAlias.php @@ -14,6 +14,9 @@ final class TTypeAlias extends Atomic { /** * @var array|null + * @deprecated type aliases are resolved within {@see TypeParser::resolveTypeAliases()} and therefore the + * referencing type(s) are part of other intersection types. The intersection types are not set anymore + * and with v6 this property along with its related methods will get removed. */ public $extra_types; @@ -30,14 +33,19 @@ final class TTypeAlias extends Atomic { $this->declaring_fq_classlike_name = $declaring_fq_classlike_name; $this->alias_name = $alias_name; + /** @psalm-suppress DeprecatedProperty For backwards compatibility, we have to keep this here. */ $this->extra_types = $extra_types; parent::__construct(true); } /** * @param array|null $extra_types + * @deprecated type aliases are resolved within {@see TypeParser::resolveTypeAliases()} and therefore the + * referencing type(s) are part of other intersection types. This method will get removed with v6. + * @psalm-suppress PossiblyUnusedMethod For backwards compatibility, we have to keep this here. */ public function setIntersectionTypes(?array $extra_types): self { + /** @psalm-suppress DeprecatedProperty For backwards compatibility, we have to keep this here. */ if ($extra_types === $this->extra_types) { return $this; } @@ -55,6 +63,7 @@ final class TTypeAlias extends Atomic public function getId(bool $exact = true, bool $nested = false): string { + /** @psalm-suppress DeprecatedProperty For backwards compatibility, we have to keep this here. */ if ($this->extra_types) { return $this->getKey() . '&' . implode( '&',