@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | -chdir(__DIR__); // to enable relative pathes to work |
|
| 40 | +chdir(__DIR__); // to enable relative pathes to work |
|
| 41 | 41 | |
| 42 | 42 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
| 43 | 43 | { |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | $argv = $_SERVER['argv']; |
| 52 | 52 | $cmd = array_shift($argv); |
| 53 | 53 | |
| 54 | -foreach($argv as $n => $arg) |
|
| 54 | +foreach ($argv as $n => $arg) |
|
| 55 | 55 | { |
| 56 | 56 | if ($arg[0] === '-') |
| 57 | 57 | { |
| 58 | - switch($arg) |
|
| 58 | + switch ($arg) |
|
| 59 | 59 | { |
| 60 | 60 | case '-v': |
| 61 | 61 | case '--verbose': |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | case '--git': |
| 76 | 76 | $run_git = true; |
| 77 | 77 | unset($argv[$n]); |
| 78 | - break 2; // no further argument processing, as they are for git |
|
| 78 | + break 2; // no further argument processing, as they are for git |
|
| 79 | 79 | |
| 80 | 80 | default: |
| 81 | 81 | usage("Unknown argument '$arg'!"); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | if (!$run_git && count($argv) > 1) usage("Too many arguments!"); |
| 87 | 87 | |
| 88 | -function usage($err=null) |
|
| 88 | +function usage($err = null) |
|
| 89 | 89 | { |
| 90 | 90 | global $cmd; |
| 91 | 91 | |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | 109 | // check if the necessary binaries are installed |
| 110 | -foreach($bins as $name => $binaries) |
|
| 110 | +foreach ($bins as $name => $binaries) |
|
| 111 | 111 | { |
| 112 | - foreach((array)$binaries as $bin) |
|
| 112 | + foreach ((array)$binaries as $bin) |
|
| 113 | 113 | { |
| 114 | 114 | if (file_exists($bin) && is_executable($bin)) |
| 115 | 115 | { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $bins[$name] = $$name = false; |
| 134 | 134 | error_log("Could not find $name command!"); |
| 135 | - if (!in_array($name, ['npm','grunt'])) |
|
| 135 | + if (!in_array($name, ['npm', 'grunt'])) |
|
| 136 | 136 | { |
| 137 | 137 | exit(1); |
| 138 | 138 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | -if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 147 | +if ($verbose) echo "Using following binaries: ".json_encode($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 148 | 148 | |
| 149 | 149 | if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
| 150 | 150 | |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | if (!exec($git.' branch --no-color', $output, $ret) || $ret) |
| 166 | 166 | { |
| 167 | - foreach($output as $line) |
|
| 167 | + foreach ($output as $line) |
|
| 168 | 168 | { |
| 169 | 169 | error_log($line); |
| 170 | 170 | } |
| 171 | 171 | exit($ret); |
| 172 | 172 | } |
| 173 | -foreach($output as $line) |
|
| 173 | +foreach ($output as $line) |
|
| 174 | 174 | { |
| 175 | 175 | if ($line[0] == '*') |
| 176 | 176 | { |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | echo "Updating to: $target\n"; |
| 218 | 218 | |
| 219 | 219 | // Update EGroupware itself and further apps installed via git |
| 220 | -foreach(scandir(__DIR__) as $dir) |
|
| 220 | +foreach (scandir(__DIR__) as $dir) |
|
| 221 | 221 | { |
| 222 | 222 | if ($dir !== '..' && file_exists(__DIR__.'/'.$dir.'/.git') && |
| 223 | 223 | // these apps / dirs are managed by composer, no need to run manual updates |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $git_cmd = $git.' '.implode(' ', array_map('escapeshellarg', $argv)); |
| 276 | 276 | |
| 277 | 277 | $ret = 0; |
| 278 | - foreach(scandir(__DIR__) as $dir) |
|
| 278 | + foreach (scandir(__DIR__) as $dir) |
|
| 279 | 279 | { |
| 280 | 280 | if ($dir !== '..' && file_exists(__DIR__.'/'.$dir.'/.git')) |
| 281 | 281 | { |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | * @param boolean $return_name =true true: just return name, false: full release object |
| 298 | 298 | * @return array|string|null null if no release found |
| 299 | 299 | */ |
| 300 | -function get_latest_release($prerelease=false, $return_name=true) |
|
| 300 | +function get_latest_release($prerelease = false, $return_name = true) |
|
| 301 | 301 | { |
| 302 | - foreach(github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release) |
|
| 302 | + foreach (github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release) |
|
| 303 | 303 | { |
| 304 | 304 | if ($prerelease || $release['prerelease'] === false) |
| 305 | 305 | { |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @throws Exception |
| 320 | 320 | * @return array with response |
| 321 | 321 | */ |
| 322 | -function github_api($_url, $data, $method='POST', $upload=null, $content_type=null) |
|
| 322 | +function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null) |
|
| 323 | 323 | { |
| 324 | 324 | global /*$config,*/ $verbose; |
| 325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | curl_setopt($c, CURLOPT_TIMEOUT, 240); |
| 333 | 333 | curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); |
| 334 | 334 | |
| 335 | - switch($method) |
|
| 335 | + switch ($method) |
|
| 336 | 336 | { |
| 337 | 337 | case 'POST': |
| 338 | 338 | curl_setopt($c, CURLOPT_POST, true); |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 341 | 341 | break; |
| 342 | 342 | case 'GET': |
| 343 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 343 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 344 | 344 | break; |
| 345 | 345 | case 'FILE': |
| 346 | 346 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 347 | 347 | curl_setopt($c, CURLOPT_POST, true); |
| 348 | 348 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 349 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 349 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 350 | 350 | break; |
| 351 | 351 | default: |
| 352 | 352 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | curl_setopt($c, CURLOPT_URL, $url); |
| 355 | 355 | |
| 356 | 356 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
| 357 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 357 | + if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n"; |
|
| 358 | 358 | |
| 359 | 359 | if (($response = curl_exec($c)) === false) |
| 360 | 360 | { |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | curl_setopt($c, CURLOPT_HEADER, true); |
| 363 | 363 | curl_setopt($c, CURLOPT_RETURNTRANSFER, false); |
| 364 | 364 | curl_exec($c); |
| 365 | - throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
|
| 365 | + throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : '')); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |