@@ -33,8 +33,8 @@ |
||
| 33 | 33 | * @return $this |
| 34 | 34 | */ |
| 35 | 35 | public function addAll(array $map) { |
| 36 | - foreach($map as $key => $value) { |
|
| 37 | - if(is_numeric($key) || !is_string($key)) { |
|
| 36 | + foreach ($map as $key => $value) { |
|
| 37 | + if (is_numeric($key) || !is_string($key)) { |
|
| 38 | 38 | throw new \Exception("Invalid key type: ".gettype($key)); |
| 39 | 39 | } |
| 40 | 40 | $this->add($key, $value); |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | * @param Delegate $parent |
| 23 | 23 | */ |
| 24 | 24 | public function __construct($basePath, $fileExt = null, array $vars = array(), WorkerConfiguration $configuration = null, Delegate $parent = null) { |
| 25 | - if($fileExt === null) { |
|
| 25 | + if ($fileExt === null) { |
|
| 26 | 26 | $fileExt = '.phtml'; |
| 27 | 27 | } |
| 28 | - if($configuration === null) { |
|
| 28 | + if ($configuration === null) { |
|
| 29 | 29 | $configuration = new FileWorkerConfiguration(); |
| 30 | 30 | } |
| 31 | 31 | parent::__construct($vars, [], $configuration); |
@@ -64,23 +64,23 @@ discard block |
||
| 64 | 64 | $this->setRegions($regions); |
| 65 | 65 | |
| 66 | 66 | try { |
| 67 | - $content = $this->obRecord(function () use ($filename, $resource, $vars) { |
|
| 67 | + $content = $this->obRecord(function() use ($filename, $resource, $vars) { |
|
| 68 | 68 | $templateFilename = Directories::concat($this->currentWorkDir, $filename); |
| 69 | 69 | $templateFilename = $this->normalize($templateFilename); |
| 70 | - $templatePath = stream_resolve_include_path($templateFilename . $this->fileExt); |
|
| 71 | - if($templatePath === false) { |
|
| 70 | + $templatePath = stream_resolve_include_path($templateFilename.$this->fileExt); |
|
| 71 | + if ($templatePath === false) { |
|
| 72 | 72 | $templatePath = stream_resolve_include_path($templateFilename); |
| 73 | 73 | } |
| 74 | - if($templatePath !== false) { |
|
| 74 | + if ($templatePath !== false) { |
|
| 75 | 75 | $templateFilename = $templatePath; |
| 76 | - $fn = function () use ($templateFilename) { |
|
| 76 | + $fn = function() use ($templateFilename) { |
|
| 77 | 77 | /** @noinspection PhpIncludeInspection */ |
| 78 | 78 | require $templateFilename; |
| 79 | 79 | }; |
| 80 | 80 | $fn->bindTo(new \stdClass()); |
| 81 | 81 | call_user_func($fn); |
| 82 | 82 | } else { |
| 83 | - if($this->parent !== null) { |
|
| 83 | + if ($this->parent !== null) { |
|
| 84 | 84 | echo $this->parent->render($resource, $vars); |
| 85 | 85 | } else { |
| 86 | 86 | throw new Exception("Resource not found: {$resource}"); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @throws \Exception |
| 101 | 101 | */ |
| 102 | 102 | private function generateLayoutContent($content) { |
| 103 | - if($this->getLayout() !== null) { |
|
| 103 | + if ($this->getLayout() !== null) { |
|
| 104 | 104 | $regions = $this->getRegions(); |
| 105 | 105 | $regions['content'] = $content; |
| 106 | 106 | $layoutResource = $this->getLayout(); |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | * @return string |
| 133 | 133 | */ |
| 134 | 134 | private function normalize($templateFilename) { |
| 135 | - if(strpos($templateFilename, '..')) { |
|
| 135 | + if (strpos($templateFilename, '..')) { |
|
| 136 | 136 | $templateFilename = strtr($templateFilename, [DIRECTORY_SEPARATOR => '/']); |
| 137 | 137 | $templateFilename = preg_replace('/\\/+/', '/', $templateFilename); |
| 138 | 138 | $parts = explode('/', $templateFilename); |
| 139 | 139 | $correctedParts = []; |
| 140 | - foreach($parts as $part) { |
|
| 141 | - if($part === '.') { |
|
| 140 | + foreach ($parts as $part) { |
|
| 141 | + if ($part === '.') { |
|
| 142 | 142 | // Skip |
| 143 | - } elseif($part === '..') { |
|
| 144 | - if(count($correctedParts)) { |
|
| 143 | + } elseif ($part === '..') { |
|
| 144 | + if (count($correctedParts)) { |
|
| 145 | 145 | array_pop($correctedParts); |
| 146 | 146 | } else { |
| 147 | 147 | // Skip |