@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | private function checkDirectory(string $sDirectory): string |
81 | 81 | { |
82 | 82 | $sDirectory = rtrim(trim($sDirectory), '/\\'); |
83 | - if(!is_dir($sDirectory)) |
|
83 | + if (!is_dir($sDirectory)) |
|
84 | 84 | { |
85 | 85 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
86 | 86 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function checkOptions(string $sCallable, $xOptions): array |
95 | 95 | { |
96 | - if(is_string($xOptions)) |
|
96 | + if (is_string($xOptions)) |
|
97 | 97 | { |
98 | 98 | $xOptions = ['namespace' => $xOptions]; |
99 | 99 | } |
100 | - if(!is_array($xOptions)) |
|
100 | + if (!is_array($xOptions)) |
|
101 | 101 | { |
102 | 102 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
103 | 103 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $xOptions['directory'] = $this->checkDirectory($sCallable); |
106 | 106 | // Check the namespace |
107 | 107 | $sNamespace = $xOptions['namespace'] ?? ''; |
108 | - if(!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
108 | + if (!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
109 | 109 | { |
110 | 110 | $xOptions['namespace'] = ''; |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Change the keys in $xOptions to have "\" as separator |
114 | 114 | $_aOptions = []; |
115 | - foreach($xOptions as $sName => $aOption) |
|
115 | + foreach ($xOptions as $sName => $aOption) |
|
116 | 116 | { |
117 | 117 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
118 | 118 | $_aOptions[$sName] = $aOption; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function register(string $sType, string $sCallable, array $aOptions): bool |
127 | 127 | { |
128 | - if(($aOptions['namespace'])) |
|
128 | + if (($aOptions['namespace'])) |
|
129 | 129 | { |
130 | 130 | $this->xRegistry->addNamespace($aOptions['namespace'], $aOptions); |
131 | 131 | return true; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->xRepository = $xRepository; |
90 | 90 | |
91 | 91 | // Set the composer autoloader |
92 | - if(file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) || |
|
92 | + if (file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) || |
|
93 | 93 | file_exists(($sAutoloadFile = __DIR__ . '/../../../../vendor/autoload.php'))) |
94 | 94 | { |
95 | 95 | $this->xAutoloader = require($sAutoloadFile); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function addDirectory(string $sDirectory, array $aOptions) |
107 | 107 | { |
108 | 108 | // Set the autoload option default value |
109 | - if(!isset($aOptions['autoload'])) |
|
109 | + if (!isset($aOptions['autoload'])) |
|
110 | 110 | { |
111 | 111 | $aOptions['autoload'] = true; |
112 | 112 | } |
@@ -123,26 +123,26 @@ discard block |
||
123 | 123 | public function addNamespace(string $sNamespace, array $aOptions) |
124 | 124 | { |
125 | 125 | // Separator default value |
126 | - if(!isset($aOptions['separator'])) |
|
126 | + if (!isset($aOptions['separator'])) |
|
127 | 127 | { |
128 | 128 | $aOptions['separator'] = '.'; |
129 | 129 | } |
130 | 130 | $aOptions['separator'] = trim($aOptions['separator']); |
131 | - if(!in_array($aOptions['separator'], ['.', '_'])) |
|
131 | + if (!in_array($aOptions['separator'], ['.', '_'])) |
|
132 | 132 | { |
133 | 133 | $aOptions['separator'] = '.'; |
134 | 134 | } |
135 | - if($aOptions['separator'] === '_') |
|
135 | + if ($aOptions['separator'] === '_') |
|
136 | 136 | { |
137 | 137 | $this->bUsingUnderscore = true; |
138 | 138 | } |
139 | 139 | // Set the autoload option default value |
140 | - if(!isset($aOptions['autoload'])) |
|
140 | + if (!isset($aOptions['autoload'])) |
|
141 | 141 | { |
142 | 142 | $aOptions['autoload'] = true; |
143 | 143 | } |
144 | 144 | // Register the dir with PSR4 autoloading |
145 | - if(($aOptions['autoload']) && $this->xAutoloader != null) |
|
145 | + if (($aOptions['autoload']) && $this->xAutoloader != null) |
|
146 | 146 | { |
147 | 147 | $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']); |
148 | 148 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public function parseDirectories() |
158 | 158 | { |
159 | 159 | // This is to be done only once. |
160 | - if($this->bDirectoriesParsed) |
|
160 | + if ($this->bDirectoriesParsed) |
|
161 | 161 | { |
162 | 162 | return; |
163 | 163 | } |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | |
166 | 166 | // Browse directories without namespaces and read all the files. |
167 | 167 | $aClassMap = []; |
168 | - foreach($this->xRepository->getDirectoryOptions() as $sDirectory => $aOptions) |
|
168 | + foreach ($this->xRepository->getDirectoryOptions() as $sDirectory => $aOptions) |
|
169 | 169 | { |
170 | 170 | $itFile = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDirectory)); |
171 | 171 | // Iterate on dir content |
172 | - foreach($itFile as $xFile) |
|
172 | + foreach ($itFile as $xFile) |
|
173 | 173 | { |
174 | 174 | // Skip everything except PHP files |
175 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
175 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
176 | 176 | { |
177 | 177 | continue; |
178 | 178 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $sClassName = $xFile->getBasename('.php'); |
181 | 181 | $aClassOptions = ['timestamp' => $xFile->getMTime()]; |
182 | 182 | // No more classmap autoloading. The file will be included when needed. |
183 | - if(($aOptions['autoload'])) |
|
183 | + if (($aOptions['autoload'])) |
|
184 | 184 | { |
185 | 185 | $aClassMap[$sClassName] = $xFile->getPathname(); |
186 | 186 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | // Set classmap autoloading |
191 | - if(($aClassMap) && $this->xAutoloader !== null) |
|
191 | + if (($aClassMap) && $this->xAutoloader !== null) |
|
192 | 192 | { |
193 | 193 | $this->xAutoloader->addClassMap($aClassMap); |
194 | 194 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | public function parseNamespaces() |
203 | 203 | { |
204 | 204 | // This is to be done only once. |
205 | - if($this->bNamespacesParsed) |
|
205 | + if ($this->bNamespacesParsed) |
|
206 | 206 | { |
207 | 207 | return; |
208 | 208 | } |
@@ -210,17 +210,17 @@ discard block |
||
210 | 210 | |
211 | 211 | // Browse directories with namespaces and read all the files. |
212 | 212 | $sDS = DIRECTORY_SEPARATOR; |
213 | - foreach($this->xRepository->getNamespaceOptions() as $sNamespace => $aOptions) |
|
213 | + foreach ($this->xRepository->getNamespaceOptions() as $sNamespace => $aOptions) |
|
214 | 214 | { |
215 | 215 | $this->xRepository->addNamespace($sNamespace, ['separator' => $aOptions['separator']]); |
216 | 216 | |
217 | 217 | // Iterate on dir content |
218 | 218 | $sDirectory = $aOptions['directory']; |
219 | 219 | $itFile = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDirectory)); |
220 | - foreach($itFile as $xFile) |
|
220 | + foreach ($itFile as $xFile) |
|
221 | 221 | { |
222 | 222 | // skip everything except PHP files |
223 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
223 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
224 | 224 | { |
225 | 225 | continue; |
226 | 226 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $sClassPath = $sNamespace; |
230 | 230 | $sRelativePath = substr($xFile->getPath(), strlen($sDirectory)); |
231 | 231 | $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\'); |
232 | - if($sRelativePath !== '') |
|
232 | + if ($sRelativePath !== '') |
|
233 | 233 | { |
234 | 234 | $sClassPath .= '\\' . $sRelativePath; |
235 | 235 | } |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | // Replace all separators ('.' and '_') with antislashes, and remove the antislashes |
257 | 257 | // at the beginning and the end of the class name. |
258 | 258 | $sClassName = trim(str_replace('.', '\\', $sClassName), '\\'); |
259 | - if($this->bUsingUnderscore) |
|
259 | + if ($this->bUsingUnderscore) |
|
260 | 260 | { |
261 | 261 | $sClassName = trim(str_replace('_', '\\', $sClassName), '\\'); |
262 | 262 | } |
263 | 263 | // Register the class, if it wasn't already. |
264 | - if(!$this->di->h($sClassName)) |
|
264 | + if (!$this->di->h($sClassName)) |
|
265 | 265 | { |
266 | 266 | $this->di->registerCallableClass($sClassName, $this->xRepository->getClassOptions($sClassName)); |
267 | 267 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | // The methods of the CallableClass class must not be exported |
112 | 112 | $xCallableClass = new ReflectionClass(CallableClass::class); |
113 | - foreach($xCallableClass->getMethods(ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
113 | + foreach ($xCallableClass->getMethods(ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
114 | 114 | { |
115 | 115 | $this->aProtectedMethods[] = $xMethod->getName(); |
116 | 116 | } |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function makeClassOptions(string $sClassName, array $aClassOptions, array $aDirectoryOptions): array |
183 | 183 | { |
184 | - foreach($this->aDefaultClassOptions as $sOption => $xValue) |
|
184 | + foreach ($this->aDefaultClassOptions as $sOption => $xValue) |
|
185 | 185 | { |
186 | - if(!isset($aClassOptions[$sOption])) |
|
186 | + if (!isset($aClassOptions[$sOption])) |
|
187 | 187 | { |
188 | 188 | $aClassOptions[$sOption] = $xValue; |
189 | 189 | } |
190 | 190 | } |
191 | - if(is_string($aClassOptions['protected'])) |
|
191 | + if (is_string($aClassOptions['protected'])) |
|
192 | 192 | { |
193 | 193 | $aClassOptions['protected'] = [$aClassOptions['protected']]; // Convert to array. |
194 | 194 | } |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | $aDirectoryOptions['classes']['*'] ?? [], // Options for all classes |
200 | 200 | $aDirectoryOptions['classes'][$sClassName] ?? [], // Options for this specific class |
201 | 201 | ]; |
202 | - foreach($aOptionGroups as $aOptionGroup) |
|
202 | + foreach ($aOptionGroups as $aOptionGroup) |
|
203 | 203 | { |
204 | - if(isset($aOptionGroup['separator'])) |
|
204 | + if (isset($aOptionGroup['separator'])) |
|
205 | 205 | { |
206 | 206 | $aClassOptions['separator'] = $aOptionGroup['separator']; |
207 | 207 | } |
208 | - if(isset($aOptionGroup['protected'])) |
|
208 | + if (isset($aOptionGroup['protected'])) |
|
209 | 209 | { |
210 | - if(is_string($aOptionGroup['protected'])) |
|
210 | + if (is_string($aOptionGroup['protected'])) |
|
211 | 211 | { |
212 | 212 | $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array. |
213 | 213 | } |
214 | 214 | $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']); |
215 | 215 | } |
216 | - if(isset($aOptionGroup['functions'])) |
|
216 | + if (isset($aOptionGroup['functions'])) |
|
217 | 217 | { |
218 | 218 | $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']); |
219 | 219 | } |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | private function getNamespaceClassOptions(string $sClassName) |
260 | 260 | { |
261 | 261 | // Find the corresponding namespace |
262 | - foreach($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
262 | + foreach ($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
263 | 263 | { |
264 | 264 | // Check if the namespace matches the class. |
265 | - if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0) |
|
265 | + if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0) |
|
266 | 266 | { |
267 | 267 | // Save the class options |
268 | 268 | $this->aClasses[$sClassName] = $this->makeClassOptions($sClassName, |
@@ -283,17 +283,17 @@ discard block |
||
283 | 283 | public function getClassOptions(string $sClassName): array |
284 | 284 | { |
285 | 285 | // Find options for a class registered with namespace. |
286 | - if(!isset($this->aClasses[$sClassName])) |
|
286 | + if (!isset($this->aClasses[$sClassName])) |
|
287 | 287 | { |
288 | 288 | $this->getNamespaceClassOptions($sClassName); |
289 | - if(!isset($this->aClasses[$sClassName])) |
|
289 | + if (!isset($this->aClasses[$sClassName])) |
|
290 | 290 | { |
291 | 291 | // Find options for a class registered without namespace. |
292 | 292 | // We then need to parse all classes to be able to find one. |
293 | 293 | $this->di->getCallableRegistry()->parseDirectories(); |
294 | 294 | } |
295 | 295 | } |
296 | - if(isset($this->aClasses[$sClassName])) |
|
296 | + if (isset($this->aClasses[$sClassName])) |
|
297 | 297 | { |
298 | 298 | return $this->aClasses[$sClassName]; |
299 | 299 | } |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | public function getCallableObjects(): array |
323 | 323 | { |
324 | 324 | $aCallableObjects = []; |
325 | - foreach($this->aClasses as $sClassName => $aOptions) |
|
325 | + foreach ($this->aClasses as $sClassName => $aOptions) |
|
326 | 326 | { |
327 | - if(!$this->di->h($sClassName)) |
|
327 | + if (!$this->di->h($sClassName)) |
|
328 | 328 | { |
329 | 329 | $this->di->registerCallableClass($sClassName, $aOptions); |
330 | 330 | } |
@@ -207,36 +207,36 @@ |
||
207 | 207 | switch($sName) |
208 | 208 | { |
209 | 209 | // Set the separator |
210 | - case 'separator': |
|
211 | - if($xValue === '_' || $xValue === '.') |
|
212 | - { |
|
213 | - $this->sSeparator = $xValue; |
|
214 | - } |
|
215 | - break; |
|
216 | - // Set the protected methods |
|
217 | - case 'protected': |
|
218 | - if(is_array($xValue)) |
|
219 | - { |
|
220 | - $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
|
221 | - } |
|
222 | - break; |
|
223 | - // Set the methods to call before processing the request |
|
224 | - case '__before': |
|
225 | - $this->setHookMethods($this->aBeforeMethods, $xValue); |
|
226 | - break; |
|
227 | - // Set the methods to call after processing the request |
|
228 | - case '__after': |
|
229 | - $this->setHookMethods($this->aAfterMethods, $xValue); |
|
230 | - break; |
|
231 | - // Set the attributes to inject in the callable object |
|
232 | - case '__di': |
|
233 | - $this->aAttributes = array_merge($this->aAttributes, $xValue); |
|
234 | - break; |
|
235 | - case 'excluded': |
|
236 | - $this->bExcluded = (bool)$xValue; |
|
237 | - break; |
|
238 | - default: |
|
239 | - break; |
|
210 | + case 'separator': |
|
211 | + if($xValue === '_' || $xValue === '.') |
|
212 | + { |
|
213 | + $this->sSeparator = $xValue; |
|
214 | + } |
|
215 | + break; |
|
216 | + // Set the protected methods |
|
217 | + case 'protected': |
|
218 | + if(is_array($xValue)) |
|
219 | + { |
|
220 | + $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
|
221 | + } |
|
222 | + break; |
|
223 | + // Set the methods to call before processing the request |
|
224 | + case '__before': |
|
225 | + $this->setHookMethods($this->aBeforeMethods, $xValue); |
|
226 | + break; |
|
227 | + // Set the methods to call after processing the request |
|
228 | + case '__after': |
|
229 | + $this->setHookMethods($this->aAfterMethods, $xValue); |
|
230 | + break; |
|
231 | + // Set the attributes to inject in the callable object |
|
232 | + case '__di': |
|
233 | + $this->aAttributes = array_merge($this->aAttributes, $xValue); |
|
234 | + break; |
|
235 | + case 'excluded': |
|
236 | + $this->bExcluded = (bool)$xValue; |
|
237 | + break; |
|
238 | + default: |
|
239 | + break; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 |
@@ -186,8 +186,7 @@ |
||
186 | 186 | if(is_array($xMethodToCall)) |
187 | 187 | { |
188 | 188 | $aHookMethods[$sCalledMethod] = $xMethodToCall; |
189 | - } |
|
190 | - elseif(is_string($xMethodToCall)) |
|
189 | + } elseif(is_string($xMethodToCall)) |
|
191 | 190 | { |
192 | 191 | $aHookMethods[$sCalledMethod] = [$xMethodToCall]; |
193 | 192 | } |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | */ |
194 | 194 | private function setHookMethods(array &$aHookMethods, $xValue) |
195 | 195 | { |
196 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
196 | + foreach ($xValue as $sCalledMethod => $xMethodToCall) |
|
197 | 197 | { |
198 | - if(is_array($xMethodToCall)) |
|
198 | + if (is_array($xMethodToCall)) |
|
199 | 199 | { |
200 | 200 | $aHookMethods[$sCalledMethod] = $xMethodToCall; |
201 | 201 | } |
202 | - elseif(is_string($xMethodToCall)) |
|
202 | + elseif (is_string($xMethodToCall)) |
|
203 | 203 | { |
204 | 204 | $aHookMethods[$sCalledMethod] = [$xMethodToCall]; |
205 | 205 | } |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function configure(string $sName, $xValue) |
218 | 218 | { |
219 | - switch($sName) |
|
219 | + switch ($sName) |
|
220 | 220 | { |
221 | 221 | // Set the separator |
222 | 222 | case 'separator': |
223 | - if($xValue === '_' || $xValue === '.') |
|
223 | + if ($xValue === '_' || $xValue === '.') |
|
224 | 224 | { |
225 | 225 | $this->sSeparator = $xValue; |
226 | 226 | } |
227 | 227 | break; |
228 | 228 | // Set the protected methods |
229 | 229 | case 'protected': |
230 | - if(is_array($xValue)) |
|
230 | + if (is_array($xValue)) |
|
231 | 231 | { |
232 | 232 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
233 | 233 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $this->aAttributes = array_merge($this->aAttributes, $xValue); |
246 | 246 | break; |
247 | 247 | case 'excluded': |
248 | - $this->bExcluded = (bool)$xValue; |
|
248 | + $this->bExcluded = (bool) $xValue; |
|
249 | 249 | break; |
250 | 250 | default: |
251 | 251 | break; |
@@ -295,16 +295,16 @@ discard block |
||
295 | 295 | */ |
296 | 296 | private function getOptionValue(array $aCommonOptions, array $aMethodOptions, string $sOptionName) |
297 | 297 | { |
298 | - if(!isset($aCommonOptions[$sOptionName])) |
|
298 | + if (!isset($aCommonOptions[$sOptionName])) |
|
299 | 299 | { |
300 | 300 | return $aMethodOptions[$sOptionName]; |
301 | 301 | } |
302 | - if(!isset($aMethodOptions[$sOptionName])) |
|
302 | + if (!isset($aMethodOptions[$sOptionName])) |
|
303 | 303 | { |
304 | 304 | return $aCommonOptions[$sOptionName]; |
305 | 305 | } |
306 | 306 | // If both are not arrays, return the latest. |
307 | - if(!is_array($aCommonOptions[$sOptionName]) && !is_array($aMethodOptions[$sOptionName])) |
|
307 | + if (!is_array($aCommonOptions[$sOptionName]) && !is_array($aMethodOptions[$sOptionName])) |
|
308 | 308 | { |
309 | 309 | return $aMethodOptions[$sOptionName]; |
310 | 310 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $aMethodOptions = isset($this->aOptions[$sMethodName]) ? $this->aOptions[$sMethodName] : []; |
329 | 329 | $aOptionNames = array_unique(array_merge(array_keys($aCommonOptions), array_keys($aMethodOptions))); |
330 | 330 | $aOptions = []; |
331 | - foreach($aOptionNames as $sOptionName) |
|
331 | + foreach ($aOptionNames as $sOptionName) |
|
332 | 332 | { |
333 | 333 | $aOptions[$sOptionName] = $this->getOptionValue($aCommonOptions, $aMethodOptions, $sOptionName); |
334 | 334 | } |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | // $aMethods = $aHookMethods[$sMethod] ?? $aHookMethods['*'] ?? []; |
413 | 413 | // The hooks defined at method level are merged with those defined at class level. |
414 | 414 | $aMethods = array_merge($aHookMethods['*'] ?? [], $aHookMethods[$sMethod] ?? []); |
415 | - foreach($aMethods as $xKey => $xValue) |
|
415 | + foreach ($aMethods as $xKey => $xValue) |
|
416 | 416 | { |
417 | 417 | $sHookName = $xValue; |
418 | 418 | $aHookArgs = []; |
419 | - if(is_string($xKey)) |
|
419 | + if (is_string($xKey)) |
|
420 | 420 | { |
421 | 421 | $sHookName = $xKey; |
422 | 422 | $aHookArgs = is_array($xValue) ? $xValue : [$xValue]; |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | // $aAttributes = $this->aAttributes[$sMethod] ?? $this->aAttributes['*'] ?? []; |
458 | 458 | // The attributes defined at method level are merged with those defined at class level. |
459 | 459 | $aAttributes = array_merge($this->aAttributes['*'] ?? [], $this->aAttributes[$sMethod] ?? []); |
460 | - foreach($aAttributes as $sName => $sClass) |
|
460 | + foreach ($aAttributes as $sName => $sClass) |
|
461 | 461 | { |
462 | 462 | // Set the protected attributes of the object |
463 | 463 | $cSetter = function($c) use($sName, $sClass) { |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | } |
470 | 470 | |
471 | 471 | // Set the Jaxon request target in the helper |
472 | - if($this->xRegisteredObject instanceof CallableClass) |
|
472 | + if ($this->xRegisteredObject instanceof CallableClass) |
|
473 | 473 | { |
474 | 474 | // Set the protected attributes of the object |
475 | 475 | $cSetter = function() use($xTarget) { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function setDataBag() |
41 | 41 | { |
42 | - if($this->xDataBag !== null) |
|
42 | + if ($this->xDataBag !== null) |
|
43 | 43 | { |
44 | 44 | return; |
45 | 45 | } |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | $aBody = $xRequest->getParsedBody(); |
49 | 49 | $aParams = $xRequest->getQueryParams(); |
50 | 50 | $aData = is_array($aBody) ? |
51 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
52 | - $this->readData($aParams['jxnbags'] ?? []); |
|
51 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
53 | 52 | $this->xDataBag = new DataBag($aData); |
54 | 53 | } |
55 | 54 | |
@@ -69,7 +68,7 @@ discard block |
||
69 | 68 | private function readData($xData): array |
70 | 69 | { |
71 | 70 | // Todo: clean input data. |
72 | - if(is_string($xData)) |
|
71 | + if (is_string($xData)) |
|
73 | 72 | { |
74 | 73 | return json_decode($xData, true) ?: []; |
75 | 74 | } |
@@ -105,7 +104,7 @@ discard block |
||
105 | 104 | public function writeCommand() |
106 | 105 | { |
107 | 106 | $this->setDataBag(); |
108 | - if($this->xDataBag->touched()) |
|
107 | + if ($this->xDataBag->touched()) |
|
109 | 108 | { |
110 | 109 | $this->addCommand(['cmd' => 'bags.set'], $this->xDataBag->getAll()); |
111 | 110 | } |
@@ -126,7 +126,7 @@ |
||
126 | 126 | */ |
127 | 127 | private function getLibraries(): array |
128 | 128 | { |
129 | - if($this->aLibraries === null) |
|
129 | + if ($this->aLibraries === null) |
|
130 | 130 | { |
131 | 131 | $this->aLibraries = $this->xLibraryManager->getLibraries(); |
132 | 132 | } |
@@ -63,12 +63,10 @@ |
||
63 | 63 | if(!$sPath) |
64 | 64 | { |
65 | 65 | $this->sPath = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead |
66 | - } |
|
67 | - elseif(($sContext)) |
|
66 | + } elseif(($sContext)) |
|
68 | 67 | { |
69 | 68 | $this->sPath = "$jQueryNs('" . $sPath . "', $jQueryNs('" . $sContext . "'))"; |
70 | - } |
|
71 | - else |
|
69 | + } else |
|
72 | 70 | { |
73 | 71 | $this->sPath = "$jQueryNs('" . $sPath . "')"; |
74 | 72 | } |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | $sContext = trim($sContext, " \t"); |
68 | 68 | $this->aCalls = []; |
69 | 69 | |
70 | - if(!$sPath) |
|
70 | + if (!$sPath) |
|
71 | 71 | { |
72 | 72 | $this->sPath = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead |
73 | 73 | } |
74 | - elseif(($sContext)) |
|
74 | + elseif (($sContext)) |
|
75 | 75 | { |
76 | 76 | $this->sPath = "$jQueryNs('" . $sPath . "', $jQueryNs('" . $sContext . "'))"; |
77 | 77 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public function getScript(): string |
146 | 146 | { |
147 | 147 | $sScript = $this->sPath; |
148 | - if(count($this->aCalls) > 0) |
|
148 | + if (count($this->aCalls) > 0) |
|
149 | 149 | { |
150 | 150 | $sScript .= '.' . implode('.', $this->aCalls); |
151 | 151 | } |
@@ -87,7 +87,7 @@ |
||
87 | 87 | public function selector(string $sPath = '', string $sContext = ''): DomSelector |
88 | 88 | { |
89 | 89 | $xSelector = new DomSelector($this->jQueryNs, $sPath, $sContext); |
90 | - if($this->bCommand && $this->response() !== null) |
|
90 | + if ($this->bCommand && $this->response() !== null) |
|
91 | 91 | { |
92 | 92 | $this->addCommand(['cmd' => 'jquery'], $xSelector); |
93 | 93 | } |
@@ -85,28 +85,28 @@ discard block |
||
85 | 85 | private function updateContainer(Config $xConfig) |
86 | 86 | { |
87 | 87 | $aOptions = $xConfig->getOption('container.set', []); |
88 | - foreach($aOptions as $xKey => $xValue) |
|
88 | + foreach ($aOptions as $xKey => $xValue) |
|
89 | 89 | { |
90 | 90 | // The key is the class name. It must be a string. |
91 | - $this->di->set((string)$xKey, $xValue); |
|
91 | + $this->di->set((string) $xKey, $xValue); |
|
92 | 92 | } |
93 | 93 | $aOptions = $xConfig->getOption('container.val', []); |
94 | - foreach($aOptions as $xKey => $xValue) |
|
94 | + foreach ($aOptions as $xKey => $xValue) |
|
95 | 95 | { |
96 | 96 | // The key is the class name. It must be a string. |
97 | - $this->di->val((string)$xKey, $xValue); |
|
97 | + $this->di->val((string) $xKey, $xValue); |
|
98 | 98 | } |
99 | 99 | $aOptions = $xConfig->getOption('container.auto', []); |
100 | - foreach($aOptions as $xValue) |
|
100 | + foreach ($aOptions as $xValue) |
|
101 | 101 | { |
102 | 102 | // The key is the class name. It must be a string. |
103 | - $this->di->auto((string)$xValue); |
|
103 | + $this->di->auto((string) $xValue); |
|
104 | 104 | } |
105 | 105 | $aOptions = $xConfig->getOption('container.alias', []); |
106 | - foreach($aOptions as $xKey => $xValue) |
|
106 | + foreach ($aOptions as $xKey => $xValue) |
|
107 | 107 | { |
108 | 108 | // The key is the class name. It must be a string. |
109 | - $this->di->alias((string)$xKey, (string)$xValue); |
|
109 | + $this->di->alias((string) $xKey, (string) $xValue); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | */ |
122 | 122 | private function registerCallables(array $aOptions, string $sCallableType) |
123 | 123 | { |
124 | - foreach($aOptions as $xKey => $xValue) |
|
124 | + foreach ($aOptions as $xKey => $xValue) |
|
125 | 125 | { |
126 | - if(is_integer($xKey) && is_string($xValue)) |
|
126 | + if (is_integer($xKey) && is_string($xValue)) |
|
127 | 127 | { |
128 | 128 | // Register a function without options |
129 | 129 | $this->xPluginManager->registerCallable($sCallableType, $xValue); |
130 | 130 | } |
131 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
131 | + elseif (is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
132 | 132 | { |
133 | 133 | // Register a function with options |
134 | 134 | $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue); |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | { |
172 | 172 | // $this->aPackages contains packages config file paths. |
173 | 173 | $aLibOptions = $sClassName::config(); |
174 | - if(is_string($aLibOptions)) |
|
174 | + if (is_string($aLibOptions)) |
|
175 | 175 | { |
176 | 176 | // A string is supposed to be the path to a config file. |
177 | 177 | $aLibOptions = $this->xConfigManager->read($aLibOptions); |
178 | 178 | } |
179 | - elseif(!is_array($aLibOptions)) |
|
179 | + elseif (!is_array($aLibOptions)) |
|
180 | 180 | { |
181 | 181 | // Otherwise, anything else than an array is not accepted. |
182 | 182 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | public function registerPackage(string $sClassName, array $aUserOptions) |
198 | 198 | { |
199 | 199 | $sClassName = trim($sClassName, '\\ '); |
200 | - if(!is_subclass_of($sClassName, Package::class)) |
|
200 | + if (!is_subclass_of($sClassName, Package::class)) |
|
201 | 201 | { |
202 | 202 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
203 | 203 | throw new SetupException($sMessage); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | // Register packages |
243 | 243 | $aPackageConfig = $xAppConfig->getOption('packages', []); |
244 | - foreach($aPackageConfig as $sClassName => $aPkgOptions) |
|
244 | + foreach ($aPackageConfig as $sClassName => $aPkgOptions) |
|
245 | 245 | { |
246 | 246 | $this->registerPackage($sClassName, $aPkgOptions); |
247 | 247 | } |
@@ -127,8 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | // Register a function without options |
129 | 129 | $this->xPluginManager->registerCallable($sCallableType, $xValue); |
130 | - } |
|
131 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
130 | + } elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
132 | 131 | { |
133 | 132 | // Register a function with options |
134 | 133 | $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue); |
@@ -175,8 +174,7 @@ discard block |
||
175 | 174 | { |
176 | 175 | // A string is supposed to be the path to a config file. |
177 | 176 | $aLibOptions = $this->xConfigManager->read($aLibOptions); |
178 | - } |
|
179 | - elseif(!is_array($aLibOptions)) |
|
177 | + } elseif(!is_array($aLibOptions)) |
|
180 | 178 | { |
181 | 179 | // Otherwise, anything else than an array is not accepted. |
182 | 180 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |