* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class Php extends GeneratorAbstract { public function getDocType(TypeInterface $type): string { if ($type instanceof ArrayType) { $items = $type->getItems(); if ($items instanceof TypeInterface) { return 'array<' . $this->getDocType($items) . '>'; } else { return 'array'; } } elseif ($type instanceof MapType) { $additionalProperties = $type->getAdditionalProperties(); if ($additionalProperties instanceof TypeInterface) { return '\\' . Record::class . '<' . $this->getDocType($additionalProperties) . '>'; } else { return '\\' . Record::class; } } elseif ($type instanceof StringType && $type->getFormat() === TypeAbstract::FORMAT_BINARY) { return 'resource'; } elseif ($type instanceof UnionType) { $parts = []; foreach ($type->getOneOf() as $item) { $parts[] = $this->getDocType($item); } return implode('|', $parts); } elseif ($type instanceof IntersectionType) { $parts = []; foreach ($type->getAllOf() as $item) { $parts[] = $this->getDocType($item); } return implode('&', $parts); } elseif ($type instanceof GenericType) { return $type->getGeneric() ?? ''; } elseif ($type instanceof AnyType) { return 'mixed'; } else { return $this->getType($type); } } protected function getDate(): string { return '\\' . Date::class; } protected function getDateTime(): string { return '\\' . \DateTime::class; } protected function getTime(): string { return '\\' . Time::class; } protected function getDuration(): string { return '\\' . \DateInterval::class; } protected function getUri(): string { return '\\' . Uri::class; } protected function getBinary(): string { return ''; } protected function getString(): string { return 'string'; } protected function getInteger(): string { return 'int'; } protected function getNumber(): string { return 'float'; } protected function getBoolean(): string { return 'bool'; } protected function getArray(string $type): string { return 'array'; } protected function getMap(string $type): string { return '\\' . Record::class; } protected function getUnion(array $types): string { if (PHP_MAJOR_VERSION >= 8) { return implode('|', $types); } else { return ''; } } protected function getIntersection(array $types): string { return ''; } protected function getGroup(string $type): string { return '(' . $type . ')'; } protected function getGeneric(array $types): string { return ''; } protected function getAny(): string { return ''; } protected function getNamespaced(string $namespace, string $name): string { return '\\' . $namespace . '\\' . $name; } } __halt_compiler();----SIGNATURE:----fPb10sGiLDfdSsJTFtVSVxzpNI9kZ3Ea9ZCDgM2rxXRVMP46bkSXfVP+L+dPBq1jAf+ZEfci8gs0WlHd8tQf43u1qkaK05JhaytDysnQr4hUSR0L2lYC/67cOxJxJOhqcgiRA77L/7aAI3Y6AQFL0YBM6H/9dETNF9Di5HkwM6BmjEeJ3/DRM3OaK17mjjCbyOXl76jYUCw5TgVZH0Tgpzm8s9owRV4eREnOx0HScejyGUR/ojWIH3OunLdzA/PWWBr8QQqUoSdQf7Ighs5VP+/GyPze2gpsaYWGGfuXBa2yYwM4qEZJgx1FTBZ+JU85xAmLqOCzYyKLdxTiuWBHBGE76619cZrd3r1kFqrAP7+XpxzFsMhLC9E3UXRfS+O9HGdqVIHeXnAT8LpH/r9V9G68g11fZulOQCO7cZaT/dIYD+fUZ2pJgCn8jPZHsW/LnFX78P0QytdoZRTjhvVxWZ5oCP78AN9z0u18AJgXsCVlApOstRrKhiXqXrWahk+7ZfjxmJHvDeGETWlo9xynI280MFDnOupLPQcoMSKO5q8FpSG478v2MwbrHzmzdRbV2isr0S479qR/OPIUM42FUxdjJofnvl8mg4sRDHmUCBj6XMrwU5xapz0vTtUlJ9gHZzZCX835Vd4063ttBWlXefjHGLaorD8YpSFqnQFRq+U=----ATTACHMENT:----Njk0NTIzNTg5NTU4NjM5NyAyNDUyODY1NDE5MTg4MDggMzk2ODUyODIzMTU5MDAwMA==