1 | <?php |
||
22 | class StaticInitializationJoinpoint extends AbstractJoinpoint implements ClassJoinpoint |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * @var ReflectionClass |
||
27 | */ |
||
28 | protected $reflectionClass; |
||
29 | |||
30 | /** |
||
31 | * Constructor for the class static initialization joinpoint |
||
32 | * |
||
33 | * @param array $advices List of advices for this invocation |
||
34 | 1 | */ |
|
35 | public function __construct(string $className, string $unusedType, array $advices) |
||
36 | 1 | { |
|
37 | 1 | $originalClass = $className; |
|
38 | 1 | if (strpos($originalClass, AspectContainer::AOP_PROXIED_SUFFIX)) { |
|
39 | $originalClass = substr($originalClass, 0, -strlen(AspectContainer::AOP_PROXIED_SUFFIX)); |
||
40 | 1 | } |
|
41 | 1 | $this->reflectionClass = new \ReflectionClass($originalClass); |
|
42 | 1 | parent::__construct($advices); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * Proceeds to the next interceptor in the chain. |
||
47 | * |
||
48 | * @return void Static initializtion could not return anything |
||
49 | 1 | */ |
|
50 | public function proceed() |
||
51 | 1 | { |
|
52 | 1 | if (isset($this->advices[$this->current])) { |
|
53 | 1 | $currentInterceptor = $this->advices[$this->current++]; |
|
54 | $currentInterceptor->invoke($this); |
||
55 | 1 | } |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * Invokes current joinpoint with all interceptors |
||
60 | 1 | */ |
|
61 | final public function __invoke(): void |
||
62 | 1 | { |
|
63 | 1 | $this->current = 0; |
|
64 | 1 | $this->proceed(); |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * Returns the object for which current joinpoint is invoked |
||
69 | * |
||
70 | * @return object|null Instance of object or null for static call/unavailable context |
||
71 | */ |
||
72 | public function getThis(): ?object |
||
76 | |||
77 | /** |
||
78 | * Checks if the current joinpoint is dynamic or static |
||
79 | * |
||
80 | * Dynamic joinpoint contains a reference to an object that can be received via getThis() method call |
||
81 | * |
||
82 | * @see ClassJoinpoint::getThis() |
||
83 | */ |
||
84 | public function isDynamic(): bool |
||
88 | |||
89 | /** |
||
90 | * Returns the static scope name (class name) of this joinpoint. |
||
91 | */ |
||
92 | public function getScope(): string |
||
96 | |||
97 | /** |
||
98 | * Returns a friendly description of current joinpoint |
||
99 | */ |
||
100 | final public function __toString(): string |
||
107 | } |
||
108 |