1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

qa: mark TTypeAlias#extra_types and TTypeAlias#setIntersectionTypes as deprecated

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>
This commit is contained in:
Maximilian Bösing 2023-04-14 21:25:37 +02:00
parent c3f91992f1
commit 07fcf5399c
No known key found for this signature in database
GPG Key ID: 9A8988C93CEC81A3
2 changed files with 10 additions and 0 deletions

View File

@ -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,

View File

@ -14,6 +14,9 @@ final class TTypeAlias extends Atomic
{
/**
* @var array<string, TTypeAlias>|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<string, TTypeAlias>|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(
'&',