@@ -25,10 +25,10 @@ |
||
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 |
@@ -50,7 +50,7 @@ discard block |
||
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 |
||
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 |
||
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) { |
@@ -75,7 +75,7 @@ discard block |
||
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 |
||
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 | } |
@@ -78,7 +78,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 ..."); |
@@ -27,7 +27,7 @@ |
||
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); |
@@ -27,19 +27,19 @@ |
||
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 | } |
@@ -34,7 +34,7 @@ discard block |
||
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 |
||
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; |
@@ -37,7 +37,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $currdir = getcwd(); |
88 | 88 | $result = @chdir($this->workingDir); |
89 | - if(!$result){ |
|
89 | + if (!$result) { |
|
90 | 90 | $this->error("Cannot change working directory to '$this->workingDir'."); |
91 | 91 | } |
92 | 92 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | $result = @chdir($currdir); |
101 | - if(!$result){ |
|
101 | + if (!$result) { |
|
102 | 102 | $this->error("Cannot change working directory back to '$currdir'."); |
103 | 103 | } |
104 | 104 | } |