1 | <?php |
||
22 | abstract class AbstractProxy |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Indent for source code |
||
27 | * |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $indent = 4; |
||
31 | |||
32 | /** |
||
33 | * List of advices that are used for generation of child |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $advices = []; |
||
38 | |||
39 | /** |
||
40 | * PHP expression string for accessing LSB information |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected static $staticLsbExpression = 'static::class'; |
||
45 | |||
46 | /** |
||
47 | * Constructs an abstract proxy class |
||
48 | * |
||
49 | * @param array $advices List of advices |
||
50 | */ |
||
51 | 6 | public function __construct(array $advices = []) |
|
55 | |||
56 | /** |
||
57 | * Returns text representation of class |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | abstract public function __toString(); |
||
62 | |||
63 | /** |
||
64 | * Indent block of code |
||
65 | * |
||
66 | * @param string $text Non-indented text |
||
67 | * |
||
68 | * @return string Indented text |
||
69 | */ |
||
70 | 6 | protected function indent(string $text): string |
|
79 | |||
80 | /** |
||
81 | * Returns list of string representation of parameters |
||
82 | * |
||
83 | * @param array|ReflectionParameter[] $parameters List of parameters |
||
84 | * |
||
85 | * @return array|string[] |
||
86 | */ |
||
87 | 6 | protected function getParameters(array $parameters): array |
|
96 | |||
97 | /** |
||
98 | * Return string representation of parameter |
||
99 | * |
||
100 | * @param ReflectionParameter $parameter Reflection parameter |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | 3 | protected function getParameterCode(ReflectionParameter $parameter): string |
|
131 | |||
132 | /** |
||
133 | * Replace concrete advices with list of ids |
||
134 | * |
||
135 | * @param array $advices List of advices |
||
136 | * |
||
137 | * @return array flatten list of advices |
||
138 | */ |
||
139 | 6 | private function flattenAdvices(array $advices): array |
|
152 | |||
153 | /** |
||
154 | * Prepares a line with args from the method definition |
||
155 | * |
||
156 | * @param ReflectionFunctionAbstract $functionLike |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | 6 | protected function prepareArgsLine(ReflectionFunctionAbstract $functionLike): string |
|
188 | |||
189 | /** |
||
190 | * Creates a function code from Reflection |
||
191 | * |
||
192 | * @param ReflectionFunctionAbstract $functionLike Reflection for method |
||
193 | * @param string $body Body of method |
||
194 | * |
||
195 | * @return string |
||
196 | */ |
||
197 | 6 | protected function getOverriddenFunction(ReflectionFunctionAbstract $functionLike, string $body): string |
|
229 | } |
||
230 |