diff --git a/src/Generator/Php.php b/src/Generator/Php.php index 6f3e83d6..ced3b20a 100644 --- a/src/Generator/Php.php +++ b/src/Generator/Php.php @@ -93,6 +93,10 @@ protected function writeStruct(Code\Name $name, array $properties, ?string $exte $tags['template'] = $generics; } + if (!empty($templates)) { + $tags['extends'] = $extends . $this->generator->getGenericType($templates); + } + $uses = []; $class = $this->factory->class($name->getClass()); @@ -109,9 +113,6 @@ protected function writeStruct(Code\Name $name, array $properties, ?string $exte } if (!empty($extends)) { - if (!empty($templates)) { - $extends.= $this->generator->getGenericType($templates); - } $class->extend($extends); } diff --git a/src/Generator/Type/Php.php b/src/Generator/Type/Php.php index a7967a92..ed3d30c3 100644 --- a/src/Generator/Type/Php.php +++ b/src/Generator/Type/Php.php @@ -123,7 +123,7 @@ protected function getGroup(string $type): string protected function getGeneric(array $types): string { - return ''; + return '<' . implode(', ', $types) . '>'; } protected function getAny(): string diff --git a/tests/Generator/resource/php/php_oop.php b/tests/Generator/resource/php/php_oop.php index 2368e562..8612a696 100644 --- a/tests/Generator/resource/php/php_oop.php +++ b/tests/Generator/resource/php/php_oop.php @@ -102,6 +102,9 @@ public function jsonSerialize() : object } } +/** + * @extends Map + */ class StudentMap extends Map implements \JsonSerializable, \PSX\Record\RecordableInterface { }