diff options
Diffstat (limited to 'vendor/vimeo/psalm/src/Psalm/Type/Atomic/HasIntersectionTrait.php')
-rw-r--r-- | vendor/vimeo/psalm/src/Psalm/Type/Atomic/HasIntersectionTrait.php | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/vendor/vimeo/psalm/src/Psalm/Type/Atomic/HasIntersectionTrait.php b/vendor/vimeo/psalm/src/Psalm/Type/Atomic/HasIntersectionTrait.php deleted file mode 100644 index 4174319..0000000 --- a/vendor/vimeo/psalm/src/Psalm/Type/Atomic/HasIntersectionTrait.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php - -namespace Psalm\Type\Atomic; - -use Psalm\Codebase; -use Psalm\Internal\Type\TemplateResult; -use Psalm\Internal\Type\TemplateStandinTypeReplacer; -use Psalm\Type\Atomic; - -use function array_map; -use function implode; - -trait HasIntersectionTrait -{ - /** - * @var array<string, TNamedObject|TTemplateParam|TIterable|TObjectWithProperties>|null - */ - public $extra_types; - - /** - * @param array<lowercase-string, string> $aliased_classes - */ - private function getNamespacedIntersectionTypes( - ?string $namespace, - array $aliased_classes, - ?string $this_class, - bool $use_phpdoc_format - ): string { - if (!$this->extra_types) { - return ''; - } - - return '&' . implode( - '&', - array_map( - /** - * @param TNamedObject|TTemplateParam|TIterable|TObjectWithProperties $extra_type - * - * @return string - */ - function (Atomic $extra_type) use ( - $namespace, - $aliased_classes, - $this_class, - $use_phpdoc_format - ): string { - return $extra_type->toNamespacedString( - $namespace, - $aliased_classes, - $this_class, - $use_phpdoc_format - ); - }, - $this->extra_types - ) - ); - } - - /** - * @param TNamedObject|TTemplateParam|TIterable|TObjectWithProperties $type - */ - public function addIntersectionType(Atomic $type): void - { - $this->extra_types[$type->getKey()] = $type; - } - - /** - * @return array<string, TNamedObject|TTemplateParam|TIterable|TObjectWithProperties>|null - */ - public function getIntersectionTypes(): ?array - { - return $this->extra_types; - } - - public function replaceIntersectionTemplateTypesWithArgTypes( - TemplateResult $template_result, - ?Codebase $codebase - ): void { - if (!$this->extra_types) { - return; - } - - $new_types = []; - - foreach ($this->extra_types as $extra_type) { - if ($extra_type instanceof TTemplateParam - && isset($template_result->lower_bounds[$extra_type->param_name][$extra_type->defining_class]) - ) { - $template_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( - $template_result->lower_bounds[$extra_type->param_name][$extra_type->defining_class], - $codebase - ); - - foreach ($template_type->getAtomicTypes() as $template_type_part) { - if ($template_type_part instanceof TNamedObject) { - $new_types[$template_type_part->getKey()] = clone $template_type_part; - } elseif ($template_type_part instanceof TTemplateParam) { - $new_types[$template_type_part->getKey()] = clone $template_type_part; - } - } - } else { - $extra_type->replaceTemplateTypesWithArgTypes($template_result, $codebase); - $new_types[$extra_type->getKey()] = $extra_type; - } - } - - $this->extra_types = $new_types; - } -} |