Skip to content

Commit

Permalink
getType(), getReturnType(): added option $asObject that returns Nette…
Browse files Browse the repository at this point in the history
…\Utils\Type

(requires nette/utils 3.2.5)
  • Loading branch information
dg committed Sep 23, 2021
1 parent 3405e81 commit 9b79d3c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/PhpGenerator/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Nette\PhpGenerator;

use Nette;
use Nette\Utils\Type;


/**
Expand Down Expand Up @@ -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;
}


Expand Down
10 changes: 8 additions & 2 deletions src/PhpGenerator/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Nette\PhpGenerator;

use Nette;
use Nette\Utils\Type;


/**
Expand Down Expand Up @@ -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;
}


Expand Down
10 changes: 8 additions & 2 deletions src/PhpGenerator/Traits/FunctionLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Nette;
use Nette\PhpGenerator\Dumper;
use Nette\PhpGenerator\Parameter;
use Nette\Utils\Type;


/**
Expand Down Expand Up @@ -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;
}


Expand Down

0 comments on commit 9b79d3c

Please sign in to comment.