1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Go! AOP framework |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright 2015, Lisachenko Alexander <[email protected]> |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the license that is bundled |
8
|
|
|
* with this source code in the file LICENSE. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Go\Aop\Framework; |
12
|
|
|
|
13
|
|
|
class StaticClosureMethodInvocation extends DynamicClosureMethodInvocation |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Invokes original method and return result from it |
17
|
|
|
* |
18
|
|
|
* @return mixed |
19
|
|
|
*/ |
20
|
12 |
|
public function proceed() |
21
|
|
|
{ |
22
|
12 |
|
if (isset($this->advices[$this->current])) { |
23
|
|
|
/** @var $currentInterceptor \Go\Aop\Intercept\Interceptor */ |
24
|
1 |
|
$currentInterceptor = $this->advices[$this->current++]; |
25
|
|
|
|
26
|
1 |
|
return $currentInterceptor->invoke($this); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// Rebind the closure if scope (class name) was changed since last time |
30
|
12 |
|
if ($this->previousInstance !== $this->instance) { |
31
|
12 |
|
if ($this->closureToCall === null) { |
32
|
12 |
|
$this->closureToCall = $this->getStaticInvoker($this->className, $this->reflectionMethod->name); |
33
|
|
|
} |
34
|
12 |
|
$this->closureToCall = $this->closureToCall->bindTo(null, $this->instance); |
35
|
12 |
|
$this->previousInstance = $this->instance; |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
12 |
|
$closureToCall = $this->closureToCall; |
39
|
|
|
|
40
|
12 |
|
return $closureToCall($this->arguments); |
41
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Returns static method invoker |
46
|
|
|
* |
47
|
|
|
* @param string $className Class name to forward request |
48
|
|
|
* @param string $method Method name to call |
49
|
|
|
* |
50
|
|
|
* @return \Closure |
51
|
|
|
*/ |
52
|
|
|
protected static function getStaticInvoker($className, $method) |
53
|
|
|
{ |
54
|
12 |
|
return function(array $args) use ($className, $method) { |
55
|
12 |
|
return forward_static_call_array(array($className, $method), $args); |
56
|
12 |
|
}; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..