@@ -128,15 +128,15 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function checkOptions(string $sCallable, $xOptions): array |
| 130 | 130 | { |
| 131 | - if(!$this->xValidator->validateFunction(trim($sCallable))) |
|
| 131 | + if (!$this->xValidator->validateFunction(trim($sCallable))) |
|
| 132 | 132 | { |
| 133 | 133 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
| 134 | 134 | } |
| 135 | - if(is_string($xOptions)) |
|
| 135 | + if (is_string($xOptions)) |
|
| 136 | 136 | { |
| 137 | 137 | $xOptions = ['include' => $xOptions]; |
| 138 | 138 | } |
| 139 | - elseif(!is_array($xOptions)) |
|
| 139 | + elseif (!is_array($xOptions)) |
|
| 140 | 140 | { |
| 141 | 141 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
| 142 | 142 | } |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | $sPhpFunction = trim($sCallable); |
| 158 | 158 | $sFunction = $sPhpFunction; |
| 159 | 159 | // Check if an alias is defined |
| 160 | - if(isset($aOptions['alias'])) |
|
| 160 | + if (isset($aOptions['alias'])) |
|
| 161 | 161 | { |
| 162 | - $sFunction = (string)$aOptions['alias']; |
|
| 162 | + $sFunction = (string) $aOptions['alias']; |
|
| 163 | 163 | unset($aOptions['alias']); |
| 164 | 164 | } |
| 165 | 165 | $this->aFunctions[$sFunction] = $sPhpFunction; |
@@ -181,13 +181,13 @@ discard block |
||
| 181 | 181 | public function getCallable(string $sCallable) |
| 182 | 182 | { |
| 183 | 183 | $sFunction = trim($sCallable); |
| 184 | - if(!isset($this->aFunctions[$sFunction])) |
|
| 184 | + if (!isset($this->aFunctions[$sFunction])) |
|
| 185 | 185 | { |
| 186 | 186 | return null; |
| 187 | 187 | } |
| 188 | 188 | $xCallable = new CallableFunction($this->di, $sFunction, |
| 189 | 189 | $this->sPrefix . $sFunction, $this->aFunctions[$sFunction]); |
| 190 | - foreach($this->aOptions[$sFunction] as $sName => $sValue) |
|
| 190 | + foreach ($this->aOptions[$sFunction] as $sName => $sValue) |
|
| 191 | 191 | { |
| 192 | 192 | $xCallable->configure($sName, $sValue); |
| 193 | 193 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | public function getScript(): string |
| 217 | 217 | { |
| 218 | 218 | $code = ''; |
| 219 | - foreach(array_keys($this->aFunctions) as $sFunction) |
|
| 219 | + foreach (array_keys($this->aFunctions) as $sFunction) |
|
| 220 | 220 | { |
| 221 | 221 | $xFunction = $this->getCallable($sFunction); |
| 222 | 222 | $code .= $this->getCallableScript($xFunction); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | public static function canProcessRequest(ServerRequestInterface $xRequest): bool |
| 231 | 231 | { |
| 232 | 232 | $aBody = $xRequest->getParsedBody(); |
| 233 | - if(is_array($aBody)) |
|
| 233 | + if (is_array($aBody)) |
|
| 234 | 234 | { |
| 235 | 235 | return isset($aBody['jxnfun']); |
| 236 | 236 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | public function setTarget(ServerRequestInterface $xRequest) |
| 245 | 245 | { |
| 246 | 246 | $aBody = $xRequest->getParsedBody(); |
| 247 | - if(is_array($aBody)) |
|
| 247 | + if (is_array($aBody)) |
|
| 248 | 248 | { |
| 249 | 249 | $this->xTarget = Target::makeFunction(trim($aBody['jxnfun'])); |
| 250 | 250 | return; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $sRequestedFunction = $this->xTarget->getFunctionName(); |
| 263 | 263 | |
| 264 | 264 | // Security check: make sure the requested function was registered. |
| 265 | - if(!$this->xValidator->validateFunction($sRequestedFunction) || |
|
| 265 | + if (!$this->xValidator->validateFunction($sRequestedFunction) || |
|
| 266 | 266 | !isset($this->aFunctions[$sRequestedFunction])) |
| 267 | 267 | { |
| 268 | 268 | // Unable to find the requested function |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function configure(string $sName, string $sValue) |
| 125 | 125 | { |
| 126 | - switch($sName) |
|
| 126 | + switch ($sName) |
|
| 127 | 127 | { |
| 128 | 128 | case 'class': // The user function is a method in the given class |
| 129 | 129 | $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function call(array $aArgs = []) |
| 149 | 149 | { |
| 150 | - if(($this->sInclude)) |
|
| 150 | + if (($this->sInclude)) |
|
| 151 | 151 | { |
| 152 | 152 | require_once $this->sInclude; |
| 153 | 153 | } |
| 154 | 154 | // If the function is an alias for a class method, then instantiate the class |
| 155 | - if(is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0])) |
|
| 155 | + if (is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0])) |
|
| 156 | 156 | { |
| 157 | 157 | $sClassName = $this->xPhpFunction[0]; |
| 158 | 158 | $this->xPhpFunction[0] = $this->di->h($sClassName) ? $this->di->g($sClassName) : new $sClassName; |
@@ -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,7 +322,7 @@ 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 | 327 | $this->di->registerCallableClass($sClassName, $aOptions); |
| 328 | 328 | $aCallableObjects[$sClassName] = $this->di->getCallableObject($sClassName); |
@@ -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 custom 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,7 +256,7 @@ 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 | } |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | private function getCallableObjectOptions(array $aConfigOptions, array $aAnnotationOptions): array |
| 37 | 37 | { |
| 38 | 38 | $aOptions = []; |
| 39 | - foreach($aConfigOptions as $sNames => $aFunctionOptions) |
|
| 39 | + foreach ($aConfigOptions as $sNames => $aFunctionOptions) |
|
| 40 | 40 | { |
| 41 | 41 | $aFunctionNames = explode(',', $sNames); // Names are in comma-separated list. |
| 42 | - foreach($aFunctionNames as $sFunctionName) |
|
| 42 | + foreach ($aFunctionNames as $sFunctionName) |
|
| 43 | 43 | { |
| 44 | 44 | $aOptions[$sFunctionName] = array_merge($aOptions[$sFunctionName] ?? [], $aFunctionOptions); |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | - foreach($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
| 47 | + foreach ($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
| 48 | 48 | { |
| 49 | 49 | $aOptions[$sFunctionName] = array_merge($aOptions[$sFunctionName] ?? [], $aFunctionOptions); |
| 50 | 50 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $aMethods = $xCallableObject->getPublicMethods($aProtectedMethods); |
| 67 | 67 | $aProperties = $xCallableObject->getProperties(); |
| 68 | 68 | [$bExcluded, $aAnnotationOptions, $aAnnotationProtected] = $xAnnotationReader->getAttributes($sClassName, $aMethods, $aProperties); |
| 69 | - if($bExcluded) |
|
| 69 | + if ($bExcluded) |
|
| 70 | 70 | { |
| 71 | 71 | $xCallableObject->configure('excluded', true); |
| 72 | 72 | return; |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | // Functions options |
| 79 | 79 | $aCallableOptions = []; |
| 80 | 80 | $aOptions = $this->getCallableObjectOptions($aOptions['functions'], $aAnnotationOptions); |
| 81 | - foreach($aOptions as $sFunctionName => $aFunctionOptions) |
|
| 81 | + foreach ($aOptions as $sFunctionName => $aFunctionOptions) |
|
| 82 | 82 | { |
| 83 | - foreach($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 83 | + foreach ($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 84 | 84 | { |
| 85 | - if(substr($sOptionName, 0, 2) !== '__') |
|
| 85 | + if (substr($sOptionName, 0, 2) !== '__') |
|
| 86 | 86 | { |
| 87 | 87 | // Options for javascript code. |
| 88 | 88 | $aCallableOptions[$sFunctionName][$sOptionName] = $xOptionValue; |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | $sReflectionClass = $sClassName . '_ReflectionClass'; |
| 112 | 112 | |
| 113 | 113 | // Prevent duplication |
| 114 | - if($this->h($sReflectionClass)) // It's important not to use the class name here. |
|
| 114 | + if ($this->h($sReflectionClass)) // It's important not to use the class name here. |
|
| 115 | 115 | { |
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Make sure the registered class exists |
| 120 | - if(isset($aOptions['include'])) |
|
| 120 | + if (isset($aOptions['include'])) |
|
| 121 | 121 | { |
| 122 | 122 | require_once($aOptions['include']); |
| 123 | 123 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $this->val($sReflectionClass, new ReflectionClass($sClassName)); |
| 128 | 128 | } |
| 129 | - catch(ReflectionException $e) |
|
| 129 | + catch (ReflectionException $e) |
|
| 130 | 130 | { |
| 131 | 131 | $xTranslator = $this->g(Translator::class); |
| 132 | 132 | $sMessage = $xTranslator->trans('errors.class.invalid', ['name' => $sClassName]); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | }); |
| 150 | 150 | |
| 151 | 151 | // Register the user class, but only if the user already didn't. |
| 152 | - if(!$this->h($sClassName)) |
|
| 152 | + if (!$this->h($sClassName)) |
|
| 153 | 153 | { |
| 154 | 154 | $this->set($sClassName, function($c) use($sReflectionClass) { |
| 155 | 155 | return $this->make($c->g($sReflectionClass)); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | // Initialize the user class instance |
| 159 | 159 | $this->extend($sClassName, function($xRegisteredObject, $c) use($sClassName) { |
| 160 | - if($xRegisteredObject instanceof CallableClass) |
|
| 160 | + if ($xRegisteredObject instanceof CallableClass) |
|
| 161 | 161 | { |
| 162 | 162 | // Set the protected attributes of the object |
| 163 | 163 | $cSetter = function($c, $sClassName) { |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | // Run the callbacks for class initialisation |
| 172 | 172 | $aCallbacks = $c->g(CallbackManager::class)->getInitCallbacks(); |
| 173 | - foreach($aCallbacks as $xCallback) |
|
| 173 | + foreach ($aCallbacks as $xCallback) |
|
| 174 | 174 | { |
| 175 | 175 | call_user_func($xCallback, $xRegisteredObject); |
| 176 | 176 | } |
@@ -111,10 +111,12 @@ discard block |
||
| 111 | 111 | $sReflectionClass = $sClassName . '_ReflectionClass'; |
| 112 | 112 | |
| 113 | 113 | // Prevent duplication |
| 114 | - if($this->h($sReflectionClass)) // It's important not to use the class name here. |
|
| 114 | + if($this->h($sReflectionClass)) { |
|
| 115 | + // It's important not to use the class name here. |
|
| 115 | 116 | { |
| 116 | 117 | return; |
| 117 | 118 | } |
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | // Make sure the registered class exists |
| 120 | 122 | if(isset($aOptions['include'])) |
@@ -125,8 +127,7 @@ discard block |
||
| 125 | 127 | try |
| 126 | 128 | { |
| 127 | 129 | $this->val($sReflectionClass, new ReflectionClass($sClassName)); |
| 128 | - } |
|
| 129 | - catch(ReflectionException $e) |
|
| 130 | + } catch(ReflectionException $e) |
|
| 130 | 131 | { |
| 131 | 132 | $xTranslator = $this->g(Translator::class); |
| 132 | 133 | $sMessage = $xTranslator->trans('errors.class.invalid', ['name' => $sClassName]); |