@@ -137,10 +137,10 @@ |
||
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 | } |
@@ -130,17 +130,17 @@ |
||
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 | $command->delete($destination); |
145 | 145 | } |
146 | 146 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | return; |
51 | 51 | } |
52 | 52 | $result = @unlink($file); |
53 | - if(!$result){ |
|
53 | + if (!$result) { |
|
54 | 54 | $this->error("Cannot delete file '$file'."); |
55 | 55 | } |
56 | 56 | } |
@@ -151,7 +151,7 @@ |
||
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 Exception("Cannot found service '$service' to inject into " . get_class($build) . "::$property."); |
156 | 156 | } |
157 | 157 | $build->$property = $container->getService($service); |
@@ -54,7 +54,7 @@ |
||
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 | } |
@@ -99,12 +99,18 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | + /** |
|
103 | + * @param integer $code |
|
104 | + */ |
|
102 | 105 | protected function terminate($code) |
103 | 106 | { |
104 | 107 | throw new TerminateException(NULL, $code); |
105 | 108 | } |
106 | 109 | |
107 | 110 | |
111 | + /** |
|
112 | + * @param string $workingDir |
|
113 | + */ |
|
108 | 114 | protected function detectBootstrapFilename($workingDir) |
109 | 115 | { |
110 | 116 | return $workingDir . DIRECTORY_SEPARATOR . 'bootstrap.php'; |
@@ -112,6 +118,8 @@ discard block |
||
112 | 118 | |
113 | 119 | |
114 | 120 | /** |
121 | + * @param string $workingDir |
|
122 | + * @param string $configFile |
|
115 | 123 | * @return Container |
116 | 124 | */ |
117 | 125 | protected function createContainer($workingDir, $configFile, Container $bootstrapContainer = NULL) |
@@ -165,6 +173,9 @@ discard block |
||
165 | 173 | } |
166 | 174 | |
167 | 175 | |
176 | + /** |
|
177 | + * @param IBuild $class |
|
178 | + */ |
|
168 | 179 | protected function getAutowiredProperties($class) |
169 | 180 | { |
170 | 181 | $return = []; |
@@ -180,6 +191,10 @@ discard block |
||
180 | 191 | } |
181 | 192 | |
182 | 193 | |
194 | + /** |
|
195 | + * @param string $color |
|
196 | + * @param string $backgroundColor |
|
197 | + */ |
|
183 | 198 | protected function log($message, $color = NULL, $backgroundColor = NULL) |
184 | 199 | { |
185 | 200 | echo Cli::getColoredString($message . PHP_EOL, $color, $backgroundColor); |
@@ -89,34 +89,34 @@ discard block |
||
89 | 89 | |
90 | 90 | // BC break check |
91 | 91 | $mainSections = ['includes', 'class', 'parameters', 'services']; |
92 | - foreach($config as $key => $val){ |
|
93 | - if(!in_array($key, $mainSections)) { |
|
92 | + foreach ($config as $key => $val) { |
|
93 | + if (!in_array($key, $mainSections)) { |
|
94 | 94 | throw new NotSupportedException("Since version 2.0 are supported main only these sections: " . implode(", ", $mainSections) . ". Section '$key' found. Move your variables into parameters section."); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | 98 | $container = new Container(); |
99 | 99 | $container->setClass($config['class']); |
100 | - if(isset($config['parameters'])){ |
|
100 | + if (isset($config['parameters'])) { |
|
101 | 101 | $container->setParameters($config['parameters']); |
102 | 102 | } |
103 | - if(isset($config['services'])){ |
|
104 | - foreach($config['services'] as $name => $config){ |
|
105 | - if(!is_array($config)){ |
|
103 | + if (isset($config['services'])) { |
|
104 | + foreach ($config['services'] as $name => $config) { |
|
105 | + if (!is_array($config)) { |
|
106 | 106 | $container->addService($name, $config); // is directly service object from merged container |
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | $class = $config['class']; |
110 | 110 | $arguments = []; |
111 | - if($config['class'] instanceof \Nette\Neon\Entity){ |
|
111 | + if ($config['class'] instanceof \Nette\Neon\Entity) { |
|
112 | 112 | $class = $config['class']->value; |
113 | 113 | $arguments = $config['class']->attributes; |
114 | 114 | } |
115 | 115 | $reflectionClass = new \ReflectionClass($class); |
116 | 116 | $service = $reflectionClass->newInstanceArgs($arguments); |
117 | - if(isset($config['setup'])){ |
|
118 | - foreach($config['setup'] as $neonEntity){ |
|
119 | - if(!method_exists($service, $neonEntity->value)){ |
|
117 | + if (isset($config['setup'])) { |
|
118 | + foreach ($config['setup'] as $neonEntity) { |
|
119 | + if (!method_exists($service, $neonEntity->value)) { |
|
120 | 120 | throw new ContainerFactoryException("Class $class does not have method $neonEntity->value()."); |
121 | 121 | } |
122 | 122 | call_user_func_array(array($service, $neonEntity->value), $neonEntity->attributes); |
@@ -177,18 +177,18 @@ discard block |
||
177 | 177 | { |
178 | 178 | $config = $this->resolveUnmergables($config); |
179 | 179 | foreach ($config as $key => $value) { |
180 | - if($value instanceof \Nette\Neon\Entity){ |
|
180 | + if ($value instanceof \Nette\Neon\Entity) { |
|
181 | 181 | $value->value = $this->parseValue($value->value, $allConfig); |
182 | - foreach($value->attributes as $k => $v){ |
|
183 | - if(is_array($v)){ |
|
182 | + foreach ($value->attributes as $k => $v) { |
|
183 | + if (is_array($v)) { |
|
184 | 184 | $value->attributes[$k] = $this->parseValues($v, $allConfig, array_merge($keysPath, [$key])); |
185 | - } else{ |
|
185 | + } else { |
|
186 | 186 | $value->attributes[$k] = $this->parseValue($v, $allConfig); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | } elseif (is_array($value)) { |
190 | 190 | $value = $this->parseValues($value, $allConfig, array_merge($keysPath, [$key])); |
191 | - } elseif(!is_object($value)) { |
|
191 | + } elseif (!is_object($value)) { |
|
192 | 192 | $value = $this->parseValue($value, $allConfig); |
193 | 193 | } |
194 | 194 | |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | if (preg_match_all('#%([^%]+)%#', $value, $matches)) { |
216 | 216 | foreach ($matches[1] as $match) { |
217 | 217 | $parameter = $config['parameters']; |
218 | - foreach(explode(".", $match) as $m){ |
|
218 | + foreach (explode(".", $match) as $m) { |
|
219 | 219 | if (!array_key_exists($m, $parameter)) { |
220 | 220 | throw new ContainerFactoryException("Cannot find variable '$match', part '$m'."); |
221 | 221 | } |
222 | 222 | $parameter = $parameter[$m]; |
223 | 223 | } |
224 | - if(is_array($parameter)){ |
|
225 | - if("%$match%" !== $value){ // if is variable value an array, must not be part of a string |
|
224 | + if (is_array($parameter)) { |
|
225 | + if ("%$match%" !== $value) { // if is variable value an array, must not be part of a string |
|
226 | 226 | throw new ContainerFactoryException("Array value cannot be part of a string."); |
227 | 227 | } |
228 | 228 | return $parameter; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | */ |
52 | 52 | public function setSectionTasks($section, array $tasks) |
53 | 53 | { |
54 | - if(!isset($this->sections[$section])){ |
|
54 | + if (!isset($this->sections[$section])) { |
|
55 | 55 | throw new InvalidArgumentException("Section '$section' not found."); |
56 | 56 | } |
57 | 57 | $this->sections[$section]['tasks'] = $tasks; |
@@ -62,7 +62,6 @@ discard block |
||
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Sets path to working directory |
65 | - * @param string $workingTree |
|
66 | 65 | */ |
67 | 66 | public function setWorkingDirectory($workingDirectory) |
68 | 67 | { |
@@ -100,7 +99,7 @@ discard block |
||
100 | 99 | |
101 | 100 | /** |
102 | 101 | * Sets git command (to be executed later) |
103 | - * @param mixed $command |
|
102 | + * @param string $command |
|
104 | 103 | */ |
105 | 104 | public function setCommand($command) |
106 | 105 | { |
@@ -139,6 +138,9 @@ discard block |
||
139 | 138 | } |
140 | 139 | |
141 | 140 | |
141 | + /** |
|
142 | + * @param string $command |
|
143 | + */ |
|
142 | 144 | private function exec($command) |
143 | 145 | { |
144 | 146 | $exec = new Exec(); |
@@ -127,12 +127,12 @@ |
||
127 | 127 | public function execute() |
128 | 128 | { |
129 | 129 | $command = ''; |
130 | - if($this->workingDirectory !== NULL){ |
|
130 | + if ($this->workingDirectory !== NULL) { |
|
131 | 131 | $command .= 'cd ' . escapeshellarg($this->workingDirectory) . ' && '; |
132 | 132 | } |
133 | 133 | $command .= escapeshellarg($this->gitExecutable); |
134 | 134 | $execCommand = $command . ' ' . $this->command; |
135 | - if($this->redirectStderrToStdout){ |
|
135 | + if ($this->redirectStderrToStdout) { |
|
136 | 136 | $execCommand .= ' 2>&1'; |
137 | 137 | } |
138 | 138 | return $this->exec($execCommand); |