@@ -28,114 +28,114 @@ |
||
28 | 28 | class BootstrapDependencyInjectionContainer |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var EE_Dependency_Map $dependency_map |
|
33 | - */ |
|
34 | - protected $dependency_map; |
|
35 | - |
|
36 | - /** |
|
37 | - * @type LoaderInterface $loader |
|
38 | - */ |
|
39 | - protected $loader; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var EE_Registry $registry |
|
43 | - */ |
|
44 | - protected $registry; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var ClassInterfaceCache $class_cache |
|
48 | - */ |
|
49 | - private $class_cache; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var Mirror |
|
53 | - */ |
|
54 | - private $mirror; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Can't use this just yet until we exorcise some more of our singleton usage from core |
|
59 | - */ |
|
60 | - public function buildDependencyInjectionContainer() |
|
61 | - { |
|
62 | - // build DI container |
|
63 | - // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
64 | - // $OpenCoffeeShop->addRecipes(); |
|
65 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Setups EE_Registry and EE_Dependency_Map |
|
71 | - * |
|
72 | - * @throws EE_Error |
|
73 | - */ |
|
74 | - public function buildLegacyDependencyInjectionContainer() |
|
75 | - { |
|
76 | - $this->class_cache = new ClassInterfaceCache(); |
|
77 | - $this->mirror = new Mirror(); |
|
78 | - // EE_Dependency_Map: info about how to load classes required by other classes |
|
79 | - espresso_load_required( |
|
80 | - 'EE_Dependency_Map', |
|
81 | - EE_CORE . 'EE_Dependency_Map.core.php' |
|
82 | - ); |
|
83 | - $this->dependency_map = EE_Dependency_Map::instance($this->class_cache); |
|
84 | - // EE_Registry: central repository for classes (legacy) |
|
85 | - espresso_load_required( |
|
86 | - 'EE_Registry', |
|
87 | - EE_CORE . 'EE_Registry.core.php' |
|
88 | - ); |
|
89 | - $this->registry = EE_Registry::instance( |
|
90 | - $this->dependency_map, |
|
91 | - $this->mirror, |
|
92 | - $this->class_cache |
|
93 | - ); |
|
94 | - |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * Performs initial setup for the generic Loader |
|
100 | - * |
|
101 | - * @throws InvalidDataTypeException |
|
102 | - * @throws InvalidInterfaceException |
|
103 | - * @throws InvalidArgumentException |
|
104 | - */ |
|
105 | - public function buildLoader() |
|
106 | - { |
|
107 | - $this->loader = LoaderFactory::getLoader($this->registry, $this->class_cache); |
|
108 | - $this->loader->share('EventEspresso\core\services\loaders\ClassInterfaceCache', $this->class_cache); |
|
109 | - $this->loader->share('EventEspresso\core\services\container\Mirror', $this->mirror); |
|
110 | - $this->dependency_map->setLoader($this->loader); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @return EE_Dependency_Map |
|
116 | - */ |
|
117 | - public function getDependencyMap() |
|
118 | - { |
|
119 | - return $this->dependency_map; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @return EE_Registry |
|
125 | - */ |
|
126 | - public function getRegistry() |
|
127 | - { |
|
128 | - return $this->registry; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @return LoaderInterface |
|
135 | - */ |
|
136 | - public function getLoader() |
|
137 | - { |
|
138 | - return $this->loader; |
|
139 | - } |
|
31 | + /** |
|
32 | + * @var EE_Dependency_Map $dependency_map |
|
33 | + */ |
|
34 | + protected $dependency_map; |
|
35 | + |
|
36 | + /** |
|
37 | + * @type LoaderInterface $loader |
|
38 | + */ |
|
39 | + protected $loader; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var EE_Registry $registry |
|
43 | + */ |
|
44 | + protected $registry; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var ClassInterfaceCache $class_cache |
|
48 | + */ |
|
49 | + private $class_cache; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var Mirror |
|
53 | + */ |
|
54 | + private $mirror; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Can't use this just yet until we exorcise some more of our singleton usage from core |
|
59 | + */ |
|
60 | + public function buildDependencyInjectionContainer() |
|
61 | + { |
|
62 | + // build DI container |
|
63 | + // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
64 | + // $OpenCoffeeShop->addRecipes(); |
|
65 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Setups EE_Registry and EE_Dependency_Map |
|
71 | + * |
|
72 | + * @throws EE_Error |
|
73 | + */ |
|
74 | + public function buildLegacyDependencyInjectionContainer() |
|
75 | + { |
|
76 | + $this->class_cache = new ClassInterfaceCache(); |
|
77 | + $this->mirror = new Mirror(); |
|
78 | + // EE_Dependency_Map: info about how to load classes required by other classes |
|
79 | + espresso_load_required( |
|
80 | + 'EE_Dependency_Map', |
|
81 | + EE_CORE . 'EE_Dependency_Map.core.php' |
|
82 | + ); |
|
83 | + $this->dependency_map = EE_Dependency_Map::instance($this->class_cache); |
|
84 | + // EE_Registry: central repository for classes (legacy) |
|
85 | + espresso_load_required( |
|
86 | + 'EE_Registry', |
|
87 | + EE_CORE . 'EE_Registry.core.php' |
|
88 | + ); |
|
89 | + $this->registry = EE_Registry::instance( |
|
90 | + $this->dependency_map, |
|
91 | + $this->mirror, |
|
92 | + $this->class_cache |
|
93 | + ); |
|
94 | + |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * Performs initial setup for the generic Loader |
|
100 | + * |
|
101 | + * @throws InvalidDataTypeException |
|
102 | + * @throws InvalidInterfaceException |
|
103 | + * @throws InvalidArgumentException |
|
104 | + */ |
|
105 | + public function buildLoader() |
|
106 | + { |
|
107 | + $this->loader = LoaderFactory::getLoader($this->registry, $this->class_cache); |
|
108 | + $this->loader->share('EventEspresso\core\services\loaders\ClassInterfaceCache', $this->class_cache); |
|
109 | + $this->loader->share('EventEspresso\core\services\container\Mirror', $this->mirror); |
|
110 | + $this->dependency_map->setLoader($this->loader); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @return EE_Dependency_Map |
|
116 | + */ |
|
117 | + public function getDependencyMap() |
|
118 | + { |
|
119 | + return $this->dependency_map; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @return EE_Registry |
|
125 | + */ |
|
126 | + public function getRegistry() |
|
127 | + { |
|
128 | + return $this->registry; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @return LoaderInterface |
|
135 | + */ |
|
136 | + public function getLoader() |
|
137 | + { |
|
138 | + return $this->loader; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | } |
@@ -78,13 +78,13 @@ |
||
78 | 78 | // EE_Dependency_Map: info about how to load classes required by other classes |
79 | 79 | espresso_load_required( |
80 | 80 | 'EE_Dependency_Map', |
81 | - EE_CORE . 'EE_Dependency_Map.core.php' |
|
81 | + EE_CORE.'EE_Dependency_Map.core.php' |
|
82 | 82 | ); |
83 | 83 | $this->dependency_map = EE_Dependency_Map::instance($this->class_cache); |
84 | 84 | // EE_Registry: central repository for classes (legacy) |
85 | 85 | espresso_load_required( |
86 | 86 | 'EE_Registry', |
87 | - EE_CORE . 'EE_Registry.core.php' |
|
87 | + EE_CORE.'EE_Registry.core.php' |
|
88 | 88 | ); |
89 | 89 | $this->registry = EE_Registry::instance( |
90 | 90 | $this->dependency_map, |
@@ -52,233 +52,233 @@ |
||
52 | 52 | class BootstrapCore |
53 | 53 | { |
54 | 54 | |
55 | - /** |
|
56 | - * @type LoaderInterface $loader |
|
57 | - */ |
|
58 | - private $loader; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var RequestInterface $request |
|
62 | - */ |
|
63 | - protected $request; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var ResponseInterface $response |
|
67 | - */ |
|
68 | - protected $response; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var RequestStackBuilder $request_stack_builder |
|
72 | - */ |
|
73 | - protected $request_stack_builder; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var RequestStack $request_stack |
|
77 | - */ |
|
78 | - protected $request_stack; |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * BootstrapCore constructor. |
|
83 | - */ |
|
84 | - public function __construct() |
|
85 | - { |
|
86 | - // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
87 | - add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @throws InvalidFilePathException |
|
93 | - * @throws InvalidClassException |
|
94 | - * @throws DomainException |
|
95 | - * @throws EE_Error |
|
96 | - * @throws InvalidArgumentException |
|
97 | - * @throws InvalidDataTypeException |
|
98 | - * @throws InvalidInterfaceException |
|
99 | - * @throws ReflectionException |
|
100 | - * @throws Exception |
|
101 | - */ |
|
102 | - public function initialize() |
|
103 | - { |
|
104 | - $this->bootstrapDependencyInjectionContainer(); |
|
105 | - $this->bootstrapDomain(); |
|
106 | - $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
107 | - add_action( |
|
108 | - 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
109 | - array($bootstrap_request, 'setupLegacyRequest') |
|
110 | - ); |
|
111 | - $this->runRequestStack(); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @throws ReflectionException |
|
117 | - * @throws EE_Error |
|
118 | - * @throws InvalidArgumentException |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidInterfaceException |
|
121 | - */ |
|
122 | - private function bootstrapDependencyInjectionContainer() |
|
123 | - { |
|
124 | - $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
125 | - $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
126 | - $bootstrap_di->buildLoader(); |
|
127 | - $registry = $bootstrap_di->getRegistry(); |
|
128 | - $dependency_map = $bootstrap_di->getDependencyMap(); |
|
129 | - $dependency_map->initialize(); |
|
130 | - $registry->initialize(); |
|
131 | - $this->loader = $bootstrap_di->getLoader(); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * configures the Domain object for core |
|
137 | - * |
|
138 | - * @return void |
|
139 | - * @throws DomainException |
|
140 | - * @throws InvalidArgumentException |
|
141 | - * @throws InvalidDataTypeException |
|
142 | - * @throws InvalidClassException |
|
143 | - * @throws InvalidFilePathException |
|
144 | - * @throws InvalidInterfaceException |
|
145 | - */ |
|
146 | - private function bootstrapDomain() |
|
147 | - { |
|
148 | - DomainFactory::getShared( |
|
149 | - new FullyQualifiedName( |
|
150 | - 'EventEspresso\core\domain\Domain' |
|
151 | - ), |
|
152 | - array( |
|
153 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
154 | - Version::fromString(espresso_version()) |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * sets up the request and response objects |
|
162 | - * |
|
163 | - * @return BootstrapRequestResponseObjects |
|
164 | - * @throws InvalidArgumentException |
|
165 | - */ |
|
166 | - private function bootstrapRequestResponseObjects() |
|
167 | - { |
|
168 | - /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
169 | - $bootstrap_request = $this->loader->getShared( |
|
170 | - 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
171 | - array($this->loader) |
|
172 | - ); |
|
173 | - $bootstrap_request->buildRequestResponse(); |
|
174 | - $bootstrap_request->shareRequestResponse(); |
|
175 | - $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
176 | - $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
177 | - return $bootstrap_request; |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * run_request_stack |
|
183 | - * construct request stack and run middleware apps |
|
184 | - * |
|
185 | - * @throws EE_Error |
|
186 | - * @throws Exception |
|
187 | - */ |
|
188 | - public function runRequestStack() |
|
189 | - { |
|
190 | - $this->loadAutoloader(); |
|
191 | - $this->setAutoloadersForRequiredFiles(); |
|
192 | - $this->request_stack_builder = $this->buildRequestStack(); |
|
193 | - $this->request_stack = $this->request_stack_builder->resolve( |
|
194 | - new RequestStackCoreApp() |
|
195 | - ); |
|
196 | - $this->request_stack->handleRequest($this->request, $this->response); |
|
197 | - $this->request_stack->handleResponse(); |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * load_autoloader |
|
203 | - * |
|
204 | - * @throws EE_Error |
|
205 | - */ |
|
206 | - protected function loadAutoloader() |
|
207 | - { |
|
208 | - // load interfaces |
|
209 | - espresso_load_required( |
|
210 | - 'EEH_Autoloader', |
|
211 | - EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
212 | - ); |
|
213 | - EEH_Autoloader::instance(); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * load_required_files |
|
220 | - * |
|
221 | - * @throws EE_Error |
|
222 | - */ |
|
223 | - protected function setAutoloadersForRequiredFiles() |
|
224 | - { |
|
225 | - // load interfaces |
|
226 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
227 | - // load helpers |
|
228 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
229 | - // register legacy request stack classes just in case |
|
230 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
231 | - // register legacy middleware classes just in case |
|
232 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * build_request_stack |
|
239 | - * |
|
240 | - * @return RequestStackBuilder |
|
241 | - */ |
|
242 | - public function buildRequestStack() |
|
243 | - { |
|
244 | - $request_stack_builder = new RequestStackBuilder($this->loader); |
|
245 | - /** |
|
246 | - * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
247 | - * so items at the beginning of the final middleware stack will run last. |
|
248 | - * First parameter is the middleware classname, second is an array of arguments |
|
249 | - */ |
|
250 | - $stack_apps = apply_filters( |
|
251 | - 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
252 | - array( |
|
253 | - // first in last out |
|
254 | - 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
255 | - 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
256 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
257 | - 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
258 | - // last in first out |
|
259 | - 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
260 | - ) |
|
261 | - ); |
|
262 | - // legacy filter for backwards compatibility |
|
263 | - $stack_apps = apply_filters( |
|
264 | - 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
265 | - $stack_apps |
|
266 | - ); |
|
267 | - // load middleware onto stack : FILO (First In Last Out) |
|
268 | - // items at the beginning of the $stack_apps array will run last |
|
269 | - foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
270 | - $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
271 | - } |
|
272 | - // finally, we'll add this on its own because we need it to always be part of the stack |
|
273 | - // and we also need it to always run first because the rest of the system relies on it |
|
274 | - $request_stack_builder->push( |
|
275 | - array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
276 | - ); |
|
277 | - return apply_filters( |
|
278 | - 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
279 | - $request_stack_builder |
|
280 | - ); |
|
281 | - } |
|
55 | + /** |
|
56 | + * @type LoaderInterface $loader |
|
57 | + */ |
|
58 | + private $loader; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var RequestInterface $request |
|
62 | + */ |
|
63 | + protected $request; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var ResponseInterface $response |
|
67 | + */ |
|
68 | + protected $response; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var RequestStackBuilder $request_stack_builder |
|
72 | + */ |
|
73 | + protected $request_stack_builder; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var RequestStack $request_stack |
|
77 | + */ |
|
78 | + protected $request_stack; |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * BootstrapCore constructor. |
|
83 | + */ |
|
84 | + public function __construct() |
|
85 | + { |
|
86 | + // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
87 | + add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @throws InvalidFilePathException |
|
93 | + * @throws InvalidClassException |
|
94 | + * @throws DomainException |
|
95 | + * @throws EE_Error |
|
96 | + * @throws InvalidArgumentException |
|
97 | + * @throws InvalidDataTypeException |
|
98 | + * @throws InvalidInterfaceException |
|
99 | + * @throws ReflectionException |
|
100 | + * @throws Exception |
|
101 | + */ |
|
102 | + public function initialize() |
|
103 | + { |
|
104 | + $this->bootstrapDependencyInjectionContainer(); |
|
105 | + $this->bootstrapDomain(); |
|
106 | + $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
107 | + add_action( |
|
108 | + 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
109 | + array($bootstrap_request, 'setupLegacyRequest') |
|
110 | + ); |
|
111 | + $this->runRequestStack(); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @throws ReflectionException |
|
117 | + * @throws EE_Error |
|
118 | + * @throws InvalidArgumentException |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidInterfaceException |
|
121 | + */ |
|
122 | + private function bootstrapDependencyInjectionContainer() |
|
123 | + { |
|
124 | + $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
125 | + $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
126 | + $bootstrap_di->buildLoader(); |
|
127 | + $registry = $bootstrap_di->getRegistry(); |
|
128 | + $dependency_map = $bootstrap_di->getDependencyMap(); |
|
129 | + $dependency_map->initialize(); |
|
130 | + $registry->initialize(); |
|
131 | + $this->loader = $bootstrap_di->getLoader(); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * configures the Domain object for core |
|
137 | + * |
|
138 | + * @return void |
|
139 | + * @throws DomainException |
|
140 | + * @throws InvalidArgumentException |
|
141 | + * @throws InvalidDataTypeException |
|
142 | + * @throws InvalidClassException |
|
143 | + * @throws InvalidFilePathException |
|
144 | + * @throws InvalidInterfaceException |
|
145 | + */ |
|
146 | + private function bootstrapDomain() |
|
147 | + { |
|
148 | + DomainFactory::getShared( |
|
149 | + new FullyQualifiedName( |
|
150 | + 'EventEspresso\core\domain\Domain' |
|
151 | + ), |
|
152 | + array( |
|
153 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
154 | + Version::fromString(espresso_version()) |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * sets up the request and response objects |
|
162 | + * |
|
163 | + * @return BootstrapRequestResponseObjects |
|
164 | + * @throws InvalidArgumentException |
|
165 | + */ |
|
166 | + private function bootstrapRequestResponseObjects() |
|
167 | + { |
|
168 | + /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
169 | + $bootstrap_request = $this->loader->getShared( |
|
170 | + 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
171 | + array($this->loader) |
|
172 | + ); |
|
173 | + $bootstrap_request->buildRequestResponse(); |
|
174 | + $bootstrap_request->shareRequestResponse(); |
|
175 | + $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
176 | + $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
177 | + return $bootstrap_request; |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * run_request_stack |
|
183 | + * construct request stack and run middleware apps |
|
184 | + * |
|
185 | + * @throws EE_Error |
|
186 | + * @throws Exception |
|
187 | + */ |
|
188 | + public function runRequestStack() |
|
189 | + { |
|
190 | + $this->loadAutoloader(); |
|
191 | + $this->setAutoloadersForRequiredFiles(); |
|
192 | + $this->request_stack_builder = $this->buildRequestStack(); |
|
193 | + $this->request_stack = $this->request_stack_builder->resolve( |
|
194 | + new RequestStackCoreApp() |
|
195 | + ); |
|
196 | + $this->request_stack->handleRequest($this->request, $this->response); |
|
197 | + $this->request_stack->handleResponse(); |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * load_autoloader |
|
203 | + * |
|
204 | + * @throws EE_Error |
|
205 | + */ |
|
206 | + protected function loadAutoloader() |
|
207 | + { |
|
208 | + // load interfaces |
|
209 | + espresso_load_required( |
|
210 | + 'EEH_Autoloader', |
|
211 | + EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
212 | + ); |
|
213 | + EEH_Autoloader::instance(); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * load_required_files |
|
220 | + * |
|
221 | + * @throws EE_Error |
|
222 | + */ |
|
223 | + protected function setAutoloadersForRequiredFiles() |
|
224 | + { |
|
225 | + // load interfaces |
|
226 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
227 | + // load helpers |
|
228 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
229 | + // register legacy request stack classes just in case |
|
230 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
231 | + // register legacy middleware classes just in case |
|
232 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * build_request_stack |
|
239 | + * |
|
240 | + * @return RequestStackBuilder |
|
241 | + */ |
|
242 | + public function buildRequestStack() |
|
243 | + { |
|
244 | + $request_stack_builder = new RequestStackBuilder($this->loader); |
|
245 | + /** |
|
246 | + * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
247 | + * so items at the beginning of the final middleware stack will run last. |
|
248 | + * First parameter is the middleware classname, second is an array of arguments |
|
249 | + */ |
|
250 | + $stack_apps = apply_filters( |
|
251 | + 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
252 | + array( |
|
253 | + // first in last out |
|
254 | + 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
255 | + 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
256 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
257 | + 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
258 | + // last in first out |
|
259 | + 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
260 | + ) |
|
261 | + ); |
|
262 | + // legacy filter for backwards compatibility |
|
263 | + $stack_apps = apply_filters( |
|
264 | + 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
265 | + $stack_apps |
|
266 | + ); |
|
267 | + // load middleware onto stack : FILO (First In Last Out) |
|
268 | + // items at the beginning of the $stack_apps array will run last |
|
269 | + foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
270 | + $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
271 | + } |
|
272 | + // finally, we'll add this on its own because we need it to always be part of the stack |
|
273 | + // and we also need it to always run first because the rest of the system relies on it |
|
274 | + $request_stack_builder->push( |
|
275 | + array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
276 | + ); |
|
277 | + return apply_filters( |
|
278 | + 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
279 | + $request_stack_builder |
|
280 | + ); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | |
284 | 284 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | // load interfaces |
209 | 209 | espresso_load_required( |
210 | 210 | 'EEH_Autoloader', |
211 | - EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
211 | + EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php' |
|
212 | 212 | ); |
213 | 213 | EEH_Autoloader::instance(); |
214 | 214 | } |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | protected function setAutoloadersForRequiredFiles() |
224 | 224 | { |
225 | 225 | // load interfaces |
226 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
226 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true); |
|
227 | 227 | // load helpers |
228 | 228 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
229 | 229 | // register legacy request stack classes just in case |
230 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
230 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS); |
|
231 | 231 | // register legacy middleware classes just in case |
232 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
232 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * so items at the beginning of the final middleware stack will run last. |
248 | 248 | * First parameter is the middleware classname, second is an array of arguments |
249 | 249 | */ |
250 | - $stack_apps = apply_filters( |
|
250 | + $stack_apps = apply_filters( |
|
251 | 251 | 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
252 | 252 | array( |
253 | 253 | // first in last out |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | ) |
261 | 261 | ); |
262 | 262 | // legacy filter for backwards compatibility |
263 | - $stack_apps = apply_filters( |
|
263 | + $stack_apps = apply_filters( |
|
264 | 264 | 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
265 | 265 | $stack_apps |
266 | 266 | ); |
@@ -25,226 +25,226 @@ |
||
25 | 25 | class Mirror |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var ReflectionClass[] $classes |
|
30 | - */ |
|
31 | - private $classes = array(); |
|
32 | - |
|
33 | - /** |
|
34 | - * @var ReflectionMethod[] $constructors |
|
35 | - */ |
|
36 | - private $constructors = array(); |
|
37 | - |
|
38 | - /** |
|
39 | - * @var ReflectionParameter[][] $parameters |
|
40 | - */ |
|
41 | - private $parameters = array(); |
|
42 | - |
|
43 | - /** |
|
44 | - * @var ReflectionParameter[][] $parameters |
|
45 | - */ |
|
46 | - private $parameter_classes = array(); |
|
47 | - |
|
48 | - /** |
|
49 | - * @var ReflectionProperty[][] $properties |
|
50 | - */ |
|
51 | - private $properties = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * @var ReflectionMethod[][] $methods |
|
55 | - */ |
|
56 | - private $methods = array(); |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @param string $class_name |
|
61 | - * @return ReflectionClass |
|
62 | - * @throws ReflectionException |
|
63 | - * @throws InvalidDataTypeException |
|
64 | - */ |
|
65 | - public function getReflectionClass($class_name) |
|
66 | - { |
|
67 | - if (! is_string($class_name)) { |
|
68 | - throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
69 | - } |
|
70 | - if (! isset($this->classes[ $class_name ])) { |
|
71 | - $this->classes[ $class_name ] = new ReflectionClass($class_name); |
|
72 | - } |
|
73 | - return $this->classes[ $class_name ]; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @param string $class_name |
|
79 | - * @return ReflectionMethod |
|
80 | - * @throws InvalidDataTypeException |
|
81 | - * @throws ReflectionException |
|
82 | - */ |
|
83 | - public function getConstructor($class_name) |
|
84 | - { |
|
85 | - if (! is_string($class_name)) { |
|
86 | - throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
87 | - } |
|
88 | - if (! isset($this->constructors[ $class_name ])) { |
|
89 | - $reflection_class = $this->getReflectionClass($class_name); |
|
90 | - $this->constructors[ $class_name ] = $reflection_class->getConstructor(); |
|
91 | - } |
|
92 | - return $this->constructors[ $class_name ]; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param ReflectionClass $reflection_class |
|
98 | - * @return ReflectionMethod |
|
99 | - * @throws InvalidDataTypeException |
|
100 | - * @throws ReflectionException |
|
101 | - */ |
|
102 | - public function getConstructorFromReflection(ReflectionClass $reflection_class) |
|
103 | - { |
|
104 | - return $this->getConstructor($reflection_class->getName()); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $class_name |
|
110 | - * @return ReflectionParameter[] |
|
111 | - * @throws InvalidDataTypeException |
|
112 | - * @throws ReflectionException |
|
113 | - */ |
|
114 | - public function getParameters($class_name) |
|
115 | - { |
|
116 | - if (! isset($this->parameters[ $class_name ])) { |
|
117 | - $constructor = $this->getConstructor($class_name); |
|
118 | - $this->parameters[ $class_name ] = $constructor->getParameters(); |
|
119 | - } |
|
120 | - return $this->parameters[ $class_name ]; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @param ReflectionClass $reflection_class |
|
126 | - * @return ReflectionParameter[] |
|
127 | - * @throws InvalidDataTypeException |
|
128 | - * @throws ReflectionException |
|
129 | - */ |
|
130 | - public function getParametersFromReflection(ReflectionClass $reflection_class) |
|
131 | - { |
|
132 | - return $this->getParameters($reflection_class->getName()); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @param ReflectionMethod $constructor |
|
138 | - * @return ReflectionParameter[] |
|
139 | - * @throws InvalidDataTypeException |
|
140 | - * @throws ReflectionException |
|
141 | - */ |
|
142 | - public function getParametersFromReflectionConstructor(ReflectionMethod $constructor) |
|
143 | - { |
|
144 | - return $this->getParameters($constructor->getDeclaringClass()); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * @param ReflectionParameter $param |
|
150 | - * @param string $class_name |
|
151 | - * @param string $index |
|
152 | - * @return string|null |
|
153 | - */ |
|
154 | - public function getParameterClassName(ReflectionParameter $param, $class_name, $index) |
|
155 | - { |
|
156 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) { |
|
157 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
158 | - } |
|
159 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
160 | - $this->parameter_classes[ $class_name ] = array(); |
|
161 | - } |
|
162 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
163 | - $this->parameter_classes[ $class_name ][ $index ] = array(); |
|
164 | - } |
|
165 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass() |
|
166 | - ? $param->getClass()->name |
|
167 | - : null; |
|
168 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * @param ReflectionParameter $param |
|
174 | - * @param string $class_name |
|
175 | - * @param string $index |
|
176 | - * @return string|null |
|
177 | - */ |
|
178 | - public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index) |
|
179 | - { |
|
180 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) { |
|
181 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
182 | - } |
|
183 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
184 | - $this->parameter_classes[ $class_name ] = array(); |
|
185 | - } |
|
186 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
187 | - $this->parameter_classes[ $class_name ][ $index ] = array(); |
|
188 | - } |
|
189 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable() |
|
190 | - ? $param->getDefaultValue() |
|
191 | - : null; |
|
192 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * @param string $class_name |
|
198 | - * @return ReflectionProperty[] |
|
199 | - * @throws InvalidDataTypeException |
|
200 | - * @throws ReflectionException |
|
201 | - */ |
|
202 | - public function getProperties($class_name) |
|
203 | - { |
|
204 | - if (! isset($this->properties[ $class_name ])) { |
|
205 | - $reflection_class = $this->getReflectionClass($class_name); |
|
206 | - $this->properties[ $class_name ] = $reflection_class->getProperties(); |
|
207 | - } |
|
208 | - return $this->properties[ $class_name ]; |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * @param ReflectionClass $reflection_class |
|
214 | - * @return ReflectionProperty[] |
|
215 | - * @throws InvalidDataTypeException |
|
216 | - * @throws ReflectionException |
|
217 | - */ |
|
218 | - public function getPropertiesFromReflection(ReflectionClass $reflection_class) |
|
219 | - { |
|
220 | - return $this->getProperties($reflection_class->getName()); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * @param string $class_name |
|
226 | - * @return ReflectionMethod[] |
|
227 | - * @throws InvalidDataTypeException |
|
228 | - * @throws ReflectionException |
|
229 | - */ |
|
230 | - public function getMethods($class_name) |
|
231 | - { |
|
232 | - if (! isset($this->methods[ $class_name ])) { |
|
233 | - $reflection_class = $this->getReflectionClass($class_name); |
|
234 | - $this->methods[ $class_name ] = $reflection_class->getMethods(); |
|
235 | - } |
|
236 | - return $this->methods[ $class_name ]; |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @param ReflectionClass $reflection_class ) |
|
242 | - * @return ReflectionMethod[] |
|
243 | - * @throws InvalidDataTypeException |
|
244 | - * @throws ReflectionException |
|
245 | - */ |
|
246 | - public function getMethodsFromReflection(ReflectionClass $reflection_class) |
|
247 | - { |
|
248 | - return $this->getMethods($reflection_class->getName()); |
|
249 | - } |
|
28 | + /** |
|
29 | + * @var ReflectionClass[] $classes |
|
30 | + */ |
|
31 | + private $classes = array(); |
|
32 | + |
|
33 | + /** |
|
34 | + * @var ReflectionMethod[] $constructors |
|
35 | + */ |
|
36 | + private $constructors = array(); |
|
37 | + |
|
38 | + /** |
|
39 | + * @var ReflectionParameter[][] $parameters |
|
40 | + */ |
|
41 | + private $parameters = array(); |
|
42 | + |
|
43 | + /** |
|
44 | + * @var ReflectionParameter[][] $parameters |
|
45 | + */ |
|
46 | + private $parameter_classes = array(); |
|
47 | + |
|
48 | + /** |
|
49 | + * @var ReflectionProperty[][] $properties |
|
50 | + */ |
|
51 | + private $properties = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * @var ReflectionMethod[][] $methods |
|
55 | + */ |
|
56 | + private $methods = array(); |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @param string $class_name |
|
61 | + * @return ReflectionClass |
|
62 | + * @throws ReflectionException |
|
63 | + * @throws InvalidDataTypeException |
|
64 | + */ |
|
65 | + public function getReflectionClass($class_name) |
|
66 | + { |
|
67 | + if (! is_string($class_name)) { |
|
68 | + throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
69 | + } |
|
70 | + if (! isset($this->classes[ $class_name ])) { |
|
71 | + $this->classes[ $class_name ] = new ReflectionClass($class_name); |
|
72 | + } |
|
73 | + return $this->classes[ $class_name ]; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @param string $class_name |
|
79 | + * @return ReflectionMethod |
|
80 | + * @throws InvalidDataTypeException |
|
81 | + * @throws ReflectionException |
|
82 | + */ |
|
83 | + public function getConstructor($class_name) |
|
84 | + { |
|
85 | + if (! is_string($class_name)) { |
|
86 | + throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
87 | + } |
|
88 | + if (! isset($this->constructors[ $class_name ])) { |
|
89 | + $reflection_class = $this->getReflectionClass($class_name); |
|
90 | + $this->constructors[ $class_name ] = $reflection_class->getConstructor(); |
|
91 | + } |
|
92 | + return $this->constructors[ $class_name ]; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param ReflectionClass $reflection_class |
|
98 | + * @return ReflectionMethod |
|
99 | + * @throws InvalidDataTypeException |
|
100 | + * @throws ReflectionException |
|
101 | + */ |
|
102 | + public function getConstructorFromReflection(ReflectionClass $reflection_class) |
|
103 | + { |
|
104 | + return $this->getConstructor($reflection_class->getName()); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $class_name |
|
110 | + * @return ReflectionParameter[] |
|
111 | + * @throws InvalidDataTypeException |
|
112 | + * @throws ReflectionException |
|
113 | + */ |
|
114 | + public function getParameters($class_name) |
|
115 | + { |
|
116 | + if (! isset($this->parameters[ $class_name ])) { |
|
117 | + $constructor = $this->getConstructor($class_name); |
|
118 | + $this->parameters[ $class_name ] = $constructor->getParameters(); |
|
119 | + } |
|
120 | + return $this->parameters[ $class_name ]; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @param ReflectionClass $reflection_class |
|
126 | + * @return ReflectionParameter[] |
|
127 | + * @throws InvalidDataTypeException |
|
128 | + * @throws ReflectionException |
|
129 | + */ |
|
130 | + public function getParametersFromReflection(ReflectionClass $reflection_class) |
|
131 | + { |
|
132 | + return $this->getParameters($reflection_class->getName()); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @param ReflectionMethod $constructor |
|
138 | + * @return ReflectionParameter[] |
|
139 | + * @throws InvalidDataTypeException |
|
140 | + * @throws ReflectionException |
|
141 | + */ |
|
142 | + public function getParametersFromReflectionConstructor(ReflectionMethod $constructor) |
|
143 | + { |
|
144 | + return $this->getParameters($constructor->getDeclaringClass()); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * @param ReflectionParameter $param |
|
150 | + * @param string $class_name |
|
151 | + * @param string $index |
|
152 | + * @return string|null |
|
153 | + */ |
|
154 | + public function getParameterClassName(ReflectionParameter $param, $class_name, $index) |
|
155 | + { |
|
156 | + if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) { |
|
157 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
158 | + } |
|
159 | + if (! isset($this->parameter_classes[ $class_name ])) { |
|
160 | + $this->parameter_classes[ $class_name ] = array(); |
|
161 | + } |
|
162 | + if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
163 | + $this->parameter_classes[ $class_name ][ $index ] = array(); |
|
164 | + } |
|
165 | + $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass() |
|
166 | + ? $param->getClass()->name |
|
167 | + : null; |
|
168 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * @param ReflectionParameter $param |
|
174 | + * @param string $class_name |
|
175 | + * @param string $index |
|
176 | + * @return string|null |
|
177 | + */ |
|
178 | + public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index) |
|
179 | + { |
|
180 | + if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) { |
|
181 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
182 | + } |
|
183 | + if (! isset($this->parameter_classes[ $class_name ])) { |
|
184 | + $this->parameter_classes[ $class_name ] = array(); |
|
185 | + } |
|
186 | + if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
187 | + $this->parameter_classes[ $class_name ][ $index ] = array(); |
|
188 | + } |
|
189 | + $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable() |
|
190 | + ? $param->getDefaultValue() |
|
191 | + : null; |
|
192 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * @param string $class_name |
|
198 | + * @return ReflectionProperty[] |
|
199 | + * @throws InvalidDataTypeException |
|
200 | + * @throws ReflectionException |
|
201 | + */ |
|
202 | + public function getProperties($class_name) |
|
203 | + { |
|
204 | + if (! isset($this->properties[ $class_name ])) { |
|
205 | + $reflection_class = $this->getReflectionClass($class_name); |
|
206 | + $this->properties[ $class_name ] = $reflection_class->getProperties(); |
|
207 | + } |
|
208 | + return $this->properties[ $class_name ]; |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * @param ReflectionClass $reflection_class |
|
214 | + * @return ReflectionProperty[] |
|
215 | + * @throws InvalidDataTypeException |
|
216 | + * @throws ReflectionException |
|
217 | + */ |
|
218 | + public function getPropertiesFromReflection(ReflectionClass $reflection_class) |
|
219 | + { |
|
220 | + return $this->getProperties($reflection_class->getName()); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * @param string $class_name |
|
226 | + * @return ReflectionMethod[] |
|
227 | + * @throws InvalidDataTypeException |
|
228 | + * @throws ReflectionException |
|
229 | + */ |
|
230 | + public function getMethods($class_name) |
|
231 | + { |
|
232 | + if (! isset($this->methods[ $class_name ])) { |
|
233 | + $reflection_class = $this->getReflectionClass($class_name); |
|
234 | + $this->methods[ $class_name ] = $reflection_class->getMethods(); |
|
235 | + } |
|
236 | + return $this->methods[ $class_name ]; |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @param ReflectionClass $reflection_class ) |
|
242 | + * @return ReflectionMethod[] |
|
243 | + * @throws InvalidDataTypeException |
|
244 | + * @throws ReflectionException |
|
245 | + */ |
|
246 | + public function getMethodsFromReflection(ReflectionClass $reflection_class) |
|
247 | + { |
|
248 | + return $this->getMethods($reflection_class->getName()); |
|
249 | + } |
|
250 | 250 | } |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getReflectionClass($class_name) |
66 | 66 | { |
67 | - if (! is_string($class_name)) { |
|
67 | + if ( ! is_string($class_name)) { |
|
68 | 68 | throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
69 | 69 | } |
70 | - if (! isset($this->classes[ $class_name ])) { |
|
71 | - $this->classes[ $class_name ] = new ReflectionClass($class_name); |
|
70 | + if ( ! isset($this->classes[$class_name])) { |
|
71 | + $this->classes[$class_name] = new ReflectionClass($class_name); |
|
72 | 72 | } |
73 | - return $this->classes[ $class_name ]; |
|
73 | + return $this->classes[$class_name]; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getConstructor($class_name) |
84 | 84 | { |
85 | - if (! is_string($class_name)) { |
|
85 | + if ( ! is_string($class_name)) { |
|
86 | 86 | throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
87 | 87 | } |
88 | - if (! isset($this->constructors[ $class_name ])) { |
|
88 | + if ( ! isset($this->constructors[$class_name])) { |
|
89 | 89 | $reflection_class = $this->getReflectionClass($class_name); |
90 | - $this->constructors[ $class_name ] = $reflection_class->getConstructor(); |
|
90 | + $this->constructors[$class_name] = $reflection_class->getConstructor(); |
|
91 | 91 | } |
92 | - return $this->constructors[ $class_name ]; |
|
92 | + return $this->constructors[$class_name]; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getParameters($class_name) |
115 | 115 | { |
116 | - if (! isset($this->parameters[ $class_name ])) { |
|
116 | + if ( ! isset($this->parameters[$class_name])) { |
|
117 | 117 | $constructor = $this->getConstructor($class_name); |
118 | - $this->parameters[ $class_name ] = $constructor->getParameters(); |
|
118 | + $this->parameters[$class_name] = $constructor->getParameters(); |
|
119 | 119 | } |
120 | - return $this->parameters[ $class_name ]; |
|
120 | + return $this->parameters[$class_name]; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
@@ -153,19 +153,19 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function getParameterClassName(ReflectionParameter $param, $class_name, $index) |
155 | 155 | { |
156 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) { |
|
157 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
156 | + if (isset($this->parameter_classes[$class_name][$index]['param_class_name'])) { |
|
157 | + return $this->parameter_classes[$class_name][$index]['param_class_name']; |
|
158 | 158 | } |
159 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
160 | - $this->parameter_classes[ $class_name ] = array(); |
|
159 | + if ( ! isset($this->parameter_classes[$class_name])) { |
|
160 | + $this->parameter_classes[$class_name] = array(); |
|
161 | 161 | } |
162 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
163 | - $this->parameter_classes[ $class_name ][ $index ] = array(); |
|
162 | + if ( ! isset($this->parameter_classes[$class_name][$index])) { |
|
163 | + $this->parameter_classes[$class_name][$index] = array(); |
|
164 | 164 | } |
165 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass() |
|
165 | + $this->parameter_classes[$class_name][$index]['param_class_name'] = $param->getClass() |
|
166 | 166 | ? $param->getClass()->name |
167 | 167 | : null; |
168 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
168 | + return $this->parameter_classes[$class_name][$index]['param_class_name']; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index) |
179 | 179 | { |
180 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) { |
|
181 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
180 | + if (isset($this->parameter_classes[$class_name][$index]['param_class_default'])) { |
|
181 | + return $this->parameter_classes[$class_name][$index]['param_class_default']; |
|
182 | 182 | } |
183 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
184 | - $this->parameter_classes[ $class_name ] = array(); |
|
183 | + if ( ! isset($this->parameter_classes[$class_name])) { |
|
184 | + $this->parameter_classes[$class_name] = array(); |
|
185 | 185 | } |
186 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
187 | - $this->parameter_classes[ $class_name ][ $index ] = array(); |
|
186 | + if ( ! isset($this->parameter_classes[$class_name][$index])) { |
|
187 | + $this->parameter_classes[$class_name][$index] = array(); |
|
188 | 188 | } |
189 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable() |
|
189 | + $this->parameter_classes[$class_name][$index]['param_class_default'] = $param->isDefaultValueAvailable() |
|
190 | 190 | ? $param->getDefaultValue() |
191 | 191 | : null; |
192 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
192 | + return $this->parameter_classes[$class_name][$index]['param_class_default']; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function getProperties($class_name) |
203 | 203 | { |
204 | - if (! isset($this->properties[ $class_name ])) { |
|
204 | + if ( ! isset($this->properties[$class_name])) { |
|
205 | 205 | $reflection_class = $this->getReflectionClass($class_name); |
206 | - $this->properties[ $class_name ] = $reflection_class->getProperties(); |
|
206 | + $this->properties[$class_name] = $reflection_class->getProperties(); |
|
207 | 207 | } |
208 | - return $this->properties[ $class_name ]; |
|
208 | + return $this->properties[$class_name]; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function getMethods($class_name) |
231 | 231 | { |
232 | - if (! isset($this->methods[ $class_name ])) { |
|
232 | + if ( ! isset($this->methods[$class_name])) { |
|
233 | 233 | $reflection_class = $this->getReflectionClass($class_name); |
234 | - $this->methods[ $class_name ] = $reflection_class->getMethods(); |
|
234 | + $this->methods[$class_name] = $reflection_class->getMethods(); |
|
235 | 235 | } |
236 | - return $this->methods[ $class_name ]; |
|
236 | + return $this->methods[$class_name]; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 |
@@ -21,54 +21,54 @@ |
||
21 | 21 | class FullyQualifiedName |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var string $fully_qualified_name |
|
26 | - */ |
|
27 | - private $fully_qualified_name; |
|
24 | + /** |
|
25 | + * @var string $fully_qualified_name |
|
26 | + */ |
|
27 | + private $fully_qualified_name; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * FullyQualifiedName constructor. |
|
32 | - * |
|
33 | - * @param string $fully_qualified_name |
|
34 | - * @throws InvalidClassException |
|
35 | - * @throws InvalidInterfaceException |
|
36 | - * @throws InvalidDataTypeException |
|
37 | - */ |
|
38 | - public function __construct($fully_qualified_name) |
|
39 | - { |
|
40 | - if (! is_string($fully_qualified_name)) { |
|
41 | - throw new InvalidDataTypeException( |
|
42 | - '$fully_qualified_name', |
|
43 | - $fully_qualified_name, |
|
44 | - 'string' |
|
45 | - ); |
|
46 | - } |
|
47 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
49 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
50 | - } |
|
51 | - throw new InvalidClassException($fully_qualified_name); |
|
52 | - } |
|
53 | - $this->fully_qualified_name = $fully_qualified_name; |
|
54 | - } |
|
30 | + /** |
|
31 | + * FullyQualifiedName constructor. |
|
32 | + * |
|
33 | + * @param string $fully_qualified_name |
|
34 | + * @throws InvalidClassException |
|
35 | + * @throws InvalidInterfaceException |
|
36 | + * @throws InvalidDataTypeException |
|
37 | + */ |
|
38 | + public function __construct($fully_qualified_name) |
|
39 | + { |
|
40 | + if (! is_string($fully_qualified_name)) { |
|
41 | + throw new InvalidDataTypeException( |
|
42 | + '$fully_qualified_name', |
|
43 | + $fully_qualified_name, |
|
44 | + 'string' |
|
45 | + ); |
|
46 | + } |
|
47 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
49 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
50 | + } |
|
51 | + throw new InvalidClassException($fully_qualified_name); |
|
52 | + } |
|
53 | + $this->fully_qualified_name = $fully_qualified_name; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function string() |
|
61 | - { |
|
62 | - return $this->fully_qualified_name; |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function string() |
|
61 | + { |
|
62 | + return $this->fully_qualified_name; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function __toString() |
|
70 | - { |
|
71 | - return $this->fully_qualified_name; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function __toString() |
|
70 | + { |
|
71 | + return $this->fully_qualified_name; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | } |