|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Murtukov\PHPCodeGenerator; |
|
6
|
|
|
|
|
7
|
|
|
abstract class AbstractFunction extends DependencyAwareGenerator |
|
8
|
|
|
{ |
|
9
|
|
|
public Signature $signature; |
|
10
|
|
|
|
|
11
|
|
|
public function getReturnType(): string |
|
12
|
|
|
{ |
|
13
|
|
|
return $this->signature->getReturnType(); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
public function setReturnType(string $returnType): self |
|
17
|
|
|
{ |
|
18
|
|
|
$this->signature->setReturnType($returnType); |
|
19
|
|
|
|
|
20
|
|
|
return $this; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function getArgument(int $index = 1): ?Argument |
|
24
|
|
|
{ |
|
25
|
|
|
return $this->signature->getArgument($index); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function removeArgument(int $index): self |
|
29
|
|
|
{ |
|
30
|
|
|
$this->signature->removeArgument($index); |
|
31
|
|
|
|
|
32
|
|
|
return $this; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function removeArguments(): self |
|
36
|
|
|
{ |
|
37
|
|
|
$this->signature->removeArguments(); |
|
38
|
|
|
|
|
39
|
|
|
return $this; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function createArgument(string $name, string $type = '', $defaultValue = Argument::NO_PARAM): Argument |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->signature->createArgument($name, $type, $defaultValue); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function addArgument(string $name, string $type = '', $defaultValue = Argument::NO_PARAM): self |
|
48
|
|
|
{ |
|
49
|
|
|
$this->signature->addArgument($name, $type, $defaultValue); |
|
50
|
|
|
|
|
51
|
|
|
return $this; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function addArguments(string ...$names): self |
|
55
|
|
|
{ |
|
56
|
|
|
$this->signature->addArguments(...$names); |
|
57
|
|
|
|
|
58
|
|
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function add(FunctionMemberInterface $member): self |
|
62
|
|
|
{ |
|
63
|
|
|
$this->signature->add($member); |
|
64
|
|
|
|
|
65
|
|
|
return $this; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function bindVar(string $name, bool $isByReference = false): self |
|
69
|
|
|
{ |
|
70
|
|
|
$this->signature->bindVar($name, $isByReference); |
|
71
|
|
|
|
|
72
|
|
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function bindVars(string ...$names): self |
|
76
|
|
|
{ |
|
77
|
|
|
$this->signature->bindVars(...$names); |
|
78
|
|
|
|
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function removeBindVars() |
|
83
|
|
|
{ |
|
84
|
|
|
$this->signature->removeBindVars(); |
|
85
|
|
|
|
|
86
|
|
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function isStatic(): bool |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->signature->isStatic; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function setStatic(): self |
|
95
|
|
|
{ |
|
96
|
|
|
$this->signature->isStatic = true; |
|
97
|
|
|
|
|
98
|
|
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function unsetStatic() |
|
102
|
|
|
{ |
|
103
|
|
|
$this->signature->isStatic = false; |
|
104
|
|
|
|
|
105
|
|
|
return $this; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|