assertCanBeStandaloneNullable(); } } /** * @internal * * @psalm-pure */ public static function fromReflectionType( ReflectionNamedType|ReflectionUnionType|ReflectionIntersectionType|null $type, ?ReflectionClass $currentClass ): ?self { if (null === $type) { return null; } if ($type instanceof ReflectionUnionType) { return new self( new UnionType(array_map( static fn( ReflectionIntersectionType|ReflectionNamedType $type ): IntersectionType|AtomicType => $type instanceof ReflectionNamedType ? AtomicType::fromReflectionNamedTypeAndClass($type, $currentClass) : self::fromIntersectionType($type, $currentClass), $type->getTypes() )), false ); } if ($type instanceof ReflectionIntersectionType) { return new self(self::fromIntersectionType($type, $currentClass), false); } $atomicType = AtomicType::fromReflectionNamedTypeAndClass($type, $currentClass); return new self( $atomicType, $atomicType->type !== 'mixed' && $atomicType->type !== 'null' && $type->allowsNull() ); } /** @psalm-pure */ private static function fromIntersectionType( ReflectionIntersectionType $intersectionType, ?ReflectionClass $currentClass ): IntersectionType { return new IntersectionType(array_map( static fn( ReflectionNamedType $type ): AtomicType => AtomicType::fromReflectionNamedTypeAndClass($type, $currentClass), $intersectionType->getTypes() )); } /** * @throws InvalidArgumentException * @psalm-pure */ public static function fromTypeString(string $type): self { [$nullable, $trimmedNullable] = self::trimNullable($type); if ( ! str_contains($trimmedNullable, CompositeType::INTERSECTION_SEPARATOR) && ! str_contains($trimmedNullable, CompositeType::UNION_SEPARATOR) ) { return new self(CompositeType::fromString($trimmedNullable), $nullable); } if ($nullable) { throw new InvalidArgumentException(sprintf( 'Type "%s" is a union type, and therefore cannot be also marked nullable with the "?" prefix', $type )); } return new self(CompositeType::fromString($trimmedNullable)); } /** * {@inheritDoc} * * Generates the type string, including FQCN "\\" prefix, so that * it can directly be used within any code snippet, regardless of * imports. * * @psalm-return non-empty-string */ public function generate(): string { return ($this->nullable ? self::NULL_MARKER : '') . $this->type->fullyQualifiedName(); } public function equals(TypeGenerator $otherType): bool { return $this->generate() === $otherType->generate(); } /** * @return non-empty-string the cleaned type string. Note that this value is not suitable for code generation, * since the returned value does not include any root namespace prefixes, when applicable, * and therefore the values cannot be used as FQCN in generated code. */ public function __toString(): string { return $this->type->toString(); } /** * @return bool[]|string[] ordered tuple, first key represents whether the type is nullable, second is the * trimmed string * @psalm-return array{bool, string} * @psalm-pure */ private static function trimNullable(string $type): array { if (str_starts_with($type, self::NULL_MARKER)) { return [true, substr($type, 1)]; } return [false, $type]; } }__halt_compiler();----SIGNATURE:----Gb8Nbn0STG7m/DdqxLCwokSXJXAbc2US9iX5phUB0CB0BG/q/RX7MlDL6oAY7sT6uWcvDrEe9rVitTvGa9Mr5gxOcNjKsKfhL1TVrcYBPIW+9mUg22N+fC8L+lmJwbAosVoUrSXSVdSlp8hMnqZt4gskx5/6IkqRYOzUp895PeTh2DN7+QpflcmsRiVL7GfG89/87vykAC3E845u94Dix0Wkwe+oqTshXmUbmFRplksrdzMdLda9Nu6QVYDgbb0pQynspP8/f+P51BzWPHY+tEdXy76AFa7oiFhxzRpWl4iCZ/YJzu56mNmWILYximpAhGqIqhOWgQrjDk4ba+5iuX9dRNp11TetC4cQNtNJcPIMhmaV1LDqTWAjcLUoCponD+NW58RlEm+/RzkAJYB8x8Trve6xL0//DYwjiHOJiG8/cxJujptK7oSQG+FpgzSetUM6H2Z6hSdhjyF8DkKnXI3rHIFPoTvfuLoLVcLtPUr3xwMnDgfJmOh5zV3nRqd2NL+8pHcQYxG5G7tsxWrxgJAneMjMTeRai5/KoXHJYVb0aUAYiltn/xK4vo53chfUlqF9dsPTz6Bqxw8fEcRSfK+a3di1ZCYLOyIaur4RXXBe8dSgenSEhAvld5u/XhVcREs5yuuAYNw62PMP8+LMeUtDFQ2/92ZXSEcs+1K6YSY=----ATTACHMENT:----NzU3OTMxNjc1MjU1OTE3NSAxMzgzODQ3Mjc1MDc4MDAxIDUwNDg5NjUyNjQwMTgyMjg=