diff --git a/src/PhpGenerator/Parameter.php b/src/PhpGenerator/Parameter.php index 98f4fe01..9300cf09 100644 --- a/src/PhpGenerator/Parameter.php +++ b/src/PhpGenerator/Parameter.php @@ -10,6 +10,7 @@ namespace Nette\PhpGenerator; use Nette; +use Nette\Utils\Type; /** @@ -61,9 +62,14 @@ public function setType(?string $type): self } - public function getType(): ?string + /** + * @return Type|string|null + */ + public function getType(bool $asObject = false) { - return $this->type; + return $asObject && $this->type + ? Type::fromString($this->type) + : $this->type; } diff --git a/src/PhpGenerator/Property.php b/src/PhpGenerator/Property.php index f5ed5abf..04c95e50 100644 --- a/src/PhpGenerator/Property.php +++ b/src/PhpGenerator/Property.php @@ -10,6 +10,7 @@ namespace Nette\PhpGenerator; use Nette; +use Nette\Utils\Type; /** @@ -81,9 +82,14 @@ public function setType(?string $type): self } - public function getType(): ?string + /** + * @return Type|string|null + */ + public function getType(bool $asObject = false) { - return $this->type; + return $asObject && $this->type + ? Type::fromString($this->type) + : $this->type; } diff --git a/src/PhpGenerator/Traits/FunctionLike.php b/src/PhpGenerator/Traits/FunctionLike.php index 2c6a49b6..f446bd8b 100644 --- a/src/PhpGenerator/Traits/FunctionLike.php +++ b/src/PhpGenerator/Traits/FunctionLike.php @@ -12,6 +12,7 @@ use Nette; use Nette\PhpGenerator\Dumper; use Nette\PhpGenerator\Parameter; +use Nette\Utils\Type; /** @@ -130,9 +131,14 @@ public function setReturnType(?string $type): self } - public function getReturnType(): ?string + /** + * @return Type|string|null + */ + public function getReturnType(bool $asObject = false) { - return $this->returnType; + return $asObject && $this->returnType + ? Type::fromString($this->returnType) + : $this->returnType; }