|
1
|
|
|
<?php |
|
2
|
|
|
namespace WebStream\Delegate; |
|
3
|
|
|
|
|
4
|
|
|
use WebStream\Core\CoreInterface; |
|
5
|
|
|
use WebStream\Core\CoreController; |
|
6
|
|
|
use WebStream\Core\CoreService; |
|
7
|
|
|
use WebStream\Core\CoreModel; |
|
8
|
|
|
use WebStream\Core\CoreView; |
|
9
|
|
|
use WebStream\Core\CoreHelper; |
|
10
|
|
|
use WebStream\Cache\Driver\CacheDriverFactory; |
|
11
|
|
|
use WebStream\Container\Container; |
|
12
|
|
|
use WebStream\Annotation\Attributes\Filter; |
|
13
|
|
|
use WebStream\Annotation\Attributes\Header; |
|
14
|
|
|
use WebStream\Annotation\Attributes\Template; |
|
15
|
|
|
use WebStream\Exception\ApplicationException; |
|
16
|
|
|
use WebStream\Exception\SystemException; |
|
17
|
|
|
use WebStream\Exception\DelegateException; |
|
18
|
|
|
use WebStream\Exception\Extend\AnnotationException; |
|
19
|
|
|
use WebStream\Exception\Extend\MethodNotFoundException; |
|
20
|
|
|
use WebStream\Util\CommonUtils; |
|
21
|
|
|
use Doctrine\Common\Annotations\AnnotationException as DoctrineAnnotationException; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* CoreExecuteDelegator |
|
25
|
|
|
* @author Ryuichi TANAKA. |
|
26
|
|
|
* @since 2015/02/25 |
|
27
|
|
|
* @version 0.4 |
|
28
|
|
|
*/ |
|
29
|
|
|
class CoreExecuteDelegator |
|
30
|
|
|
{ |
|
31
|
|
|
use CommonUtils; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var CoreInterface インスタンス |
|
35
|
|
|
*/ |
|
36
|
|
|
private $instance; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var CoreInterface 注入済みインスタンス |
|
40
|
|
|
*/ |
|
41
|
|
|
private $injectedInstance; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var Container 依存コンテナ |
|
45
|
|
|
*/ |
|
46
|
|
|
private $container; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var Logger ロガー |
|
|
|
|
|
|
50
|
|
|
*/ |
|
51
|
|
|
private $logger; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var AnnotationContainer アノテーション |
|
|
|
|
|
|
55
|
|
|
*/ |
|
56
|
|
|
private $annotation; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var array<AnnotationContainer> 例外ハンドラリスト |
|
60
|
|
|
*/ |
|
61
|
|
|
private $exceptionHandler; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* constructor |
|
65
|
|
|
*/ |
|
66
|
|
|
public function __construct(CoreInterface $instance, Container $container) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->instance = $instance; |
|
69
|
|
|
$this->container = $container; |
|
70
|
|
|
$this->logger = $container->logger; |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* method missing |
|
75
|
|
|
*/ |
|
76
|
|
|
public function __call($method, $arguments) |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->run($method, $arguments); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* overload getter |
|
83
|
|
|
*/ |
|
84
|
|
|
public function __get($name) |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->getInstance()->{$name}; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* 処理を実行する |
|
91
|
|
|
* @param string メソッド名 |
|
92
|
|
|
* @param array 引数リスト |
|
93
|
|
|
*/ |
|
|
|
|
|
|
94
|
|
|
public function run($method, $arguments = []) |
|
95
|
|
|
{ |
|
96
|
|
|
// すでに注入済みのインスタンスの場合、そのまま実行 |
|
97
|
|
|
if ($this->injectedInstance !== null) { |
|
98
|
|
|
return $this->execute($method, $arguments); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
try { |
|
102
|
|
|
$result = null; |
|
103
|
|
|
if ($this->instance instanceof CoreController) { |
|
104
|
|
|
$this->controllerInjector($this->getOriginMethod($method), $arguments); |
|
105
|
|
|
} elseif ($this->instance instanceof CoreService) { |
|
106
|
|
|
$result = $this->serviceInjector($this->getOriginMethod($method), $arguments); |
|
107
|
|
|
} elseif ($this->instance instanceof CoreModel) { |
|
108
|
|
|
$result = $this->modelInjector($this->getOriginMethod($method), $arguments); |
|
109
|
|
|
} elseif ($this->instance instanceof CoreView) { |
|
110
|
|
|
$this->viewInjector($method, $arguments); |
|
111
|
|
|
} elseif ($this->instance instanceof CoreHelper) { |
|
112
|
|
|
$result = $this->helperInjector($this->getOriginMethod($method), $arguments); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
return $result; |
|
116
|
|
|
} catch (DoctrineAnnotationException $e) { |
|
117
|
|
|
throw new AnnotationException($e); |
|
118
|
|
|
} catch (DelegateException $e) { |
|
119
|
|
|
// すでにデリゲート済み例外の場合はそのままスロー |
|
120
|
|
|
// カスタムアノテーション定義で発生する |
|
121
|
|
|
throw $e; |
|
122
|
|
|
} catch (\Exception $e) { |
|
123
|
|
|
$exceptionClass = get_class($e); |
|
124
|
|
|
switch ($exceptionClass) { |
|
125
|
|
|
case "Exception": |
|
126
|
|
|
case "LogicException": |
|
127
|
|
|
$e = new ApplicationException($e->getMessage(), 500, $e); |
|
128
|
|
|
break; |
|
129
|
|
|
case "RuntimeException": |
|
130
|
|
|
$e = new SystemException($e->getMessage(), 500, $e); |
|
131
|
|
|
break; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
$exception = new ExceptionDelegator($this->getInstance(), $e, $method); |
|
135
|
|
|
$exception->inject('logger', $this->logger); |
|
136
|
|
|
|
|
137
|
|
|
if ($this->annotation !== null && is_array($this->annotation->exceptionHandler)) { |
|
138
|
|
|
$exception->setExceptionHandler($this->annotation->exceptionHandler); |
|
139
|
|
|
} |
|
140
|
|
|
$exception->raise(); |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* オリジナルのインスタンスを返却する |
|
146
|
|
|
* @return CoreInterface インスタンス |
|
147
|
|
|
*/ |
|
148
|
|
|
public function getInstance() |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->injectedInstance ?: $this->instance; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* メソッドを実行する |
|
155
|
|
|
* @param string メソッド名 |
|
156
|
|
|
* @param array 引数リスト |
|
157
|
|
|
*/ |
|
|
|
|
|
|
158
|
|
|
private function execute($method, $arguments) |
|
159
|
|
|
{ |
|
160
|
|
|
// serviceの場合、modelの探索に行くためエラーにはしない |
|
161
|
|
|
if (!($this->injectedInstance instanceof CoreService) && !method_exists($this->injectedInstance, $method)) { |
|
162
|
|
|
$class = get_class($this->injectedInstance); |
|
163
|
|
|
throw new MethodNotFoundException("${class}#${method} is not defined."); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
return call_user_func_array([$this->injectedInstance, $method], $arguments); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* Controllerに注入する |
|
171
|
|
|
* @param string メソッド名 |
|
172
|
|
|
* @param array 引数リスト |
|
173
|
|
|
*/ |
|
|
|
|
|
|
174
|
|
|
private function controllerInjector($method, $arguments) |
|
175
|
|
|
{ |
|
176
|
|
|
if (!method_exists($this->instance, $method)) { |
|
177
|
|
|
$this->injectedInstance = $this->instance; |
|
178
|
|
|
$this->instance = null; |
|
179
|
|
|
$class = get_class($this->instance); |
|
180
|
|
|
throw new MethodNotFoundException("${class}#${method} is not defined."); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
$applicationInfo = $this->container->applicationInfo; |
|
|
|
|
|
|
184
|
|
|
|
|
185
|
|
|
// テンプレートキャッシュチェック |
|
186
|
|
|
$pageName = $this->container->coreDelegator->getPageName(); |
|
|
|
|
|
|
187
|
|
|
$cacheFile = $applicationInfo->cachePrefix . $this->camel2snake($pageName) . "-" . $this->camel2snake($method); |
|
|
|
|
|
|
188
|
|
|
|
|
189
|
|
|
$factory = new CacheDriverFactory(); |
|
190
|
|
|
$config = new Container(false); |
|
191
|
|
|
$config->cacheDir = $applicationInfo->applicationRoot . "/app/views/" . $applicationInfo->cacheDir; |
|
|
|
|
|
|
192
|
|
|
$config->classPrefix = "view_cache"; |
|
|
|
|
|
|
193
|
|
|
$cache = $factory->create("WebStream\Cache\Driver\TemporaryFile", $config); |
|
194
|
|
|
$cache->inject('logger', $this->logger); |
|
195
|
|
|
$data = $cache->get($cacheFile); |
|
196
|
|
|
|
|
197
|
|
|
if ($data !== null) { |
|
198
|
|
|
$this->logger->debug("Template cache read success: $cacheFile.cache"); |
|
199
|
|
|
echo $data; |
|
200
|
|
|
|
|
201
|
|
|
return; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
$resolver = new Resolver($this->container); |
|
205
|
|
|
$model = $resolver->runService() ?: $resolver->runModel(); |
|
206
|
|
|
|
|
207
|
|
|
// アノテーション注入処理は1度しか行わない |
|
208
|
|
|
if ($this->injectedInstance === null) { |
|
209
|
|
|
$annotation = $this->container->annotationDelegator->read($this->instance, $method); |
|
|
|
|
|
|
210
|
|
|
$annotationClosure = function ($classpath) use ($annotation) { |
|
211
|
|
|
if (array_key_exists($classpath, $annotation->annotationInfoList)) { |
|
212
|
|
|
return $annotation->annotationInfoList[$classpath]; |
|
213
|
|
|
} |
|
214
|
|
|
return null; |
|
215
|
|
|
}; |
|
216
|
|
|
|
|
217
|
|
|
// @Header |
|
218
|
|
|
$header = $annotationClosure(Header::class); |
|
|
|
|
|
|
219
|
|
|
// $mimeType = $this->annotation->header->mimeType; |
|
220
|
|
|
|
|
221
|
|
|
// @Filter |
|
222
|
|
|
$filter = $annotationClosure(Filter::class); |
|
223
|
|
|
|
|
224
|
|
|
// @Template |
|
225
|
|
|
$template = $annotationClosure(Template::class); |
|
226
|
|
|
|
|
227
|
|
|
|
|
228
|
|
|
// $template = $this->annotation->template; |
|
229
|
|
|
|
|
230
|
|
|
// custom annotation |
|
231
|
|
|
// $this->instance->__customAnnotation($this->annotation->customAnnotations); |
|
232
|
|
|
|
|
233
|
|
|
// 各アノテーションでエラーがあった場合この時点で例外を起こす。 |
|
234
|
|
|
// 例外発生を遅延実行させないとエラーになっていないアノテーション情報が取れない |
|
235
|
|
|
$exception = $annotation->exception; |
|
236
|
|
|
if ($exception instanceof ExceptionDelegator) { |
|
237
|
|
|
if ($this->annotation->exceptionHandler !== null) { |
|
238
|
|
|
$this->exceptionHandler = $this->annotation->exceptionHandler; |
|
239
|
|
|
} |
|
240
|
|
|
$exception->inject('logger', $this->logger); |
|
241
|
|
|
$exception->setExceptionHandler($this->exceptionHandler); |
|
242
|
|
|
$exception->raise(); |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
// initialize filter |
|
246
|
|
|
$container = $this->container; |
|
247
|
|
|
$container->model = $model; |
|
|
|
|
|
|
248
|
|
|
foreach ($filter->initialize as $refMethod) { |
|
249
|
|
|
$refMethod->invokeArgs($this->instance, [$container]); |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
// before filter |
|
253
|
|
|
foreach ($filter->before as $refMethod) { |
|
254
|
|
|
$refMethod->invoke($this->instance); |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
$this->injectedInstance = $this->instance; |
|
258
|
|
|
$this->execute($method, $arguments); |
|
259
|
|
|
|
|
260
|
|
|
// draw template |
|
261
|
|
|
if ($template !== null) { |
|
262
|
|
|
$view = $resolver->runView(); |
|
263
|
|
|
$view->setTemplateEngine($template->engine); |
|
264
|
|
|
$view->draw([ |
|
265
|
|
|
"model" => $model, |
|
266
|
|
|
"helper" => $resolver->runHelper(), |
|
267
|
|
|
"mimeType" => $mimeType |
|
|
|
|
|
|
268
|
|
|
]); |
|
269
|
|
|
|
|
270
|
|
|
if ($template->cacheTime !== null) { |
|
271
|
|
|
$cacheFile = $applicationInfo->cachePrefix . $this->camel2snake($pageName) . "-" . $this->camel2snake($method); |
|
272
|
|
|
$view->templateCache($cacheFile, ob_get_contents(), $template->cacheTime); |
|
273
|
|
|
} |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
// after filter |
|
277
|
|
|
foreach ($filter->after as $refMethod) { |
|
278
|
|
|
$refMethod->invoke($this->injectedInstance); |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
$this->instance = null; |
|
282
|
|
|
} |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* Serviceに注入する |
|
287
|
|
|
* @param string メソッド名 |
|
288
|
|
|
* @param array 引数リスト |
|
289
|
|
|
*/ |
|
|
|
|
|
|
290
|
|
|
private function serviceInjector($method, $arguments) |
|
291
|
|
|
{ |
|
292
|
|
|
// アノテーション注入処理は1度しか行わない |
|
293
|
|
|
if ($this->injectedInstance === null) { |
|
294
|
|
|
$this->annotation = $this->container->annotationDelegator->read($this->instance, $method); |
|
|
|
|
|
|
295
|
|
|
|
|
296
|
|
|
// @Filter |
|
297
|
|
|
$filter = $this->annotation->filter; |
|
298
|
|
|
|
|
299
|
|
|
// @ExceptionHandler |
|
300
|
|
|
$this->exceptionHandler = $this->annotation->exceptionHandler; |
|
301
|
|
|
|
|
302
|
|
|
// custom annotation |
|
303
|
|
|
$this->instance->__customAnnotation($this->annotation->customAnnotations); |
|
304
|
|
|
|
|
305
|
|
|
// 各アノテーションでエラーがあった場合この時点で例外を起こす。 |
|
306
|
|
|
// 例外発生を遅延実行させないとエラーになっていないアノテーション情報が取れない |
|
307
|
|
|
$exception = $this->annotation->exception; |
|
308
|
|
|
if ($exception instanceof ExceptionDelegator) { |
|
309
|
|
|
if ($this->annotation->exceptionHandler !== null) { |
|
310
|
|
|
$this->exceptionHandler = $this->annotation->exceptionHandler; |
|
311
|
|
|
} |
|
312
|
|
|
$exception->inject('logger', $this->logger); |
|
313
|
|
|
$exception->setExceptionHandler($this->exceptionHandler); |
|
314
|
|
|
$exception->raise(); |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
foreach ($filter->initialize as $refMethod) { |
|
318
|
|
|
$refMethod->invokeArgs($this->instance, [$this->container]); |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
$this->injectedInstance = $this->instance; |
|
322
|
|
|
$this->instance = null; |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
return $this->execute($method, $arguments); |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* Modelに注入する |
|
330
|
|
|
* @param string メソッド名 |
|
331
|
|
|
* @param array 引数リスト |
|
332
|
|
|
*/ |
|
|
|
|
|
|
333
|
|
|
private function modelInjector($method, $arguments) |
|
334
|
|
|
{ |
|
335
|
|
|
// アノテーション注入処理は1度しか行わない |
|
336
|
|
|
if ($this->injectedInstance === null) { |
|
337
|
|
|
$this->annotation = $this->container->annotationDelegator->read($this->instance, $method); |
|
|
|
|
|
|
338
|
|
|
|
|
339
|
|
|
// @Filter |
|
340
|
|
|
$filter = $this->annotation->filter; |
|
341
|
|
|
|
|
342
|
|
|
// custom annotation |
|
343
|
|
|
$this->instance->__customAnnotation($this->annotation->customAnnotations); |
|
344
|
|
|
|
|
345
|
|
|
if ($this->exceptionHandler === null) { |
|
|
|
|
|
|
346
|
|
|
$this->exceptionHandler = $this->annotation->exceptionHandler; |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
// 各アノテーションでエラーがあった場合この時点で例外を起こす。 |
|
350
|
|
|
// 例外発生を遅延実行させないとエラーになっていないアノテーション情報が取れない |
|
351
|
|
|
$exception = $this->annotation->exception; |
|
352
|
|
|
if ($exception instanceof ExceptionDelegator) { |
|
353
|
|
|
if ($this->annotation->exceptionHandler !== null) { |
|
354
|
|
|
$this->exceptionHandler = $this->annotation->exceptionHandler; |
|
355
|
|
|
} |
|
356
|
|
|
$exception->inject('logger', $this->logger); |
|
357
|
|
|
$exception->setExceptionHandler($this->annotation->exceptionHandler); |
|
358
|
|
|
$exception->raise(); |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
$initializeContainer = new Container(false); |
|
362
|
|
|
$initializeContainer->connectionContainerList = $this->annotation->database; |
|
|
|
|
|
|
363
|
|
|
$initializeContainer->queryAnnotations = $this->annotation->query; |
|
|
|
|
|
|
364
|
|
|
|
|
365
|
|
|
foreach ($filter->initialize as $refMethod) { |
|
366
|
|
|
$refMethod->invokeArgs($this->instance, [$initializeContainer]); |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
$this->injectedInstance = $this->instance; |
|
370
|
|
|
$this->instance = null; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
return $this->execute($method, $arguments); |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
/** |
|
377
|
|
|
* Viewに注入する |
|
378
|
|
|
* @param string メソッド名 |
|
379
|
|
|
* @param array 引数リスト |
|
380
|
|
|
*/ |
|
|
|
|
|
|
381
|
|
|
private function viewInjector($method, $arguments) |
|
382
|
|
|
{ |
|
383
|
|
|
// アノテーション注入処理は1度しか行わない |
|
384
|
|
|
if ($this->injectedInstance === null) { |
|
385
|
|
|
$this->annotation = $this->container->annotationDelegator->read($this->instance, $method); |
|
|
|
|
|
|
386
|
|
|
|
|
387
|
|
|
// @Filter |
|
388
|
|
|
$filter = $this->annotation->filter; |
|
389
|
|
|
|
|
390
|
|
|
// 各アノテーションでエラーがあった場合この時点で例外を起こす。 |
|
391
|
|
|
// 例外発生を遅延実行させないとエラーになっていないアノテーション情報が取れない |
|
392
|
|
|
$exception = $this->annotation->exception; |
|
393
|
|
|
if ($exception instanceof ExceptionDelegator) { |
|
394
|
|
|
$exception->inject('logger', $this->logger); |
|
395
|
|
|
$exception->raise(); |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
foreach ($filter->initialize as $refMethod) { |
|
399
|
|
|
$refMethod->invokeArgs($this->instance, [$this->container]); |
|
400
|
|
|
} |
|
401
|
|
|
|
|
402
|
|
|
$this->injectedInstance = $this->instance; |
|
403
|
|
|
$this->instance = null; |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
$this->execute($method, $arguments); |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
/** |
|
410
|
|
|
* Helperに注入する |
|
411
|
|
|
* @param string メソッド名 |
|
412
|
|
|
* @param array 引数リスト |
|
413
|
|
|
*/ |
|
|
|
|
|
|
414
|
|
|
private function helperInjector($method, $arguments) |
|
415
|
|
|
{ |
|
416
|
|
|
// アノテーション注入処理は1度しか行わない |
|
417
|
|
|
if ($this->injectedInstance === null) { |
|
418
|
|
|
$this->annotation = $this->container->annotationDelegator->read($this->instance, $method); |
|
|
|
|
|
|
419
|
|
|
|
|
420
|
|
|
// @Filter |
|
421
|
|
|
$filter = $this->annotation->filter; |
|
422
|
|
|
|
|
423
|
|
|
// custom annotation |
|
424
|
|
|
$this->instance->__customAnnotation($this->annotation->customAnnotations); |
|
425
|
|
|
|
|
426
|
|
|
if ($this->exceptionHandler === null) { |
|
|
|
|
|
|
427
|
|
|
$this->exceptionHandler = $this->annotation->exceptionHandler; |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
// 各アノテーションでエラーがあった場合この時点で例外を起こす。 |
|
431
|
|
|
// 例外発生を遅延実行させないとエラーになっていないアノテーション情報が取れない |
|
432
|
|
|
$exception = $this->annotation->exception; |
|
433
|
|
|
if ($exception instanceof ExceptionDelegator) { |
|
434
|
|
|
if ($this->annotation->exceptionHandler !== null) { |
|
435
|
|
|
$this->exceptionHandler = $this->annotation->exceptionHandler; |
|
436
|
|
|
} |
|
437
|
|
|
$exception->inject('logger', $this->logger); |
|
438
|
|
|
$exception->setExceptionHandler($this->annotation->exceptionHandler); |
|
439
|
|
|
$exception->raise(); |
|
440
|
|
|
} |
|
441
|
|
|
|
|
442
|
|
|
foreach ($filter->initialize as $refMethod) { |
|
443
|
|
|
$refMethod->invokeArgs($this->instance, [$this->container]); |
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
$this->injectedInstance = $this->instance; |
|
447
|
|
|
$this->instance = null; |
|
448
|
|
|
} |
|
449
|
|
|
|
|
450
|
|
|
return $this->execute($method, $arguments); |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
/** |
|
454
|
|
|
* 実メソッド名を返却する |
|
455
|
|
|
* @param stirng $method エイリアスメソッド名 |
|
|
|
|
|
|
456
|
|
|
* @return stirng 実メソッド名 |
|
457
|
|
|
*/ |
|
458
|
|
|
private function getOriginMethod($method) |
|
459
|
|
|
{ |
|
460
|
|
|
// 実メソッドが定義済みの場合、エイリアスメソッド参照はしない |
|
461
|
|
|
if (method_exists($this->instance, $method)) { |
|
462
|
|
|
return $method; |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
$annotation = $this->container->annotationDelegator->read($this->instance, $method, "WebStream\Annotation\Attributes\Alias"); |
|
|
|
|
|
|
466
|
|
|
|
|
467
|
|
|
$originMethod = null; |
|
468
|
|
|
foreach ($annotation->alias as $alias) { |
|
469
|
|
|
if ($originMethod !== null && $alias->{$method} !== null) { |
|
470
|
|
|
throw new AnnotationException("Alias method of the same name is defined: $method"); |
|
471
|
|
|
} |
|
472
|
|
|
if ($alias->{$method} !== null) { |
|
473
|
|
|
$originMethod = $alias->{$method}; |
|
474
|
|
|
} |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
if ($originMethod !== null) { |
|
478
|
|
|
$class = get_class($this->instance); |
|
479
|
|
|
$this->logger->debug("Alias method found. Transfer from ${class}#${method} to ${class}#${originMethod}."); |
|
480
|
|
|
} else { |
|
481
|
|
|
$originMethod = $method; |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
return $originMethod; |
|
485
|
|
|
} |
|
486
|
|
|
} |
|
487
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths