Completed
Push — master ( f29bd1...c64831 )
by Adam
03:32
created
Cli.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 
26 26
 	public static function getColoredString($string, $foreground = NULL, $background = NULL)
27 27
 	{
28
-		if(!self::$enableColors){
28
+		if (!self::$enableColors) {
29 29
 			return $string;
30 30
 		}
31
-		if($foreground === NULL && $background === NULL){
31
+		if ($foreground === NULL && $background === NULL) {
32 32
 			return $string;
33 33
 		}
34 34
 
Please login to merge, or discard this patch.
config/ContainerFactory.php 2 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -179,11 +179,11 @@
 block discarded – undo
179 179
 				foreach($value->attributes as $k => $v){
180 180
 					if(is_array($v)){
181 181
 						$value->attributes[$k] = $this->parseValues($v, $allConfig, array_merge($keysPath, [$key]));
182
-					}else{
182
+					} else{
183 183
 						$value->attributes[$k] = $this->parseValue($v, $allConfig);
184 184
 					}
185 185
 				}
186
-			}elseif (is_array($value)) {
186
+			} elseif (is_array($value)) {
187 187
 				$value = $this->parseValues($value, $allConfig, array_merge($keysPath, [$key]));
188 188
 			} elseif(!is_object($value)) {
189 189
 				$value = $this->parseValue($value, $allConfig);
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 				'workingDirectory' => $this->workingDirectory,
71 71
 			]
72 72
 		];
73
-		if($this->containersToMerge !== NULL){
73
+		if ($this->containersToMerge !== NULL) {
74 74
 			foreach ($this->containersToMerge as $containerToMerge) {
75 75
 				foreach ($containerToMerge->getParameters() as $k => $v) {
76 76
 					$config['parameters'][$k] = $v;
@@ -86,34 +86,34 @@  discard block
 block discarded – undo
86 86
 
87 87
 		// BC break check
88 88
 		$mainSections = ['includes', 'class', 'parameters', 'services'];
89
-		foreach($config as $key => $val){
90
-			if(!in_array($key, $mainSections)) {
89
+		foreach ($config as $key => $val) {
90
+			if (!in_array($key, $mainSections)) {
91 91
 				throw new \RuntimeException("Since version 2.0 are supported main only these sections: " . implode(", ", $mainSections) . ". Section '$key' found. Move your variables into parameters section.");
92 92
 			}
93 93
 		}
94 94
 
95 95
 		$container = new Container();
96 96
 		$container->setClass($config['class']);
97
-		if(isset($config['parameters'])){
97
+		if (isset($config['parameters'])) {
98 98
 			$container->setParameters($config['parameters']);
99 99
 		}
100
-		if(isset($config['services'])){
101
-			foreach($config['services'] as $name => $config){
102
-				if(!is_array($config)){
100
+		if (isset($config['services'])) {
101
+			foreach ($config['services'] as $name => $config) {
102
+				if (!is_array($config)) {
103 103
 					$container->addService($name, $config); // is directly service object from merged container
104 104
 					continue;
105 105
 				}
106 106
 				$class = $config['class'];
107 107
 				$arguments = [];
108
-				if($config['class'] instanceof \Nette\Neon\Entity){
108
+				if ($config['class'] instanceof \Nette\Neon\Entity) {
109 109
 					$class = $config['class']->value;
110 110
 					$arguments = $config['class']->attributes;
111 111
 				}
112 112
 				$reflectionClass = new \ReflectionClass($class);
113 113
 				$service = $reflectionClass->newInstanceArgs($arguments);
114
-				if(isset($config['setup'])){
115
-					foreach($config['setup'] as $neonEntity){
116
-						if(!method_exists($service, $neonEntity->value)){
114
+				if (isset($config['setup'])) {
115
+					foreach ($config['setup'] as $neonEntity) {
116
+						if (!method_exists($service, $neonEntity->value)) {
117 117
 							throw new \RuntimeException("Class $class does not have method $neonEntity->value().");
118 118
 						}
119 119
 						call_user_func_array(array($service, $neonEntity->value), $neonEntity->attributes);
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 		$return = [];
133 133
 		foreach ($files as $file) {
134 134
 			$array = $this->readFile($file);
135
-			if($array !== NULL){
136
-				if(isset($array['includes'])){
137
-					foreach($array['includes'] as $include){
135
+			if ($array !== NULL) {
136
+				if (isset($array['includes'])) {
137
+					foreach ($array['includes'] as $include) {
138 138
 						$return[] = dirname($file) . DIRECTORY_SEPARATOR . $include;
139 139
 					}
140 140
 				}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	{
150 150
 		foreach ($files as $file) {
151 151
 			$array = $this->readFile($file);
152
-			if($array !== NULL) {
152
+			if ($array !== NULL) {
153 153
 				$config = array_replace_recursive($config, $array);
154 154
 			}
155 155
 		}
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 	{
175 175
 		$config = $this->resolveUnmergables($config);
176 176
 		foreach ($config as $key => $value) {
177
-			if($value instanceof \Nette\Neon\Entity){
177
+			if ($value instanceof \Nette\Neon\Entity) {
178 178
 				$value->value = $this->parseValue($value->value, $allConfig);
179
-				foreach($value->attributes as $k => $v){
180
-					if(is_array($v)){
179
+				foreach ($value->attributes as $k => $v) {
180
+					if (is_array($v)) {
181 181
 						$value->attributes[$k] = $this->parseValues($v, $allConfig, array_merge($keysPath, [$key]));
182
-					}else{
182
+					} else {
183 183
 						$value->attributes[$k] = $this->parseValue($v, $allConfig);
184 184
 					}
185 185
 				}
186 186
 			}elseif (is_array($value)) {
187 187
 				$value = $this->parseValues($value, $allConfig, array_merge($keysPath, [$key]));
188
-			} elseif(!is_object($value)) {
188
+			} elseif (!is_object($value)) {
189 189
 				$value = $this->parseValue($value, $allConfig);
190 190
 			}
191 191
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 			$config[$newKey] = $value;
196 196
 
197 197
 			// write to global config
198
-			$v =& $allConfig;
198
+			$v = & $allConfig;
199 199
 			foreach ($keysPath as $kp) {
200
-				$v =& $v[$kp];
200
+				$v = & $v[$kp];
201 201
 			}
202
-			if(!($value instanceof \Nette\Neon\Entity)) {
202
+			if (!($value instanceof \Nette\Neon\Entity)) {
203 203
 				$v[$newKey] = $value;
204 204
 			}
205 205
 		}
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 		if (preg_match_all('#%([^%]+)%#', $value, $matches)) {
213 213
 			foreach ($matches[1] as $match) {
214 214
 				$parameter = $config['parameters'];
215
-				foreach(explode(".", $match) as $m){
215
+				foreach (explode(".", $match) as $m) {
216 216
 					if (!array_key_exists($m, $parameter)) {
217 217
 						throw new \RuntimeException("Cannot find variable '$match', part '$m'.");
218 218
 					}
219 219
 					$parameter = $parameter[$m];
220 220
 				}
221
-				if(is_array($parameter)){
222
-					if("%$match%" !== $value){ // if is variable value an array, must not be part of a string
221
+				if (is_array($parameter)) {
222
+					if ("%$match%" !== $value) { // if is variable value an array, must not be part of a string
223 223
 						throw new \RuntimeException("Array value cannot be part of a string.");
224 224
 					}
225 225
 					return $parameter;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	private function resolveUnmergables($config)
235 235
 	{
236 236
 		foreach ($config as $key => $value) {
237
-			if(preg_match('#!$#', $key)){
237
+			if (preg_match('#!$#', $key)) {
238 238
 				$newKey = substr($key, 0, strlen($key) - 1);
239 239
 				$config[$newKey] = $value;
240 240
 				unset($config[$key]);
Please login to merge, or discard this patch.
commands/Help.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function setSectionTasks($section, array $tasks)
52 52
 	{
53
-		if(!isset($this->sections[$section])){
53
+		if (!isset($this->sections[$section])) {
54 54
 			throw new \InvalidArgumentException("Section '$section' not found.");
55 55
 		}
56 56
 		$this->sections[$section]['tasks'] = $tasks;
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 		// detect max width
63 63
 		$minColumnWidth = 30;
64 64
 		foreach ($this->sections as $sectionName => $data) {
65
-			if(strlen($sectionName) > $minColumnWidth){
65
+			if (strlen($sectionName) > $minColumnWidth) {
66 66
 				$minColumnWidth = strlen($sectionName) + 5;
67 67
 			}
68 68
 			foreach ($data['tasks'] as $taskName => $description) {
69
-				if(strlen($taskName) > $minColumnWidth){
69
+				if (strlen($taskName) > $minColumnWidth) {
70 70
 					$minColumnWidth = strlen($taskName) + 2 + 5;
71 71
 				}
72 72
 			}
73 73
 		}
74 74
 		// empty section first
75
-		if(isset($this->sections[''])){
75
+		if (isset($this->sections[''])) {
76 76
 			$val = $this->sections[''];
77 77
 			unset($this->sections['']);
78 78
 			$this->sections = ['' => $val] + $this->sections;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		echo "Available tasks:" . PHP_EOL;
85 85
 		foreach ($this->sections as $sectionName => $data) {
86 86
 			echo Cli::getColoredString($sectionName, 'yellow');
87
-			echo str_repeat(" ", $minColumnWidth - strlen($sectionName) + 2);  // +2 = two spaces before taskName (below)
87
+			echo str_repeat(" ", $minColumnWidth - strlen($sectionName) + 2); // +2 = two spaces before taskName (below)
88 88
 			echo Cli::getColoredString($data['description'], 'dark_gray');
89 89
 			echo PHP_EOL;
90 90
 			foreach ($data['tasks'] as $taskName => $description) {
Please login to merge, or discard this patch.
commands/SelfInit.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	public function execute()
76 76
 	{
77 77
 		$buildDir = $this->workingDirectory . DIRECTORY_SEPARATOR . $this->dirname;
78
-		if(is_dir($buildDir)){
78
+		if (is_dir($buildDir)) {
79 79
 			$this->error("Directory '$this->dirname' in working directory '$this->workingDirectory' already exists.");
80 80
 		}
81 81
 		$directory = new Filesystem\Directory();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		foreach ($directory->read($this->distDirectory) as $fileInfo) {
86 86
 			$newFile = $buildDir . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
87 87
 			$file->copy($fileInfo->getPathName(), $newFile);
88
-			if($fileInfo->getFilename() === 'build'){
88
+			if ($fileInfo->getFilename() === 'build') {
89 89
 				$file->makeExecutable($newFile);
90 90
 			}
91 91
 		}
Please login to merge, or discard this patch.
commands/filesystem/Filesystem.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function addSymlinksRelativeToCreate(array $symlinksRelativeToCreate, $baseDir)
80 80
 	{
81
-		if(!isset($this->symlinksRelativeToCreate[$baseDir])){
81
+		if (!isset($this->symlinksRelativeToCreate[$baseDir])) {
82 82
 			$this->symlinksRelativeToCreate[$baseDir] = [];
83 83
 		}
84 84
 		$this->symlinksRelativeToCreate[$baseDir] = array_merge($this->symlinksRelativeToCreate[$baseDir], $symlinksRelativeToCreate);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 	public function execute()
112 112
 	{
113
-		if(count($this->directoriesToCreate) > 0) {
113
+		if (count($this->directoriesToCreate) > 0) {
114 114
 			$this->log(Cli::getColoredString('Creating directories', 'light_blue'));
115 115
 			$command = new Directory();
116 116
 			foreach ($this->directoriesToCreate as $directory => $chmod) {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				$this->log("Directory '$directory' created.");
123 123
 			}
124 124
 		}
125
-		if(count($this->directoriesToClean) > 0) {
125
+		if (count($this->directoriesToClean) > 0) {
126 126
 			$this->log(Cli::getColoredString('Cleaning directories', 'light_blue'));
127 127
 			$command = new Directory();
128 128
 			foreach ($this->directoriesToClean as $directory) {
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 				$this->log("Directory '$directory' cleaned.");
131 131
 			}
132 132
 		}
133
-		if(count($this->filesToCopy) > 0) {
133
+		if (count($this->filesToCopy) > 0) {
134 134
 			$this->log(Cli::getColoredString('Copying files', 'light_blue'));
135 135
 			$command = new File();
136 136
 			foreach ($this->filesToCopy as $destination => $options) {
137
-				if(is_file($destination)){
138
-					if($options['onDuplicate'] == self::ERROR){
137
+				if (is_file($destination)) {
138
+					if ($options['onDuplicate'] == self::ERROR) {
139 139
 						$this->error("File '$destination' already exists.");
140
-					}elseif($options['onDuplicate'] == self::SKIP){
140
+					}elseif ($options['onDuplicate'] == self::SKIP) {
141 141
 						$this->log("File '$destination' already exists, skipping ...");
142 142
 						continue;
143
-					}elseif($options['onDuplicate'] == self::REWRITE){
143
+					}elseif ($options['onDuplicate'] == self::REWRITE) {
144 144
 						@unlink($destination);
145 145
 					}
146 146
 				}
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 				$this->log("File '$options[source]' copied to '$destination'.");
149 149
 			}
150 150
 		}
151
-		if(count($this->symlinksRelativeToCreate) > 0) {
151
+		if (count($this->symlinksRelativeToCreate) > 0) {
152 152
 			$this->log(Cli::getColoredString('Creating symlinks', 'light_blue'));
153 153
 			$command = new \Genesis\Commands\Filesystem\Symlink();
154
-			foreach($this->symlinksRelativeToCreate as $baseDir => $symlinks){
155
-				foreach($symlinks as $link => $target) {
154
+			foreach ($this->symlinksRelativeToCreate as $baseDir => $symlinks) {
155
+				foreach ($symlinks as $link => $target) {
156 156
 					$absoluteLinkPath = $baseDir . '/' . $link;
157 157
 					if (is_link($absoluteLinkPath)) {
158 158
 						$this->log("Symlink '$link' already exists, skipping ...");
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -137,10 +137,10 @@
 block discarded – undo
137 137
 				if(is_file($destination)){
138 138
 					if($options['onDuplicate'] == self::ERROR){
139 139
 						$this->error("File '$destination' already exists.");
140
-					}elseif($options['onDuplicate'] == self::SKIP){
140
+					} elseif($options['onDuplicate'] == self::SKIP){
141 141
 						$this->log("File '$destination' already exists, skipping ...");
142 142
 						continue;
143
-					}elseif($options['onDuplicate'] == self::REWRITE){
143
+					} elseif($options['onDuplicate'] == self::REWRITE){
144 144
 						@unlink($destination);
145 145
 					}
146 146
 				}
Please login to merge, or discard this patch.
commands/filesystem/Symlink.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 */
28 28
 	public function createRelative($directory, $target, $link)
29 29
 	{
30
-		if(!is_dir($directory)){
30
+		if (!is_dir($directory)) {
31 31
 			$this->error("Directory '$directory' not found.");
32 32
 		}
33 33
 		$cmd = 'cd ' . escapeshellarg($directory) . ' && ln -s  ' . escapeshellarg($target) . ' ' . escapeshellarg($link);
Please login to merge, or discard this patch.
commands/filesystem/Directory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 block discarded – undo
27 27
 			if ($file->isLink()) {
28 28
 				$this->checkPath($file->getPathName(), $directory);
29 29
 				$result = @unlink($file->getPathname());
30
-				if(!$result){
30
+				if (!$result) {
31 31
 					$this->error("Cannot delete symlink '$file'.");
32 32
 				}
33 33
 			} elseif ($file->isDir()) {
34 34
 				$this->checkPath($file->getPathName(), $directory);
35 35
 				$result = @rmdir($file->getPathName());
36
-				if(!$result){
36
+				if (!$result) {
37 37
 					$this->error("Cannot delete file '$file'.");
38 38
 				}
39 39
 			} elseif ($file->isFile()) {
40 40
 				$this->checkPath($file->getPathName(), $directory);
41 41
 				$result = @unlink($file->getPathname());
42
-				if(!$result){
42
+				if (!$result) {
43 43
 					$this->error("Cannot delete file '$file'.");
44 44
 				}
45 45
 			}
Please login to merge, or discard this patch.
Build.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	{
35 35
 		$helpCommand = new Commands\Help;
36 36
 		foreach ($this->detectAvailableTasks() as $section => $tasks) {
37
-			if(!$helpCommand->hasSection($section)){
37
+			if (!$helpCommand->hasSection($section)) {
38 38
 				$helpCommand->addSection($section);
39 39
 			}
40 40
 			$helpCommand->setSectionTasks($section, $tasks);
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 			if (preg_match('#^run(.*)#', $method->getName(), $match)) {
52 52
 				$doc = $method->getDocComment();
53 53
 				$section = NULL;
54
-				if(preg_match('#@section ?([^\s]*)\s#s', $doc, $m)){
54
+				if (preg_match('#@section ?([^\s]*)\s#s', $doc, $m)) {
55 55
 					$section = trim($m[1]);
56 56
 				}
57 57
 				$description = NULL;
58
-				if(preg_match('#([^@][a-zA-Z0-9]+)+#', $doc, $m)){
58
+				if (preg_match('#([^@][a-zA-Z0-9]+)+#', $doc, $m)) {
59 59
 					$description = trim($m[0]);
60 60
 				}
61 61
 				$tasks[$section][lcfirst($match[1])] = $description != '' ? $description : NULL;
Please login to merge, or discard this patch.
Bootstrap.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		}
38 38
 
39 39
 		$arguments = $inputArgs->getArguments();
40
-		if(isset($arguments[0]) && $arguments[0] === 'self-init'){
40
+		if (isset($arguments[0]) && $arguments[0] === 'self-init') {
41 41
 			$directoryName = isset($arguments[1]) ? $arguments[1] : 'build';
42 42
 			$selfInit = new Commands\SelfInit();
43 43
 			$selfInit->setDistDirectory(__DIR__ . '/build-dist');
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 		if (is_file($bootstrapFile)) {
53 53
 			$this->log("Info: Found bootstrap.php in working directory.", 'dark_gray');
54 54
 			$container = require_once $bootstrapFile;
55
-			if($container === 1 || $container === TRUE){ // 1 = success, TRUE = already required
55
+			if ($container === 1 || $container === TRUE) { // 1 = success, TRUE = already required
56 56
 				$container = NULL;
57
-			}elseif(!($container instanceof Container)){
57
+			}elseif (!($container instanceof Container)) {
58 58
 				$this->log("Returned value from bootstrap.php must be instance of 'Genesis\\Container\\Container' or nothing (NULL).", 'red');
59 59
 				exit(255);
60 60
 			}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	{
113 113
 		$factory = new ContainerFactory();
114 114
 		$factory->addConfig($workingDir . '/' . $configFile);
115
-		if(is_file($workingDir . '/config.local.neon')){
115
+		if (is_file($workingDir . '/config.local.neon')) {
116 116
 			$factory->addConfig($workingDir . '/config.local.neon');
117 117
 		}
118 118
 		$factory->setWorkingDirectory($workingDir);
119
-		if($bootstrapContainer !== NULL){
119
+		if ($bootstrapContainer !== NULL) {
120 120
 			$factory->addContainerToMerge($bootstrapContainer);
121 121
 		}
122 122
 		return $factory->create();
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	protected function autowire(IBuild $build, Container $container)
152 152
 	{
153 153
 		foreach ($this->getAutowiredProperties($build) as $property => $service) {
154
-			if(!$container->hasService($service)){
154
+			if (!$container->hasService($service)) {
155 155
 				throw new \RuntimeException("Cannot found service '$service' to inject into " . get_class($build) . "::$property.");
156 156
 			}
157 157
 			$build->$property = $container->getService($service);
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	{
164 164
 		$return = [];
165 165
 		$reflectionClass = new \ReflectionClass($class);
166
-		foreach($reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $property){
166
+		foreach ($reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
167 167
 			$reflectionProp = new \ReflectionProperty($class, $property->getName());
168 168
 			$doc = $reflectionProp->getDocComment();
169
-			if(preg_match('#@inject ?([^\s]*)\s#s', $doc, $matches)){
169
+			if (preg_match('#@inject ?([^\s]*)\s#s', $doc, $matches)) {
170 170
 				$return[$property->getName()] = trim($matches[1]) !== '' ? $matches[1] : $property->getName();
171 171
 			}
172 172
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 			$container = require_once $bootstrapFile;
55 55
 			if($container === 1 || $container === TRUE){ // 1 = success, TRUE = already required
56 56
 				$container = NULL;
57
-			}elseif(!($container instanceof Container)){
57
+			} elseif(!($container instanceof Container)){
58 58
 				$this->log("Returned value from bootstrap.php must be instance of 'Genesis\\Container\\Container' or nothing (NULL).", 'red');
59 59
 				exit(255);
60 60
 			}
Please login to merge, or discard this patch.