1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Patsura Dmitry https://github.com/ovr <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace PHPSA\Definition; |
7
|
|
|
|
8
|
|
|
use PHPSA\CompiledExpression; |
9
|
|
|
use PHPSA\Context; |
10
|
|
|
use ReflectionMethod; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Method created from Reflection |
14
|
|
|
*/ |
15
|
|
|
class ReflectionClassMethod extends ClassMethod |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Return type |
19
|
|
|
* |
20
|
|
|
* @var int |
21
|
|
|
*/ |
22
|
|
|
protected $returnType = CompiledExpression::VOID; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Array of possible return values |
26
|
|
|
* |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
protected $possibleReturnValues = []; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var ReflectionMethod |
33
|
|
|
*/ |
34
|
|
|
protected $reflection; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* ReflectionClassMethod constructor. |
38
|
|
|
* @param ReflectionMethod $reflection |
39
|
|
|
*/ |
40
|
|
|
public function __construct(ReflectionMethod $reflection) |
41
|
|
|
{ |
42
|
|
|
$this->reflection = $reflection; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getName() |
49
|
|
|
{ |
50
|
|
|
return $this->reflection->getName(); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param Context $context |
55
|
|
|
* @return ReflectionClassMethod |
56
|
|
|
*/ |
57
|
|
|
public function compile(Context $context) |
58
|
|
|
{ |
59
|
|
|
$this->compiled = true; |
60
|
|
|
$context->scopePointer = $this->getPointer(); |
61
|
|
|
|
62
|
|
|
return $this; |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
|
|
public function isAbstract() |
69
|
|
|
{ |
70
|
|
|
return $this->reflection->isAbstract(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return bool |
75
|
|
|
*/ |
76
|
|
|
public function isStatic() |
77
|
|
|
{ |
78
|
|
|
return $this->reflection->isStatic(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return bool |
83
|
|
|
*/ |
84
|
|
|
public function isPublic() |
85
|
|
|
{ |
86
|
|
|
return $this->reflection->isPublic(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return bool |
91
|
|
|
*/ |
92
|
|
|
public function isProtected() |
93
|
|
|
{ |
94
|
|
|
return $this->reflection->isProtected(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
|
|
public function isPrivate() |
101
|
|
|
{ |
102
|
|
|
return $this->reflection->isPrivate(); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|