@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function append(ResponseInterface $xResponse) |
110 | 110 | { |
111 | - if($this->xResponse->getCommandCount() === 0) |
|
111 | + if ($this->xResponse->getCommandCount() === 0) |
|
112 | 112 | { |
113 | 113 | $this->xResponse = $xResponse; |
114 | 114 | return; |
115 | 115 | } |
116 | - if(get_class($this->xResponse) !== get_class($xResponse)) |
|
116 | + if (get_class($this->xResponse) !== get_class($xResponse)) |
|
117 | 117 | { |
118 | 118 | throw new RequestException($this->xTranslator->trans('errors.mismatch.types', |
119 | 119 | ['class' => get_class($xResponse)])); |
120 | 120 | } |
121 | - if($this->xResponse !== $xResponse) |
|
121 | + if ($this->xResponse !== $xResponse) |
|
122 | 122 | { |
123 | 123 | $this->xResponse->appendResponse($xResponse); |
124 | 124 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function printDebug() |
161 | 161 | { |
162 | - foreach($this->aDebugMessages as $sMessage) |
|
162 | + foreach ($this->aDebugMessages as $sMessage) |
|
163 | 163 | { |
164 | 164 | $this->xResponse->debug($sMessage); |
165 | 165 | } |
@@ -173,8 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function getContentType(): string |
175 | 175 | { |
176 | - return empty($this->sCharacterEncoding) ? $this->xResponse->getContentType() : |
|
177 | - $this->xResponse->getContentType() . '; charset="' . $this->sCharacterEncoding . '"'; |
|
176 | + return empty($this->sCharacterEncoding) ? $this->xResponse->getContentType() : $this->xResponse->getContentType() . '; charset="' . $this->sCharacterEncoding . '"'; |
|
178 | 177 | } |
179 | 178 | |
180 | 179 | /** |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function checkOptions(string $sCallable, $xOptions): array |
120 | 120 | { |
121 | - if(!$this->xValidator->validateFunction(trim($sCallable))) |
|
121 | + if (!$this->xValidator->validateFunction(trim($sCallable))) |
|
122 | 122 | { |
123 | 123 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
124 | 124 | } |
125 | - if(is_string($xOptions)) |
|
125 | + if (is_string($xOptions)) |
|
126 | 126 | { |
127 | 127 | $xOptions = ['include' => $xOptions]; |
128 | 128 | } |
129 | - elseif(!is_array($xOptions)) |
|
129 | + elseif (!is_array($xOptions)) |
|
130 | 130 | { |
131 | 131 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
132 | 132 | } |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | $sPhpFunction = trim($sCallable); |
148 | 148 | $sFunction = $sPhpFunction; |
149 | 149 | // Check if an alias is defined |
150 | - if(isset($aOptions['alias'])) |
|
150 | + if (isset($aOptions['alias'])) |
|
151 | 151 | { |
152 | - $sFunction = (string)$aOptions['alias']; |
|
152 | + $sFunction = (string) $aOptions['alias']; |
|
153 | 153 | unset($aOptions['alias']); |
154 | 154 | } |
155 | 155 | $this->aFunctions[$sFunction] = $sPhpFunction; |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | public function getCallable(string $sCallable) |
172 | 172 | { |
173 | 173 | $sFunction = trim($sCallable); |
174 | - if(!isset($this->aFunctions[$sFunction])) |
|
174 | + if (!isset($this->aFunctions[$sFunction])) |
|
175 | 175 | { |
176 | 176 | return null; |
177 | 177 | } |
178 | 178 | $xCallable = new CallableFunction($sFunction, $this->sPrefix . $sFunction, $this->aFunctions[$sFunction]); |
179 | - foreach($this->aOptions[$sFunction] as $sName => $sValue) |
|
179 | + foreach ($this->aOptions[$sFunction] as $sName => $sValue) |
|
180 | 180 | { |
181 | 181 | $xCallable->configure($sName, $sValue); |
182 | 182 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | public function getScript(): string |
206 | 206 | { |
207 | 207 | $code = ''; |
208 | - foreach(array_keys($this->aFunctions) as $sFunction) |
|
208 | + foreach (array_keys($this->aFunctions) as $sFunction) |
|
209 | 209 | { |
210 | 210 | $xFunction = $this->getCallable($sFunction); |
211 | 211 | $code .= $this->getCallableScript($xFunction); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | public static function canProcessRequest(ServerRequestInterface $xRequest): bool |
220 | 220 | { |
221 | 221 | $aBody = $xRequest->getParsedBody(); |
222 | - if(is_array($aBody)) |
|
222 | + if (is_array($aBody)) |
|
223 | 223 | { |
224 | 224 | return isset($aBody['jxnfun']); |
225 | 225 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | public function setTarget(ServerRequestInterface $xRequest) |
234 | 234 | { |
235 | 235 | $aBody = $xRequest->getParsedBody(); |
236 | - if(is_array($aBody)) |
|
236 | + if (is_array($aBody)) |
|
237 | 237 | { |
238 | 238 | $this->xTarget = Target::makeFunction(trim($aBody['jxnfun'])); |
239 | 239 | return; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $sRequestedFunction = $this->xTarget->getFunctionName(); |
252 | 252 | |
253 | 253 | // Security check: make sure the requested function was registered. |
254 | - if(!$this->xValidator->validateFunction($sRequestedFunction) || |
|
254 | + if (!$this->xValidator->validateFunction($sRequestedFunction) || |
|
255 | 255 | !isset($this->aFunctions[$sRequestedFunction])) |
256 | 256 | { |
257 | 257 | // Unable to find the requested function |
@@ -125,8 +125,7 @@ |
||
125 | 125 | if(is_string($xOptions)) |
126 | 126 | { |
127 | 127 | $xOptions = ['include' => $xOptions]; |
128 | - } |
|
129 | - elseif(!is_array($xOptions)) |
|
128 | + } elseif(!is_array($xOptions)) |
|
130 | 129 | { |
131 | 130 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
132 | 131 | } |
@@ -114,15 +114,15 @@ |
||
114 | 114 | { |
115 | 115 | switch($sName) |
116 | 116 | { |
117 | - case 'class': // The user function is a method in the given class |
|
118 | - $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
|
119 | - break; |
|
120 | - case 'include': |
|
121 | - $this->sInclude = $sValue; |
|
122 | - break; |
|
123 | - default: |
|
124 | - $this->aOptions[$sName] = $sValue; |
|
125 | - break; |
|
117 | + case 'class': // The user function is a method in the given class |
|
118 | + $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
|
119 | + break; |
|
120 | + case 'include': |
|
121 | + $this->sInclude = $sValue; |
|
122 | + break; |
|
123 | + default: |
|
124 | + $this->aOptions[$sName] = $sValue; |
|
125 | + break; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function configure(string $sName, string $sValue) |
114 | 114 | { |
115 | - switch($sName) |
|
115 | + switch ($sName) |
|
116 | 116 | { |
117 | 117 | case 'class': // The user function is a method in the given class |
118 | 118 | $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function call(array $aArgs = []) |
138 | 138 | { |
139 | - if(($this->sInclude)) |
|
139 | + if (($this->sInclude)) |
|
140 | 140 | { |
141 | 141 | require_once $this->sInclude; |
142 | 142 | } |
143 | 143 | // If the function is an alias for a class method, then instantiate the class |
144 | - if(is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0])) |
|
144 | + if (is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0])) |
|
145 | 145 | { |
146 | 146 | $sClassName = $this->xPhpFunction[0]; |
147 | 147 | $this->xPhpFunction[0] = new $sClassName; |
@@ -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 | } |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | */ |
193 | 193 | private function setHookMethods(array &$aHookMethods, $xValue) |
194 | 194 | { |
195 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
195 | + foreach ($xValue as $sCalledMethod => $xMethodToCall) |
|
196 | 196 | { |
197 | - if(is_array($xMethodToCall)) |
|
197 | + if (is_array($xMethodToCall)) |
|
198 | 198 | { |
199 | 199 | $aHookMethods[$sCalledMethod] = $xMethodToCall; |
200 | 200 | } |
201 | - elseif(is_string($xMethodToCall)) |
|
201 | + elseif (is_string($xMethodToCall)) |
|
202 | 202 | { |
203 | 203 | $aHookMethods[$sCalledMethod] = [$xMethodToCall]; |
204 | 204 | } |
@@ -215,18 +215,18 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function configure(string $sName, $xValue) |
217 | 217 | { |
218 | - switch($sName) |
|
218 | + switch ($sName) |
|
219 | 219 | { |
220 | 220 | // Set the separator |
221 | 221 | case 'separator': |
222 | - if($xValue === '_' || $xValue === '.') |
|
222 | + if ($xValue === '_' || $xValue === '.') |
|
223 | 223 | { |
224 | 224 | $this->sSeparator = $xValue; |
225 | 225 | } |
226 | 226 | break; |
227 | 227 | // Set the protected methods |
228 | 228 | case 'protected': |
229 | - if(is_array($xValue)) |
|
229 | + if (is_array($xValue)) |
|
230 | 230 | { |
231 | 231 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
232 | 232 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $this->aAttributes = array_merge($this->aAttributes, $xValue); |
245 | 245 | break; |
246 | 246 | case 'excluded': |
247 | - $this->bExcluded = (bool)$xValue; |
|
247 | + $this->bExcluded = (bool) $xValue; |
|
248 | 248 | break; |
249 | 249 | default: |
250 | 250 | break; |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | // $aMethods = $aHookMethods[$sMethod] ?? $aHookMethods['*'] ?? []; |
367 | 367 | // The hooks defined at method level are merged with those defined at class level. |
368 | 368 | $aMethods = array_merge($aHookMethods['*'] ?? [], $aHookMethods[$sMethod] ?? []); |
369 | - foreach($aMethods as $xKey => $xValue) |
|
369 | + foreach ($aMethods as $xKey => $xValue) |
|
370 | 370 | { |
371 | 371 | $sHookName = $xValue; |
372 | 372 | $aHookArgs = []; |
373 | - if(is_string($xKey)) |
|
373 | + if (is_string($xKey)) |
|
374 | 374 | { |
375 | 375 | $sHookName = $xKey; |
376 | 376 | $aHookArgs = is_array($xValue) ? $xValue : [$xValue]; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | // $aAttributes = $this->aAttributes[$sMethod] ?? $this->aAttributes['*'] ?? []; |
412 | 412 | // The attributes defined at method level are merged with those defined at class level. |
413 | 413 | $aAttributes = array_merge($this->aAttributes['*'] ?? [], $this->aAttributes[$sMethod] ?? []); |
414 | - foreach($aAttributes as $sName => $sClass) |
|
414 | + foreach ($aAttributes as $sName => $sClass) |
|
415 | 415 | { |
416 | 416 | // Set the protected attributes of the object |
417 | 417 | $cSetter = function($c) use($sName, $sClass) { |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Set the Jaxon request target in the helper |
426 | - if($this->xRegisteredObject instanceof CallableClass) |
|
426 | + if ($this->xRegisteredObject instanceof CallableClass) |
|
427 | 427 | { |
428 | 428 | // Set the protected attributes of the object |
429 | 429 | $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 | } |