| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This file is part of the Nette Framework (https://nette.org) |
| 5 |
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) |
| 6 |
*/ |
| 7 |
declare (strict_types=1); |
| 8 |
namespace Packetery\Nette\PhpGenerator; |
| 9 |
|
| 10 |
use Packetery\Nette; |
| 11 |
/** |
| 12 |
* Class property description. |
| 13 |
* |
| 14 |
* @property mixed $value |
| 15 |
*/ |
| 16 |
final class Property |
| 17 |
{ |
| 18 |
use \Packetery\Nette\SmartObject; |
| 19 |
use Traits\NameAware; |
| 20 |
use Traits\VisibilityAware; |
| 21 |
use Traits\CommentAware; |
| 22 |
use Traits\AttributeAware; |
| 23 |
/** @var mixed */ |
| 24 |
private $value; |
| 25 |
/** @var bool */ |
| 26 |
private $static = \false; |
| 27 |
/** @var string|null */ |
| 28 |
private $type; |
| 29 |
/** @var bool */ |
| 30 |
private $nullable = \false; |
| 31 |
/** @var bool */ |
| 32 |
private $initialized = \false; |
| 33 |
/** @return static */ |
| 34 |
public function setValue($val) : self |
| 35 |
{ |
| 36 |
$this->value = $val; |
| 37 |
$this->initialized = \true; |
| 38 |
return $this; |
| 39 |
} |
| 40 |
public function &getValue() |
| 41 |
{ |
| 42 |
return $this->value; |
| 43 |
} |
| 44 |
/** @return static */ |
| 45 |
public function setStatic(bool $state = \true) : self |
| 46 |
{ |
| 47 |
$this->static = $state; |
| 48 |
return $this; |
| 49 |
} |
| 50 |
public function isStatic() : bool |
| 51 |
{ |
| 52 |
return $this->static; |
| 53 |
} |
| 54 |
/** @return static */ |
| 55 |
public function setType(?string $type) : self |
| 56 |
{ |
| 57 |
if ($type && $type[0] === '?') { |
| 58 |
$type = \substr($type, 1); |
| 59 |
$this->nullable = \true; |
| 60 |
} |
| 61 |
$this->type = $type; |
| 62 |
return $this; |
| 63 |
} |
| 64 |
public function getType() : ?string |
| 65 |
{ |
| 66 |
return $this->type; |
| 67 |
} |
| 68 |
/** @return static */ |
| 69 |
public function setNullable(bool $state = \true) : self |
| 70 |
{ |
| 71 |
$this->nullable = $state; |
| 72 |
return $this; |
| 73 |
} |
| 74 |
public function isNullable() : bool |
| 75 |
{ |
| 76 |
return $this->nullable; |
| 77 |
} |
| 78 |
/** @return static */ |
| 79 |
public function setInitialized(bool $state = \true) : self |
| 80 |
{ |
| 81 |
$this->initialized = $state; |
| 82 |
return $this; |
| 83 |
} |
| 84 |
public function isInitialized() : bool |
| 85 |
{ |
| 86 |
return $this->initialized || $this->value !== null; |
| 87 |
} |
| 88 |
} |
| 89 |
|