1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
This commit is contained in:
Daniil Gentili 2022-11-26 17:44:30 +01:00
parent d0d7c46d26
commit 0f9936553f
2 changed files with 15 additions and 2 deletions

View File

@ -114,6 +114,12 @@ class TKeyedArray extends Atomic
$property_strings = [];
if ($this->is_list) {
if (count($this->properties) === 1
&& $this->properties[0]->equals($this->fallback_params[1], true, true, false)
) {
$t = $this->properties[0]->possibly_undefined ? 'list' : 'non-empty-list';
return "$t<".$this->fallback_params[1]->getId($exact).'>';
}
$use_list_syntax = true;
foreach ($this->properties as $property) {
if ($property->possibly_undefined) {
@ -179,6 +185,12 @@ class TKeyedArray extends Atomic
$suffixed_properties = [];
if ($this->is_list) {
if (count($this->properties) === 1
&& $this->properties[0]->equals($this->fallback_params[1], true, true, false)
) {
$t = $this->properties[0]->possibly_undefined ? 'list' : 'non-empty-list';
return "$t<".$this->fallback_params[1]->getId().'>';
}
$use_list_syntax = true;
foreach ($this->properties as $property) {
if ($property->possibly_undefined) {

View File

@ -1335,7 +1335,8 @@ trait UnionTrait
public function equals(
self $other_type,
bool $ensure_source_equality = true,
bool $ensure_parent_node_equality = true
bool $ensure_parent_node_equality = true,
bool $ensure_possibly_undefined_equality = true,
): bool {
if ($other_type === $this) {
return true;
@ -1349,7 +1350,7 @@ trait UnionTrait
return false;
}
if ($this->possibly_undefined !== $other_type->possibly_undefined) {
if ($this->possibly_undefined !== $other_type->possibly_undefined && $ensure_possibly_undefined_equality) {
return false;
}