@@ -91,13 +91,19 @@ discard block |
||
91 | 91 | foreach($this->getActions() as $action => $info) { |
92 | 92 | echo "sspak $action"; |
93 | 93 | if(!empty($info['unnamedArgs'])) { |
94 | - foreach($info['unnamedArgs'] as $arg) echo " ($arg)"; |
|
94 | + foreach($info['unnamedArgs'] as $arg) { |
|
95 | + echo " ($arg)"; |
|
96 | + } |
|
95 | 97 | } |
96 | 98 | if(!empty($info['namedFlags'])) { |
97 | - foreach($info['namedFlags'] as $arg) echo " (--$arg)"; |
|
99 | + foreach($info['namedFlags'] as $arg) { |
|
100 | + echo " (--$arg)"; |
|
101 | + } |
|
98 | 102 | } |
99 | 103 | if(!empty($info['namedArgs'])) { |
100 | - foreach($info['namedArgs'] as $arg) echo " --$arg=\"$arg value\""; |
|
104 | + foreach($info['namedArgs'] as $arg) { |
|
105 | + echo " --$arg=\"$arg value\""; |
|
106 | + } |
|
101 | 107 | } |
102 | 108 | echo "\n {$info['description']}\n\n"; |
103 | 109 | } |
@@ -176,7 +182,9 @@ discard block |
||
176 | 182 | $sspak = new SSPakFile($file, $executor); |
177 | 183 | |
178 | 184 | // Validation |
179 | - if(!$sspak->exists()) throw new Exception("File '$file' doesn't exist."); |
|
185 | + if(!$sspak->exists()) { |
|
186 | + throw new Exception("File '$file' doesn't exist."); |
|
187 | + } |
|
180 | 188 | |
181 | 189 | $phar = $sspak->getPhar(); |
182 | 190 | $phar->extractTo($dest); |
@@ -255,7 +263,9 @@ discard block |
||
255 | 263 | |
256 | 264 | $webroot = new Webroot($unnamedArgs[0], $executor); |
257 | 265 | $file = $unnamedArgs[1]; |
258 | - if(file_exists($file)) throw new Exception( "File '$file' already exists."); |
|
266 | + if(file_exists($file)) { |
|
267 | + throw new Exception( "File '$file' already exists."); |
|
268 | + } |
|
259 | 269 | |
260 | 270 | $sspak = new SSPakFile($file, $executor); |
261 | 271 | |
@@ -263,8 +273,11 @@ discard block |
||
263 | 273 | // SSH private key |
264 | 274 | $webroot->setSSHItentityFile($namedArgs['identity']); |
265 | 275 | } |
266 | - if(!empty($namedArgs['from-sudo'])) $webroot->setSudo($namedArgs['from-sudo']); |
|
267 | - else if(!empty($namedArgs['sudo'])) $webroot->setSudo($namedArgs['sudo']); |
|
276 | + if(!empty($namedArgs['from-sudo'])) { |
|
277 | + $webroot->setSudo($namedArgs['from-sudo']); |
|
278 | + } else if(!empty($namedArgs['sudo'])) { |
|
279 | + $webroot->setSudo($namedArgs['sudo']); |
|
280 | + } |
|
268 | 281 | |
269 | 282 | // Look up which parts of the sspak are going to be saved |
270 | 283 | $pakParts = $args->pakParts(); |
@@ -367,7 +380,9 @@ discard block |
||
367 | 380 | $currentBranch = trim($matches[1]); |
368 | 381 | $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"branch.$currentBranch.remote")); |
369 | 382 | $remoteName = trim($output['output']); |
370 | - if(!$remoteName) $remoteName = 'origin'; |
|
383 | + if(!$remoteName) { |
|
384 | + $remoteName = 'origin'; |
|
385 | + } |
|
371 | 386 | |
372 | 387 | // Default to origin |
373 | 388 | } else { |
@@ -414,7 +429,9 @@ discard block |
||
414 | 429 | } |
415 | 430 | |
416 | 431 | // Validation |
417 | - if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist."); |
|
432 | + if(!$sspak->exists()) { |
|
433 | + throw new Exception( "File '$file' doesn't exist."); |
|
434 | + } |
|
418 | 435 | |
419 | 436 | // Push database, if necessary |
420 | 437 | $namedArgs = $args->getNamedArgs(); |
@@ -445,8 +462,12 @@ discard block |
||
445 | 462 | $pakParts = $args->pakParts(); |
446 | 463 | |
447 | 464 | // Validation |
448 | - if($webroot->exists($webroot->getPath())) throw new Exception( "Webroot '$webrootDir' already exists."); |
|
449 | - if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist."); |
|
465 | + if($webroot->exists($webroot->getPath())) { |
|
466 | + throw new Exception( "Webroot '$webrootDir' already exists."); |
|
467 | + } |
|
468 | + if(!$sspak->exists()) { |
|
469 | + throw new Exception( "File '$file' doesn't exist."); |
|
470 | + } |
|
450 | 471 | |
451 | 472 | // Create new dir |
452 | 473 | $webroot->exec(array('mkdir', $webroot->getPath())); |
@@ -98,8 +98,12 @@ discard block |
||
98 | 98 | * @return boolean |
99 | 99 | */ |
100 | 100 | public function exists($file = null) { |
101 | - if(!$file) $file = $this->path; |
|
102 | - if($file == '@self') return true; |
|
101 | + if(!$file) { |
|
102 | + $file = $this->path; |
|
103 | + } |
|
104 | + if($file == '@self') { |
|
105 | + return true; |
|
106 | + } |
|
103 | 107 | |
104 | 108 | if($this->server) { |
105 | 109 | $result = $this->exec("if [ -e " . escapeshellarg($file) . " ]; then echo yes; fi"); |
@@ -128,7 +132,9 @@ discard block |
||
128 | 132 | * @param string $file The file to remove |
129 | 133 | */ |
130 | 134 | public function unlink($file) { |
131 | - if(!$file || $file == '/' || $file == '.') throw new Exception("Can't unlink file '$file'"); |
|
135 | + if(!$file || $file == '/' || $file == '.') { |
|
136 | + throw new Exception("Can't unlink file '$file'"); |
|
137 | + } |
|
132 | 138 | $this->exec(array('rm', '-rf', $file)); |
133 | 139 | return true; |
134 | 140 | } |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | |
9 | 9 | public function __construct($path, $executor, $pharAlias = 'sspak.phar') { |
10 | 10 | parent::__construct($path, $executor); |
11 | - if(!$this->isLocal()) throw new LogicException("Can't manipulate remote .sspak.phar files, only remote webroots."); |
|
11 | + if(!$this->isLocal()) { |
|
12 | + throw new LogicException("Can't manipulate remote .sspak.phar files, only remote webroots."); |
|
13 | + } |
|
12 | 14 | |
13 | 15 | $this->pharAlias = $pharAlias; |
14 | 16 | $this->pharPath = $path; |
@@ -17,7 +19,9 @@ discard block |
||
17 | 19 | if(substr($path,-5) === '.phar') { |
18 | 20 | $this->phar = new Phar($path, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, |
19 | 21 | $this->pharAlias); |
20 | - if(!file_exists($this->path)) $this->makeExecutable(); |
|
22 | + if(!file_exists($this->path)) { |
|
23 | + $this->makeExecutable(); |
|
24 | + } |
|
21 | 25 | |
22 | 26 | // Non-executable Tar version |
23 | 27 | } else { |
@@ -154,7 +158,9 @@ discard block |
||
154 | 158 | $content = $this->content('git-remote'); |
155 | 159 | $details = array(); |
156 | 160 | foreach(explode("\n", trim($content)) as $line) { |
157 | - if(!$line) continue; |
|
161 | + if(!$line) { |
|
162 | + continue; |
|
163 | + } |
|
158 | 164 | |
159 | 165 | if(preg_match('/^([^ ]+) *= *(.*)$/', $line, $matches)) { |
160 | 166 | $details[$matches[1]] = $matches[2]; |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | |
36 | 36 | public function createLocal($command, $options) { |
37 | 37 | $options = array_merge($this->defaultOptions, $options); |
38 | - if(is_array($command)) $command = $this->commandArrayToString($command); |
|
38 | + if(is_array($command)) { |
|
39 | + $command = $this->commandArrayToString($command); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | return new Process($command, $options); |
41 | 43 | } |
@@ -81,8 +83,11 @@ discard block |
||
81 | 83 | |
82 | 84 | // Modify command for remote execution, if necessary. |
83 | 85 | if($this->remoteServer) { |
84 | - if(!empty($options['outputFile']) || !empty($options['outputStream'])) $ssh = "ssh -T "; |
|
85 | - else $ssh = "ssh -t "; |
|
86 | + if(!empty($options['outputFile']) || !empty($options['outputStream'])) { |
|
87 | + $ssh = "ssh -T "; |
|
88 | + } else { |
|
89 | + $ssh = "ssh -t "; |
|
90 | + } |
|
86 | 91 | if (!empty($options['identity'])) { |
87 | 92 | $ssh .= '-i ' . escapeshellarg($options['identity']) . ' '; |
88 | 93 | } |
@@ -99,7 +104,9 @@ discard block |
||
99 | 104 | ); |
100 | 105 | |
101 | 106 | // Alternatives |
102 | - if($options['inputContent'] || $options['inputStream']) $pipeSpec[0] = array('pipe', 'r'); |
|
107 | + if($options['inputContent'] || $options['inputStream']) { |
|
108 | + $pipeSpec[0] = array('pipe', 'r'); |
|
109 | + } |
|
103 | 110 | |
104 | 111 | if($options['outputFile']) { |
105 | 112 | $pipeSpec[1] = array('file', |
@@ -117,7 +124,9 @@ discard block |
||
117 | 124 | fwrite($pipes[0], $content); |
118 | 125 | } |
119 | 126 | } |
120 | - if(isset($pipes[0])) fclose($pipes[0]); |
|
127 | + if(isset($pipes[0])) { |
|
128 | + fclose($pipes[0]); |
|
129 | + } |
|
121 | 130 | |
122 | 131 | $result = array(); |
123 | 132 |
@@ -51,9 +51,13 @@ discard block |
||
51 | 51 | * Return the sudo argument, preferring a more specific one with the given optional prefix |
52 | 52 | */ |
53 | 53 | public function sudo($optionalPrefix) { |
54 | - if(!empty($this->namedArgs[$optionalPrefix . '-sudo'])) return $this->namedArgs[$optionalPrefix . '-sudo']; |
|
55 | - else if(!empty($this->namedArgs['sudo'])) return $this->namedArgs['sudo']; |
|
56 | - else return null; |
|
54 | + if(!empty($this->namedArgs[$optionalPrefix . '-sudo'])) { |
|
55 | + return $this->namedArgs[$optionalPrefix . '-sudo']; |
|
56 | + } else if(!empty($this->namedArgs['sudo'])) { |
|
57 | + return $this->namedArgs['sudo']; |
|
58 | + } else { |
|
59 | + return null; |
|
60 | + } |
|
57 | 61 | } |
58 | 62 | |
59 | 63 | /** |
@@ -67,7 +71,9 @@ discard block |
||
67 | 71 | } |
68 | 72 | |
69 | 73 | // Default to db and assets |
70 | - if(!array_filter($pakParts)) $pakParts = array('db' => true, 'assets' => true, 'git-remote' => true); |
|
74 | + if(!array_filter($pakParts)) { |
|
75 | + $pakParts = array('db' => true, 'assets' => true, 'git-remote' => true); |
|
76 | + } |
|
71 | 77 | return $pakParts; |
72 | 78 | } |
73 | 79 |
@@ -13,7 +13,9 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | $basePath = $_SERVER['argv'][1]; |
16 | -if($basePath[0] != '/') $basePath = getcwd() . '/' . $basePath; |
|
16 | +if($basePath[0] != '/') { |
|
17 | + $basePath = getcwd() . '/' . $basePath; |
|
18 | +} |
|
17 | 19 | |
18 | 20 | // SilverStripe bootstrap |
19 | 21 | define('BASE_PATH', realpath($basePath)); |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | * Calls sniff once and then caches |
17 | 17 | */ |
18 | 18 | public function details() { |
19 | - if(!$this->details) $this->details = $this->sniff(); |
|
19 | + if(!$this->details) { |
|
20 | + $this->details = $this->sniff(); |
|
21 | + } |
|
20 | 22 | return $this->details; |
21 | 23 | } |
22 | 24 | |
@@ -26,7 +28,9 @@ discard block |
||
26 | 28 | public function sniff() { |
27 | 29 | global $snifferFileContent; |
28 | 30 | |
29 | - if(!$snifferFileContent) $snifferFileContent = file_get_contents(PACKAGE_ROOT . 'src/sspak-sniffer.php'); |
|
31 | + if(!$snifferFileContent) { |
|
32 | + $snifferFileContent = file_get_contents(PACKAGE_ROOT . 'src/sspak-sniffer.php'); |
|
33 | + } |
|
30 | 34 | |
31 | 35 | $remoteSniffer = '/tmp/sspak-sniffer-' . rand(100000,999999) . '.php'; |
32 | 36 | $this->uploadContent($snifferFileContent, $remoteSniffer); |
@@ -35,7 +39,9 @@ discard block |
||
35 | 39 | $this->unlink($remoteSniffer); |
36 | 40 | |
37 | 41 | $parsed = @unserialize($result['output']); |
38 | - if(!$parsed) throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n"); |
|
42 | + if(!$parsed) { |
|
43 | + throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n"); |
|
44 | + } |
|
39 | 45 | return $parsed; |
40 | 46 | } |
41 | 47 | |
@@ -45,7 +51,9 @@ discard block |
||
45 | 51 | */ |
46 | 52 | public function execSudo($command, $options = array()) { |
47 | 53 | if($this->sudo) { |
48 | - if(is_array($command)) $command = $this->executor->commandArrayToString($command); |
|
54 | + if(is_array($command)) { |
|
55 | + $command = $this->executor->commandArrayToString($command); |
|
56 | + } |
|
49 | 57 | // Try running sudo without asking for a password |
50 | 58 | try { |
51 | 59 | return $this->exec("sudo -n -u " . escapeshellarg($this->sudo) . " " . $command, $options); |