1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Simplify assertion when mixed

This commit is contained in:
Matt Brown 2021-01-11 17:44:57 -05:00 committed by Daniil Gentili
parent d31dc663b9
commit 7665778b56
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 8 additions and 0 deletions

View File

@ -83,6 +83,10 @@ class TArray extends \Psalm\Type\Atomic
public function getAssertionString(): string public function getAssertionString(): string
{ {
if ($this->type_params[1]->isMixed()) {
return 'array';
}
return 'array<' return 'array<'
. $this->type_params[0]->getAssertionString() . ', ' . $this->type_params[1]->getAssertionString() . $this->type_params[0]->getAssertionString() . ', ' . $this->type_params[1]->getAssertionString()
. '>' ; . '>' ;

View File

@ -192,6 +192,10 @@ class TList extends \Psalm\Type\Atomic
public function getAssertionString(): string public function getAssertionString(): string
{ {
if ($this->type_param->isMixed()) {
return 'list';
}
return 'list<' . $this->type_param->getAssertionString() . '>'; return 'list<' . $this->type_param->getAssertionString() . '>';
} }