1 | <?php |
||
26 | class GoAspectContainer extends Container implements AspectContainer |
||
27 | { |
||
28 | /** |
||
29 | * List of resources for application |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $resources = []; |
||
34 | |||
35 | /** |
||
36 | * Cached timestamp for resources |
||
37 | * |
||
38 | * @var integer |
||
39 | */ |
||
40 | protected $maxTimestamp = 0; |
||
41 | |||
42 | /** |
||
43 | * Constructor for container |
||
44 | */ |
||
45 | public function __construct() |
||
46 | { |
||
47 | // Register all services in the container |
||
48 | 10 | $this->share('aspect.loader', function (Container $container) { |
|
49 | 2 | $aspectLoader = new AspectLoader( |
|
50 | 2 | $container, |
|
|
|||
51 | 2 | $container->get('aspect.annotation.reader') |
|
52 | ); |
||
53 | 2 | $lexer = $container->get('aspect.pointcut.lexer'); |
|
54 | 2 | $parser = $container->get('aspect.pointcut.parser'); |
|
55 | |||
56 | // Register general aspect loader extension |
||
57 | 2 | $aspectLoader->registerLoaderExtension(new GeneralAspectLoaderExtension($lexer, $parser)); |
|
58 | 2 | $aspectLoader->registerLoaderExtension(new IntroductionAspectExtension($lexer, $parser)); |
|
59 | |||
60 | 2 | return $aspectLoader; |
|
61 | 10 | }); |
|
62 | |||
63 | 10 | $this->share('aspect.cached.loader', function (Container $container) { |
|
64 | $options = $container->get('kernel.options'); |
||
65 | if (!empty($options['cacheDir'])) { |
||
66 | $loader = new CachedAspectLoader( |
||
67 | $container, |
||
68 | 'aspect.loader', |
||
69 | $container->get('kernel.options') |
||
70 | ); |
||
71 | } else { |
||
72 | $loader = $container->get('aspect.loader'); |
||
73 | } |
||
74 | |||
75 | return $loader; |
||
76 | 10 | }); |
|
77 | |||
78 | 10 | $this->share('aspect.advisor.accessor', function (Container $container) { |
|
79 | return new LazyAdvisorAccessor( |
||
80 | $container, |
||
81 | $container->get('aspect.cached.loader') |
||
82 | ); |
||
83 | 10 | }); |
|
84 | |||
85 | 10 | $this->share('aspect.advice_matcher', function (Container $container) { |
|
86 | 1 | return new AdviceMatcher( |
|
87 | 1 | $container->get('aspect.loader'), |
|
88 | 1 | $container->get('kernel.interceptFunctions') |
|
89 | ); |
||
90 | 10 | }); |
|
91 | |||
92 | 10 | $this->share('aspect.annotation.cache', function (Container $container) { |
|
93 | 5 | $options = $container->get('kernel.options'); |
|
94 | |||
95 | 5 | if (!empty($options['annotationCache'])) { |
|
96 | return $options['annotationCache']; |
||
97 | } |
||
98 | |||
99 | 5 | if (!empty($options['cacheDir'])) { |
|
100 | return new DoctrineCache\FilesystemCache( |
||
101 | $options['cacheDir'] . DIRECTORY_SEPARATOR . '_annotations' . DIRECTORY_SEPARATOR, |
||
102 | '.annotations.cache', |
||
103 | 0777 & (~$options['cacheFileMode']) |
||
104 | ); |
||
105 | } |
||
106 | |||
107 | 5 | return new DoctrineCache\ArrayCache(); |
|
108 | 10 | }); |
|
109 | |||
110 | 10 | $this->share('aspect.annotation.reader', function (Container $container) { |
|
111 | 4 | $options = $container->get('kernel.options'); |
|
112 | 4 | $options['debug'] = isset($options['debug']) ? $options['debug'] : false; |
|
113 | |||
114 | 4 | return new CachedReader( |
|
115 | 4 | new AnnotationReader(), |
|
116 | 4 | $container->get('aspect.annotation.cache'), |
|
117 | 4 | $options['debug'] |
|
118 | ); |
||
119 | 10 | }); |
|
120 | |||
121 | 10 | $this->share('aspect.cache.path.manager', function (Container $container) { |
|
122 | return new CachePathManager($container->get('kernel')); |
||
123 | 10 | }); |
|
124 | |||
125 | // Pointcut services |
||
126 | 10 | $this->share('aspect.pointcut.lexer', function () { |
|
127 | 3 | return new PointcutLexer(); |
|
128 | 10 | }); |
|
129 | 10 | $this->share('aspect.pointcut.parser', function (Container $container) { |
|
130 | 3 | return new PointcutParser( |
|
131 | 3 | new PointcutGrammar( |
|
132 | 3 | $container, |
|
133 | 3 | $container->get('aspect.annotation.reader') |
|
134 | ) |
||
135 | ); |
||
136 | 10 | }); |
|
137 | 10 | } |
|
138 | |||
139 | /** |
||
140 | * Returns a pointcut by identifier |
||
141 | * |
||
142 | * @param string $id Pointcut identifier |
||
143 | * |
||
144 | * @return Aop\Pointcut |
||
145 | */ |
||
146 | 1 | public function getPointcut($id) |
|
150 | |||
151 | /** |
||
152 | * Store the pointcut in the container |
||
153 | * |
||
154 | * @param Aop\Pointcut $pointcut Instance |
||
155 | * @param string $id Key for pointcut |
||
156 | */ |
||
157 | 1 | public function registerPointcut(Aop\Pointcut $pointcut, $id) |
|
161 | |||
162 | /** |
||
163 | * Returns an advisor by identifier |
||
164 | * |
||
165 | * @param string $id Advisor identifier |
||
166 | * |
||
167 | * @return Aop\Advisor |
||
168 | */ |
||
169 | public function getAdvisor($id) |
||
173 | |||
174 | /** |
||
175 | * Store the advisor in the container |
||
176 | * |
||
177 | * @param Aop\Advisor $advisor Instance |
||
178 | * @param string $id Key for advisor |
||
179 | */ |
||
180 | 1 | public function registerAdvisor(Aop\Advisor $advisor, $id) |
|
184 | |||
185 | /** |
||
186 | * Returns an aspect by id or class name |
||
187 | * |
||
188 | * @param string $aspectName Aspect name |
||
189 | * |
||
190 | * @return Aop\Aspect |
||
191 | */ |
||
192 | 1 | public function getAspect($aspectName) |
|
196 | |||
197 | /** |
||
198 | * Register an aspect in the container |
||
199 | * |
||
200 | * @param Aop\Aspect $aspect Instance of concrete aspect |
||
201 | */ |
||
202 | 1 | public function registerAspect(Aop\Aspect $aspect) |
|
208 | |||
209 | /** |
||
210 | * Add an AOP resource to the container |
||
211 | * |
||
212 | * Resources is used to check the freshness of AOP cache |
||
213 | */ |
||
214 | 2 | public function addResource($resource) |
|
219 | |||
220 | /** |
||
221 | * Returns list of AOP resources |
||
222 | * |
||
223 | * @return array |
||
224 | */ |
||
225 | public function getResources() |
||
229 | |||
230 | /** |
||
231 | * Checks the freshness of AOP cache |
||
232 | * |
||
233 | * @param integer $timestamp |
||
234 | * |
||
235 | * @return bool Whether or not concrete file is fresh |
||
236 | */ |
||
237 | 1 | public function isFresh($timestamp) |
|
245 | } |
||
246 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: