1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Prophecy. |
5
|
|
|
* (c) Konstantin Kudryashov <[email protected]> |
6
|
|
|
* Marcello Duarte <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Prophecy\Doubler\Generator\Node; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Argument node. |
16
|
|
|
* |
17
|
|
|
* @author Konstantin Kudryashov <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class ArgumentNode |
20
|
|
|
{ |
21
|
|
|
private $name; |
22
|
|
|
private $typeHint; |
23
|
|
|
private $default; |
24
|
|
|
private $optional = false; |
25
|
|
|
private $byReference = false; |
26
|
|
|
private $isVariadic = false; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param string $name |
30
|
|
|
*/ |
31
|
|
|
public function __construct($name) |
32
|
|
|
{ |
33
|
|
|
$this->name = $name; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getName() |
37
|
|
|
{ |
38
|
|
|
return $this->name; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getTypeHint() |
42
|
|
|
{ |
43
|
|
|
return $this->typeHint; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function setTypeHint($typeHint = null) |
47
|
|
|
{ |
48
|
|
|
$this->typeHint = $typeHint; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function hasDefault() |
52
|
|
|
{ |
53
|
|
|
return $this->isOptional() && !$this->isVariadic(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getDefault() |
57
|
|
|
{ |
58
|
|
|
return $this->default; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function setDefault($default = null) |
62
|
|
|
{ |
63
|
|
|
$this->optional = true; |
64
|
|
|
$this->default = $default; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function isOptional() |
68
|
|
|
{ |
69
|
|
|
return $this->optional; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function setAsPassedByReference($byReference = true) |
73
|
|
|
{ |
74
|
|
|
$this->byReference = $byReference; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function isPassedByReference() |
78
|
|
|
{ |
79
|
|
|
return $this->byReference; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function setAsVariadic($isVariadic = true) |
83
|
|
|
{ |
84
|
|
|
$this->isVariadic = $isVariadic; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function isVariadic() |
88
|
|
|
{ |
89
|
|
|
return $this->isVariadic; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|