-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Parameter.php
96 lines (69 loc) · 1.56 KB
/
Parameter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
declare(strict_types=1);
namespace Nette\PhpGenerator;
use Nette\Utils\Type;
/**
* Function/Method parameter description.
*/
class Parameter
{
use Traits\NameAware;
use Traits\AttributeAware;
use Traits\CommentAware;
private bool $reference = false;
private ?string $type = null;
private bool $nullable = false;
private bool $hasDefaultValue = false;
private mixed $defaultValue = null;
public function setReference(bool $state = true): static
{
$this->reference = $state;
return $this;
}
public function isReference(): bool
{
return $this->reference;
}
public function setType(?string $type): static
{
$this->type = Helpers::validateType($type, $this->nullable);
return $this;
}
/** @return ($asObject is true ? ?Type : ?string) */
public function getType(bool $asObject = false): Type|string|null
{
return $asObject && $this->type
? Type::fromString($this->type)
: $this->type;
}
public function setNullable(bool $state = true): static
{
$this->nullable = $state;
return $this;
}
public function isNullable(): bool
{
return $this->nullable;
}
public function setDefaultValue(mixed $val): static
{
$this->defaultValue = $val;
$this->hasDefaultValue = true;
return $this;
}
public function getDefaultValue(): mixed
{
return $this->defaultValue;
}
public function hasDefaultValue(): bool
{
return $this->hasDefaultValue;
}
public function validate(): void
{
}
}