Completed
Push — master ( e2a1f2...9f2620 )
by Ron
02:23
created
src/Workers/FileWorker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	 * @param Delegate $parent
24 24
 	 */
25 25
 	public function __construct($basePath, $fileExt = null, array $vars = array(), WorkerConfiguration $configuration = null, Delegate $parent = null) {
26
-		if($fileExt === null)  {
26
+		if ($fileExt === null) {
27 27
 			$fileExt = '.phtml';
28 28
 		}
29
-		if($configuration === null) {
29
+		if ($configuration === null) {
30 30
 			$configuration = new FileWorkerConfiguration();
31 31
 		}
32 32
 		parent::__construct($vars, [], $configuration);
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 		$this->setVars($vars);
65 65
 		$this->setRegions($regions);
66 66
 
67
-		return ViewTryFinallySimulator::tryThis(function () use ($filename, $resource, $vars) {
68
-			$content = $this->obRecord(function () use ($filename, $resource, $vars) {
67
+		return ViewTryFinallySimulator::tryThis(function() use ($filename, $resource, $vars) {
68
+			$content = $this->obRecord(function() use ($filename, $resource, $vars) {
69 69
 				$templateFilename = Directories::concat($this->currentWorkDir, $filename);
70 70
 				$templateFilename = $this->normalize($templateFilename);
71
-				$templatePath = stream_resolve_include_path($templateFilename . $this->fileExt);
72
-				if($templatePath === false) {
71
+				$templatePath = stream_resolve_include_path($templateFilename.$this->fileExt);
72
+				if ($templatePath === false) {
73 73
 					$templatePath = stream_resolve_include_path($templateFilename);
74 74
 				}
75
-				if($templatePath !== false) {
75
+				if ($templatePath !== false) {
76 76
 					$templateFilename = $templatePath;
77
-					$fn = function () use ($templateFilename) {
77
+					$fn = function() use ($templateFilename) {
78 78
 						/** @noinspection PhpIncludeInspection */
79 79
 						require $templateFilename;
80 80
 					};
81 81
 					$fn->bindTo(new \stdClass());
82 82
 					call_user_func($fn);
83 83
 				} else {
84
-					if($this->parent !== null) {
84
+					if ($this->parent !== null) {
85 85
 						echo $this->parent->render($resource, $vars);
86 86
 					} else {
87 87
 						throw new Exception("Resource not found: {$resource}");
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 				}
90 90
 			});
91 91
 			return $this->generateLayoutContent($content);
92
-		}, function () use ($oldVars, $oldRegions) {
92
+		}, function() use ($oldVars, $oldRegions) {
93 93
 			$this->setVars($oldVars);
94 94
 			$this->setRegions($oldRegions);
95 95
 		});
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @throws \Exception
102 102
 	 */
103 103
 	private function generateLayoutContent($content) {
104
-		if($this->getLayout() !== null) {
104
+		if ($this->getLayout() !== null) {
105 105
 			$regions = $this->getRegions();
106 106
 			$regions['content'] = $content;
107 107
 			$layoutResource = $this->getLayout();
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
 	 * @return string
134 134
 	 */
135 135
 	private function normalize($templateFilename) {
136
-		if(strpos($templateFilename, '..')) {
136
+		if (strpos($templateFilename, '..')) {
137 137
 			$templateFilename = strtr($templateFilename, [DIRECTORY_SEPARATOR => '/']);
138 138
 			$templateFilename = preg_replace('/\\/+/', '/', $templateFilename);
139 139
 			$parts = explode('/', $templateFilename);
140 140
 			$correctedParts = [];
141
-			foreach($parts as $part) {
142
-				if($part === '.') {
141
+			foreach ($parts as $part) {
142
+				if ($part === '.') {
143 143
 					// Skip
144
-				} elseif($part === '..') {
145
-					if(count($correctedParts)) {
144
+				} elseif ($part === '..') {
145
+					if (count($correctedParts)) {
146 146
 						array_pop($correctedParts);
147 147
 					} else {
148 148
 						// Skip
Please login to merge, or discard this patch.