@@ -66,7 +66,7 @@ |
||
| 66 | 66 | */ |
| 67 | 67 | public function setOption(string $sName, string|array|JsonSerializable $xValue): Command |
| 68 | 68 | { |
| 69 | - if(isset($this->aCommand['options'])) |
|
| 69 | + if (isset($this->aCommand['options'])) |
|
| 70 | 70 | { |
| 71 | 71 | $this->aCommand['options'][$this->str($sName)] = $xValue; |
| 72 | 72 | return $this; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | private function _registerPlugin(string $sClassName, string $sPluginName, array $aInterfaces): int |
| 101 | 101 | { |
| 102 | 102 | // Any plugin must implement the PluginInterface interface. |
| 103 | - if(!in_array(PluginInterface::class, $aInterfaces)) |
|
| 103 | + if (!in_array(PluginInterface::class, $aInterfaces)) |
|
| 104 | 104 | { |
| 105 | 105 | $sMessage = $this->xTranslator->trans('errors.register.invalid', [ |
| 106 | 106 | 'name' => $sClassName, |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Response plugin. |
| 112 | - if(in_array(ResponsePluginInterface::class, $aInterfaces)) |
|
| 112 | + if (in_array(ResponsePluginInterface::class, $aInterfaces)) |
|
| 113 | 113 | { |
| 114 | 114 | $this->aResponsePlugins[$sPluginName] = $sClassName; |
| 115 | 115 | return 1; |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | // Request plugin. |
| 119 | 119 | $nCount = 0; |
| 120 | - if(in_array(CallableRegistryInterface::class, $aInterfaces)) |
|
| 120 | + if (in_array(CallableRegistryInterface::class, $aInterfaces)) |
|
| 121 | 121 | { |
| 122 | 122 | $this->aRegistryPlugins[$sPluginName] = $sClassName; |
| 123 | 123 | $nCount++; |
| 124 | 124 | } |
| 125 | - if(in_array(RequestHandlerInterface::class, $aInterfaces)) |
|
| 125 | + if (in_array(RequestHandlerInterface::class, $aInterfaces)) |
|
| 126 | 126 | { |
| 127 | 127 | $this->aRequestHandlers[$sPluginName] = $sClassName; |
| 128 | 128 | $nCount++; |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | $nCount = $this->_registerPlugin($sClassName, $sPluginName, $aInterfaces); |
| 152 | 152 | |
| 153 | 153 | // Any plugin can implement the CodeGeneratorInterface interface. |
| 154 | - if(in_array(CodeGeneratorInterface::class, $aInterfaces)) |
|
| 154 | + if (in_array(CodeGeneratorInterface::class, $aInterfaces)) |
|
| 155 | 155 | { |
| 156 | 156 | $this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority); |
| 157 | 157 | $nCount++; |
| 158 | 158 | } |
| 159 | 159 | // The class is not a valid plugin. |
| 160 | - if($nCount === 0) |
|
| 160 | + if ($nCount === 0) |
|
| 161 | 161 | { |
| 162 | 162 | $sMessage = $this->xTranslator->trans('errors.register.invalid', [ |
| 163 | 163 | 'name' => $sClassName, |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Register the plugin in the DI container, if necessary |
| 169 | - if(!$this->di->has($sClassName)) |
|
| 169 | + if (!$this->di->has($sClassName)) |
|
| 170 | 170 | { |
| 171 | 171 | $this->di->auto($sClassName); |
| 172 | 172 | } |
@@ -182,8 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function getResponsePlugin(string $sName): ?ResponsePluginInterface |
| 184 | 184 | { |
| 185 | - return $this->di->h($sName) ? $this->di->g($sName) : |
|
| 186 | - (!isset($this->aResponsePlugins[$sName]) ? null : |
|
| 185 | + return $this->di->h($sName) ? $this->di->g($sName) : (!isset($this->aResponsePlugins[$sName]) ? null : |
|
| 187 | 186 | $this->di->g($this->aResponsePlugins[$sName])); |
| 188 | 187 | } |
| 189 | 188 | |
@@ -201,7 +200,7 @@ discard block |
||
| 201 | 200 | */ |
| 202 | 201 | public function registerCallable(string $sType, string $sCallable, $xOptions = []): void |
| 203 | 202 | { |
| 204 | - if(isset($this->aRegistryPlugins[$sType]) && |
|
| 203 | + if (isset($this->aRegistryPlugins[$sType]) && |
|
| 205 | 204 | ($xPlugin = $this->di->g($this->aRegistryPlugins[$sType]))) |
| 206 | 205 | { |
| 207 | 206 | $xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions)); |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | public function ajaxResponse(): ResponseInterface |
| 64 | 64 | { |
| 65 | 65 | $xPsrResponse = $this->xPsr17Factory->createResponse(200); |
| 66 | - if($this->xRequest->getMethod() === 'GET') |
|
| 66 | + if ($this->xRequest->getMethod() === 'GET') |
|
| 67 | 67 | { |
| 68 | 68 | $xPsrResponse = $xPsrResponse |
| 69 | 69 | ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | private function initDataBag(): void |
| 36 | 36 | { |
| 37 | - if($this->xDataBag !== null) |
|
| 37 | + if ($this->xDataBag !== null) |
|
| 38 | 38 | { |
| 39 | 39 | return; |
| 40 | 40 | } |
@@ -44,8 +44,7 @@ discard block |
||
| 44 | 44 | $aBody = $xRequest->getParsedBody(); |
| 45 | 45 | $aParams = $xRequest->getQueryParams(); |
| 46 | 46 | $aData = is_array($aBody) ? |
| 47 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
| 48 | - $this->readData($aParams['jxnbags'] ?? []); |
|
| 47 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
| 49 | 48 | $this->xDataBag = new DataBag($this, $aData); |
| 50 | 49 | } |
| 51 | 50 | |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | // Todo: clean input data. |
| 68 | 67 | // Todo: verify the checksums. |
| 69 | 68 | return is_string($xData) ? |
| 70 | - (json_decode($xData, true) ?: []) : |
|
| 71 | - (is_array($xData) ? $xData : []); |
|
| 69 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
| 72 | 70 | } |
| 73 | 71 | |
| 74 | 72 | /** |
@@ -86,7 +84,7 @@ discard block |
||
| 86 | 84 | public function writeCommand(): void |
| 87 | 85 | { |
| 88 | 86 | $this->initDataBag(); |
| 89 | - if($this->xDataBag->touched()) |
|
| 87 | + if ($this->xDataBag->touched()) |
|
| 90 | 88 | { |
| 91 | 89 | // Todo: calculate the checksums. |
| 92 | 90 | $this->addCommand('databag.set', ['values' => $this->xDataBag]); |
@@ -52,8 +52,7 @@ |
||
| 52 | 52 | public function getScript(): string |
| 53 | 53 | { |
| 54 | 54 | // It is important to call $this->xParameterReader->uri() only if necessary. |
| 55 | - $sUri = $this->xConfigManager->getOption('core.request.uri') ?: |
|
| 56 | - $this->xParameterReader->uri(); |
|
| 55 | + $sUri = $this->xConfigManager->getOption('core.request.uri') ?: $this->xParameterReader->uri(); |
|
| 57 | 56 | $aOptions = [ |
| 58 | 57 | 'sResponseType' => 'JSON', |
| 59 | 58 | 'sVersion' => $this->option('core.version'), |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function addCodeGenerator(string $sClassName, int $nPriority): void |
| 111 | 111 | { |
| 112 | - while(isset($this->aCodeGenerators[$nPriority])) |
|
| 112 | + while (isset($this->aCodeGenerators[$nPriority])) |
|
| 113 | 113 | { |
| 114 | 114 | $nPriority++; |
| 115 | 115 | } |
@@ -163,33 +163,33 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void |
| 165 | 165 | { |
| 166 | - if(!is_subclass_of($xGenerator, AbstractPlugin::class) || |
|
| 166 | + if (!is_subclass_of($xGenerator, AbstractPlugin::class) || |
|
| 167 | 167 | $this->xAssetManager->shallIncludeAssets($xGenerator)) |
| 168 | 168 | { |
| 169 | 169 | // HTML tags for CSS |
| 170 | - if(($sCss = trim($xGenerator->getCss(), " \n")) !== '') |
|
| 170 | + if (($sCss = trim($xGenerator->getCss(), " \n")) !== '') |
|
| 171 | 171 | { |
| 172 | 172 | $this->aCss[] = $sCss; |
| 173 | 173 | } |
| 174 | 174 | // HTML tags for js |
| 175 | - if(($sJs = trim($xGenerator->getJs(), " \n")) !== '') |
|
| 175 | + if (($sJs = trim($xGenerator->getJs(), " \n")) !== '') |
|
| 176 | 176 | { |
| 177 | 177 | $this->aJs[] = $sJs; |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Additional js codes |
| 182 | - if(($xJsCode = $xGenerator->getJsCode()) !== null) |
|
| 182 | + if (($xJsCode = $xGenerator->getJsCode()) !== null) |
|
| 183 | 183 | { |
| 184 | - if(($sJs = trim($xJsCode->sJs, " \n")) !== '') |
|
| 184 | + if (($sJs = trim($xJsCode->sJs, " \n")) !== '') |
|
| 185 | 185 | { |
| 186 | 186 | $this->aCodeJs[] = $sJs; |
| 187 | 187 | } |
| 188 | - if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '') |
|
| 188 | + if (($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '') |
|
| 189 | 189 | { |
| 190 | 190 | $this->aCodeJsBefore[] = $sJsBefore; |
| 191 | 191 | } |
| 192 | - if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '') |
|
| 192 | + if (($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '') |
|
| 193 | 193 | { |
| 194 | 194 | $this->aCodeJsAfter[] = $sJsAfter; |
| 195 | 195 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | private function generateCodes(): void |
| 207 | 207 | { |
| 208 | - if($this->bGenerated) |
|
| 208 | + if ($this->bGenerated) |
|
| 209 | 209 | { |
| 210 | 210 | return; |
| 211 | 211 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | // Sort the code generators by ascending priority |
| 217 | 217 | ksort($this->aCodeGenerators); |
| 218 | 218 | |
| 219 | - foreach($this->aCodeGenerators as $sClassName) |
|
| 219 | + foreach ($this->aCodeGenerators as $sClassName) |
|
| 220 | 220 | { |
| 221 | 221 | $this->generatePluginCodes($this->getCodeGenerator($sClassName)); |
| 222 | 222 | } |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | public function getJsScript(): string |
| 263 | 263 | { |
| 264 | - foreach($this->aCodeGenerators as $sClassName) |
|
| 264 | + foreach ($this->aCodeGenerators as $sClassName) |
|
| 265 | 265 | { |
| 266 | 266 | $xGenerator = $this->getCodeGenerator($sClassName); |
| 267 | 267 | // Javascript code |
| 268 | - if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '') |
|
| 268 | + if (($sJsScript = trim($xGenerator->getScript(), " \n")) !== '') |
|
| 269 | 269 | { |
| 270 | 270 | $aJsScript[] = $sJsScript; |
| 271 | 271 | } |
@@ -282,38 +282,36 @@ discard block |
||
| 282 | 282 | private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array |
| 283 | 283 | { |
| 284 | 284 | $aCodes = []; |
| 285 | - if($bIncludeCss) |
|
| 285 | + if ($bIncludeCss) |
|
| 286 | 286 | { |
| 287 | 287 | $aCodes[] = $this->getCss(); |
| 288 | 288 | } |
| 289 | - if($bIncludeJs) |
|
| 289 | + if ($bIncludeJs) |
|
| 290 | 290 | { |
| 291 | 291 | $aCodes[] = $this->getJs(); |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : |
|
| 295 | - $this->xAssetManager->createJsFiles($this); |
|
| 294 | + $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : $this->xAssetManager->createJsFiles($this); |
|
| 296 | 295 | // Wrap the js code into the corresponding HTML tag. |
| 297 | 296 | $aCodes[] = $sUrl !== '' ? |
| 298 | - $this->render('include.js', ['sUrl' => $sUrl]) : |
|
| 299 | - $this->render('wrapper.js', ['sScript' => $this->getJsScript()]); |
|
| 297 | + $this->render('include.js', ['sUrl' => $sUrl]) : $this->render('wrapper.js', ['sScript' => $this->getJsScript()]); |
|
| 300 | 298 | |
| 301 | 299 | // Wrap the js codes into HTML tags. |
| 302 | - if(count($this->aCodeJsBefore) > 0) |
|
| 300 | + if (count($this->aCodeJsBefore) > 0) |
|
| 303 | 301 | { |
| 304 | 302 | $sScript = implode("\n\n", $this->aCodeJsBefore); |
| 305 | 303 | $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]); |
| 306 | 304 | } |
| 307 | - if(count($this->aCodeJs) > 0) |
|
| 305 | + if (count($this->aCodeJs) > 0) |
|
| 308 | 306 | { |
| 309 | 307 | $sScript = implode("\n\n", $this->aCodeJs); |
| 310 | 308 | $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]); |
| 311 | 309 | } |
| 312 | - if(count($this->aCodeJsFiles) > 0) |
|
| 310 | + if (count($this->aCodeJsFiles) > 0) |
|
| 313 | 311 | { |
| 314 | 312 | $aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]); |
| 315 | 313 | } |
| 316 | - if(count($this->aCodeJsAfter) > 0) |
|
| 314 | + if (count($this->aCodeJsAfter) > 0) |
|
| 317 | 315 | { |
| 318 | 316 | $sScript = implode("\n\n", $this->aCodeJsAfter); |
| 319 | 317 | $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function shallIncludeAssets(AbstractPlugin $xPlugin): bool |
| 74 | 74 | { |
| 75 | 75 | $sPluginOptionName = 'assets.include.' . $xPlugin->getName(); |
| 76 | - if($this->hasLibOption($sPluginOptionName)) |
|
| 76 | + if ($this->hasLibOption($sPluginOptionName)) |
|
| 77 | 77 | { |
| 78 | 78 | return $this->getLibOption($sPluginOptionName); |
| 79 | 79 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $this->getLibOption('js.lib.jq', "$sJsLibUri/libs/chibi/chibi$sJsExtension"), |
| 98 | 98 | "$sJsLibUri/jaxon.core$sJsExtension", |
| 99 | 99 | ]; |
| 100 | - if($this->getLibOption('core.debug.on')) |
|
| 100 | + if ($this->getLibOption('core.debug.on')) |
|
| 101 | 101 | { |
| 102 | 102 | $sLanguage = $this->getLibOption('core.language'); |
| 103 | 103 | $aJsFiles[] = "$sJsLibUri/jaxon.debug$sJsExtension"; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | // Check config options |
| 118 | 118 | // - The js.app.export option must be set to true |
| 119 | 119 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 120 | - if(!$this->getLibOption('js.app.export', false) || |
|
| 120 | + if (!$this->getLibOption('js.app.export', false) || |
|
| 121 | 121 | !$this->getLibOption('js.app.uri') || !$this->getLibOption('js.app.dir')) |
| 122 | 122 | { |
| 123 | 123 | return false; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $sJsFileName = $this->getLibOption('js.app.file') ?: $xCodeGenerator->getHash(); |
| 139 | 139 | $sJsDirectory = rtrim($this->getLibOption('js.app.dir'), '\/') . DIRECTORY_SEPARATOR; |
| 140 | 140 | // - The js.app.dir must be writable |
| 141 | - if(!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
| 141 | + if (!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory)) |
|
| 142 | 142 | { |
| 143 | 143 | return ''; |
| 144 | 144 | } |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | $sJsMinFilePath = $sJsDirectory . $sJsFileName . '.min.js'; |
| 148 | 148 | $sJsFileUri = rtrim($this->getLibOption('js.app.uri'), '/') . "/$sJsFileName"; |
| 149 | 149 | |
| 150 | - if(!is_file($sJsFilePath) && |
|
| 150 | + if (!is_file($sJsFilePath) && |
|
| 151 | 151 | !@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript())) |
| 152 | 152 | { |
| 153 | 153 | return ''; |
| 154 | 154 | } |
| 155 | - if(!$this->getLibOption('js.app.minify', false)) |
|
| 155 | + if (!$this->getLibOption('js.app.minify', false)) |
|
| 156 | 156 | { |
| 157 | 157 | return $sJsFileUri . '.js'; |
| 158 | 158 | } |
| 159 | - if(!is_file($sJsMinFilePath) && |
|
| 159 | + if (!is_file($sJsMinFilePath) && |
|
| 160 | 160 | !$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath)) |
| 161 | 161 | { |
| 162 | 162 | // If the file cannot be minified, return the plain js file. |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | public function __construct(protected ComponentContainer $cdi) |
| 112 | 112 | { |
| 113 | 113 | // Set the composer autoloader |
| 114 | - if(file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) || |
|
| 114 | + if (file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) || |
|
| 115 | 115 | file_exists(($sAutoloadFile = __DIR__ . '/../../../../../vendor/autoload.php')) || |
| 116 | 116 | file_exists(($sAutoloadFile = __DIR__ . '/../../../../vendor/autoload.php'))) |
| 117 | 117 | { |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | private function makeClassOptions(string $sClassName, array $aClassOptions, array $aDirectoryOptions): array |
| 182 | 182 | { |
| 183 | - foreach($this->aDefaultClassOptions as $sOption => $xValue) |
|
| 183 | + foreach ($this->aDefaultClassOptions as $sOption => $xValue) |
|
| 184 | 184 | { |
| 185 | - if(!isset($aClassOptions[$sOption])) |
|
| 185 | + if (!isset($aClassOptions[$sOption])) |
|
| 186 | 186 | { |
| 187 | 187 | $aClassOptions[$sOption] = $xValue; |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | $aClassOptions['excluded'] = (bool)($aClassOptions['excluded'] ?? false); // Convert to bool. |
| 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,30 +199,30 @@ 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'] = (string)$aOptionGroup['separator']; |
| 207 | 207 | } |
| 208 | - if(isset($aOptionGroup['excluded'])) |
|
| 208 | + if (isset($aOptionGroup['excluded'])) |
|
| 209 | 209 | { |
| 210 | 210 | $aClassOptions['excluded'] = (bool)$aOptionGroup['excluded']; |
| 211 | 211 | } |
| 212 | - if(isset($aOptionGroup['protected'])) |
|
| 212 | + if (isset($aOptionGroup['protected'])) |
|
| 213 | 213 | { |
| 214 | - if(is_string($aOptionGroup['protected'])) |
|
| 214 | + if (is_string($aOptionGroup['protected'])) |
|
| 215 | 215 | { |
| 216 | 216 | $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array. |
| 217 | 217 | } |
| 218 | 218 | $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']); |
| 219 | 219 | } |
| 220 | - if(isset($aOptionGroup['functions'])) |
|
| 220 | + if (isset($aOptionGroup['functions'])) |
|
| 221 | 221 | { |
| 222 | 222 | $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']); |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | - if(isset($aDirectoryOptions['config']) && !isset($aClassOptions['config'])) |
|
| 225 | + if (isset($aDirectoryOptions['config']) && !isset($aClassOptions['config'])) |
|
| 226 | 226 | { |
| 227 | 227 | $aClassOptions['config'] = $aDirectoryOptions['config']; |
| 228 | 228 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | { |
| 245 | 245 | $aOptions = $this->makeClassOptions($sClassName, $aClassOptions, $aDirectoryOptions); |
| 246 | 246 | $this->cdi->registerComponent($sClassName, $aOptions); |
| 247 | - if($this->bUpdateHash) |
|
| 247 | + if ($this->bUpdateHash) |
|
| 248 | 248 | { |
| 249 | 249 | $this->sHash .= $sClassName . $aOptions['timestamp']; |
| 250 | 250 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function registerComponent(string $sClassName, array $aClassOptions): void |
| 262 | 262 | { |
| 263 | - if($this->xPackageConfig !== null) |
|
| 263 | + if ($this->xPackageConfig !== null) |
|
| 264 | 264 | { |
| 265 | 265 | $aClassOptions['config'] = $this->xPackageConfig; |
| 266 | 266 | } |
@@ -277,10 +277,10 @@ discard block |
||
| 277 | 277 | public function getNamespaceComponentOptions(string $sClassName): ?array |
| 278 | 278 | { |
| 279 | 279 | // Find the corresponding namespace |
| 280 | - foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions) |
|
| 280 | + foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions) |
|
| 281 | 281 | { |
| 282 | 282 | // Check if the namespace matches the class. |
| 283 | - if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0) |
|
| 283 | + if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0) |
|
| 284 | 284 | { |
| 285 | 285 | // Save the class options |
| 286 | 286 | $aClassOptions = ['namespace' => $sNamespace]; |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | public function registerDirectory(string $sDirectory, array $aOptions): void |
| 302 | 302 | { |
| 303 | 303 | // Set the autoload option default value |
| 304 | - if(!isset($aOptions['autoload'])) |
|
| 304 | + if (!isset($aOptions['autoload'])) |
|
| 305 | 305 | { |
| 306 | 306 | $aOptions['autoload'] = true; |
| 307 | 307 | } |
| 308 | - if($this->xPackageConfig !== null) |
|
| 308 | + if ($this->xPackageConfig !== null) |
|
| 309 | 309 | { |
| 310 | 310 | $aOptions['config'] = $this->xPackageConfig; |
| 311 | 311 | } |
@@ -337,30 +337,30 @@ discard block |
||
| 337 | 337 | public function registerNamespace(string $sNamespace, array $aOptions): void |
| 338 | 338 | { |
| 339 | 339 | // Separator default value |
| 340 | - if(!isset($aOptions['separator'])) |
|
| 340 | + if (!isset($aOptions['separator'])) |
|
| 341 | 341 | { |
| 342 | 342 | $aOptions['separator'] = '.'; |
| 343 | 343 | } |
| 344 | 344 | $aOptions['separator'] = trim($aOptions['separator']); |
| 345 | - if(!in_array($aOptions['separator'], ['.', '_'])) |
|
| 345 | + if (!in_array($aOptions['separator'], ['.', '_'])) |
|
| 346 | 346 | { |
| 347 | 347 | $aOptions['separator'] = '.'; |
| 348 | 348 | } |
| 349 | - if($aOptions['separator'] === '_') |
|
| 349 | + if ($aOptions['separator'] === '_') |
|
| 350 | 350 | { |
| 351 | 351 | $this->cdi->useUnderscore(); |
| 352 | 352 | } |
| 353 | 353 | // Set the autoload option default value |
| 354 | - if(!isset($aOptions['autoload'])) |
|
| 354 | + if (!isset($aOptions['autoload'])) |
|
| 355 | 355 | { |
| 356 | 356 | $aOptions['autoload'] = true; |
| 357 | 357 | } |
| 358 | - if($this->xPackageConfig !== null) |
|
| 358 | + if ($this->xPackageConfig !== null) |
|
| 359 | 359 | { |
| 360 | 360 | $aOptions['config'] = $this->xPackageConfig; |
| 361 | 361 | } |
| 362 | 362 | // Register the dir with PSR4 autoloading |
| 363 | - if(($aOptions['autoload']) && $this->xAutoloader != null) |
|
| 363 | + if (($aOptions['autoload']) && $this->xAutoloader != null) |
|
| 364 | 364 | { |
| 365 | 365 | $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']); |
| 366 | 366 | } |
@@ -376,28 +376,28 @@ discard block |
||
| 376 | 376 | public function registerComponentsInDirectories(): void |
| 377 | 377 | { |
| 378 | 378 | // This is to be done only once. |
| 379 | - if($this->bDirectoriesParsed) |
|
| 379 | + if ($this->bDirectoriesParsed) |
|
| 380 | 380 | { |
| 381 | 381 | return; |
| 382 | 382 | } |
| 383 | 383 | $this->bDirectoriesParsed = true; |
| 384 | 384 | |
| 385 | 385 | // Browse directories without namespaces and read all the files. |
| 386 | - foreach($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions) |
|
| 386 | + foreach ($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions) |
|
| 387 | 387 | { |
| 388 | 388 | $itFile = new SortedFileIterator($sDirectory); |
| 389 | 389 | // Iterate on dir content |
| 390 | - foreach($itFile as $xFile) |
|
| 390 | + foreach ($itFile as $xFile) |
|
| 391 | 391 | { |
| 392 | 392 | // Skip everything except PHP files |
| 393 | - if(!$xFile->isFile() || $xFile->getExtension() !== 'php') |
|
| 393 | + if (!$xFile->isFile() || $xFile->getExtension() !== 'php') |
|
| 394 | 394 | { |
| 395 | 395 | continue; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | $sClassName = $xFile->getBasename('.php'); |
| 399 | 399 | $aClassOptions = ['timestamp' => $xFile->getMTime()]; |
| 400 | - if(($aDirectoryOptions['autoload']) && $this->xAutoloader !== null) |
|
| 400 | + if (($aDirectoryOptions['autoload']) && $this->xAutoloader !== null) |
|
| 401 | 401 | { |
| 402 | 402 | // Set classmap autoloading. Must be done before registering the class. |
| 403 | 403 | $this->xAutoloader->addClassMap([$sClassName => $xFile->getPathname()]); |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | public function registerComponentsInNamespaces(): void |
| 416 | 416 | { |
| 417 | 417 | // This is to be done only once. |
| 418 | - if($this->bNamespacesParsed) |
|
| 418 | + if ($this->bNamespacesParsed) |
|
| 419 | 419 | { |
| 420 | 420 | return; |
| 421 | 421 | } |
@@ -423,17 +423,17 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | // Browse directories with namespaces and read all the files. |
| 425 | 425 | $sDS = DIRECTORY_SEPARATOR; |
| 426 | - foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions) |
|
| 426 | + foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions) |
|
| 427 | 427 | { |
| 428 | 428 | $this->addNamespace($sNamespace, ['separator' => $aDirectoryOptions['separator']]); |
| 429 | 429 | |
| 430 | 430 | // Iterate on dir content |
| 431 | 431 | $sDirectory = $aDirectoryOptions['directory']; |
| 432 | 432 | $itFile = new SortedFileIterator($sDirectory); |
| 433 | - foreach($itFile as $xFile) |
|
| 433 | + foreach ($itFile as $xFile) |
|
| 434 | 434 | { |
| 435 | 435 | // skip everything except PHP files |
| 436 | - if(!$xFile->isFile() || $xFile->getExtension() !== 'php') |
|
| 436 | + if (!$xFile->isFile() || $xFile->getExtension() !== 'php') |
|
| 437 | 437 | { |
| 438 | 438 | continue; |
| 439 | 439 | } |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | $sClassPath = $sNamespace; |
| 443 | 443 | $sRelativePath = substr($xFile->getPath(), strlen($sDirectory)); |
| 444 | 444 | $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\'); |
| 445 | - if($sRelativePath !== '') |
|
| 445 | + if ($sRelativePath !== '') |
|
| 446 | 446 | { |
| 447 | 447 | $sClassPath .= '\\' . $sRelativePath; |
| 448 | 448 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function __construct(string $sDirectory) |
| 29 | 29 | { |
| 30 | 30 | $itFile = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDirectory)); |
| 31 | - foreach($itFile as $xFile) |
|
| 31 | + foreach ($itFile as $xFile) |
|
| 32 | 32 | { |
| 33 | 33 | $this->insert($xFile); |
| 34 | 34 | } |