@@ -88,7 +88,7 @@ |
||
| 88 | 88 | ->setTimeout((null === $config['timeout']) ? null : (float) $config['timeout']) |
| 89 | 89 | ->setIdleTimeout((null === $config['idle_timeout']) ? null : (float) $config['idle_timeout']); |
| 90 | 90 | |
| 91 | - $callback = function ($type, $buffer) use ($config, $host) { |
|
| 91 | + $callback = function($type, $buffer) use ($config, $host) { |
|
| 92 | 92 | $this->logger->printBuffer($host, $type, $buffer); |
| 93 | 93 | $this->pop->callback($host, boolval($config['real_time_output']))($type, $buffer); |
| 94 | 94 | }; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $dealersHand = []; |
| 81 | 81 | $playersHand = []; |
| 82 | 82 | shuffle($deck); |
| 83 | - $deal = function () use (&$deck, &$graveyard) { |
|
| 83 | + $deal = function() use (&$deck, &$graveyard) { |
|
| 84 | 84 | if (count($deck) == 0) { |
| 85 | 85 | shuffle($graveyard); |
| 86 | 86 | $deck = $graveyard; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | $variants = [$value]; |
| 289 | 289 | while ($aces-- > 0) { |
| 290 | - $variants = array_flatten(array_map(function ($v) { |
|
| 290 | + $variants = array_flatten(array_map(function($v) { |
|
| 291 | 291 | return [$v + 1, $v + 11]; |
| 292 | 292 | }, $variants)); |
| 293 | 293 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | function array_flatten(array $array) |
| 20 | 20 | { |
| 21 | 21 | $flatten = []; |
| 22 | - array_walk_recursive($array, function ($value) use (&$flatten) { |
|
| 22 | + array_walk_recursive($array, function($value) use (&$flatten) { |
|
| 23 | 23 | $flatten[] = $value; |
| 24 | 24 | }); |
| 25 | 25 | return $flatten; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | function env_stringify(array $array): string |
| 89 | 89 | { |
| 90 | 90 | return implode(' ', array_map( |
| 91 | - function ($key, $value) { |
|
| 91 | + function($key, $value) { |
|
| 92 | 92 | return sprintf("%s=%s", $key, escapeshellarg((string) $value)); |
| 93 | 93 | }, |
| 94 | 94 | array_keys($array), |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | if (getenv('COLORTERM') === 'truecolor') { |
| 182 | - $hsv = function ($h, $s, $v) { |
|
| 182 | + $hsv = function($h, $s, $v) { |
|
| 183 | 183 | $r = $g = $b = $i = $f = $p = $q = $t = 0; |
| 184 | 184 | $i = floor($h * 6); |
| 185 | 185 | $f = $h * 6 - $i; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $labels = $host->get('labels', []); |
| 54 | 54 | $labels['alias'] = $host->getAlias(); |
| 55 | 55 | $labels['true'] = 'true'; |
| 56 | - $isTrue = function ($value) { |
|
| 56 | + $isTrue = function($value) { |
|
| 57 | 57 | return $value; |
| 58 | 58 | }; |
| 59 | 59 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | private static function compare(string $op, $a, ?string $b): bool |
| 76 | 76 | { |
| 77 | - $matchFunction = function ($a, ?string $b) { |
|
| 77 | + $matchFunction = function($a, ?string $b) { |
|
| 78 | 78 | foreach ((array) $a as $item) { |
| 79 | 79 | if ($item === $b) { |
| 80 | 80 | return true; |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | $this->loop, |
| 60 | 60 | new React\Http\Middleware\StreamingRequestMiddleware(), |
| 61 | 61 | new React\Http\Middleware\RequestBodyBufferMiddleware(16 * 1024 * 1024), // 16 MiB |
| 62 | - function (ServerRequestInterface $request) { |
|
| 62 | + function(ServerRequestInterface $request) { |
|
| 63 | 63 | try { |
| 64 | 64 | return $this->router($request); |
| 65 | 65 | } catch (Throwable $exception) { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | return 0; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $callback = function (string $output) { |
|
| 185 | + $callback = function(string $output) { |
|
| 186 | 186 | $output = preg_replace('/\n$/', '', $output); |
| 187 | 187 | if (strlen($output) !== 0) { |
| 188 | 188 | $this->output->writeln($output); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | /** @var Process[] $processes */ |
| 193 | 193 | $processes = []; |
| 194 | 194 | |
| 195 | - $this->server->loop->futureTick(function () use (&$processes, $hosts, $task) { |
|
| 195 | + $this->server->loop->futureTick(function() use (&$processes, $hosts, $task) { |
|
| 196 | 196 | foreach ($hosts as $host) { |
| 197 | 197 | $processes[] = $this->createProcess($host, $task); |
| 198 | 198 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | }); |
| 204 | 204 | |
| 205 | - $this->server->loop->addPeriodicTimer(0.03, function ($timer) use (&$processes, $callback) { |
|
| 205 | + $this->server->loop->addPeriodicTimer(0.03, function($timer) use (&$processes, $callback) { |
|
| 206 | 206 | $this->gatherOutput($processes, $callback); |
| 207 | 207 | if ($this->output->isDecorated() && !getenv('CI')) { |
| 208 | 208 | $this->output->write(spinner()); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | foreach ($this->recipes as $recipe) { |
| 53 | 53 | // $find will try to return DocConfig for a given config $name. |
| 54 | - $findConfig = function (string $name) use ($recipe): ?DocConfig { |
|
| 54 | + $findConfig = function(string $name) use ($recipe): ?DocConfig { |
|
| 55 | 55 | if (array_key_exists($name, $recipe->config)) { |
| 56 | 56 | return $recipe->config[$name]; |
| 57 | 57 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | return null; |
| 71 | 71 | }; |
| 72 | - $findConfigOverride = function (DocRecipe $recipe, string $name) use (&$findConfigOverride): ?DocConfig { |
|
| 72 | + $findConfigOverride = function(DocRecipe $recipe, string $name) use (&$findConfigOverride): ?DocConfig { |
|
| 73 | 73 | foreach ($recipe->require as $r) { |
| 74 | 74 | if (array_key_exists($r, $this->recipes)) { |
| 75 | 75 | if (array_key_exists($name, $this->recipes[$r]->config)) { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | return null; |
| 86 | 86 | }; |
| 87 | 87 | // Replace all {{name}} with link to correct config declaration. |
| 88 | - $replaceLinks = function (string $comment) use ($findConfig): string { |
|
| 88 | + $replaceLinks = function(string $comment) use ($findConfig): string { |
|
| 89 | 89 | $output = ''; |
| 90 | 90 | $code = false; |
| 91 | 91 | foreach (explode("\n", $comment) as $i => $line) { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $output .= "\n"; |
| 98 | 98 | continue; |
| 99 | 99 | } |
| 100 | - $output .= preg_replace_callback('#(\{\{(?<name>[\w_:\-/]+)\}\})#', function ($m) use ($findConfig) { |
|
| 100 | + $output .= preg_replace_callback('#(\{\{(?<name>[\w_:\-/]+)\}\})#', function($m) use ($findConfig) { |
|
| 101 | 101 | $name = $m['name']; |
| 102 | 102 | $config = $findConfig($name); |
| 103 | 103 | if ($config !== null) { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | return $output; |
| 113 | 113 | }; |
| 114 | - $findTask = function (string $name, bool $searchOtherRecipes = true) use ($recipe): ?DocTask { |
|
| 114 | + $findTask = function(string $name, bool $searchOtherRecipes = true) use ($recipe): ?DocTask { |
|
| 115 | 115 | if (array_key_exists($name, $recipe->tasks)) { |
| 116 | 116 | return $recipe->tasks[$name]; |
| 117 | 117 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | MARKDOWN; |
| 172 | 172 | |
| 173 | - $map = function (DocTask $task, $ident = '') use (&$map, $findTask, &$intro): void { |
|
| 173 | + $map = function(DocTask $task, $ident = '') use (&$map, $findTask, &$intro): void { |
|
| 174 | 174 | foreach ($task->group as $taskName) { |
| 175 | 175 | $t = $findTask($taskName); |
| 176 | 176 | if ($t !== null) { |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | function indent(string $text): string |
| 358 | 358 | { |
| 359 | - return implode("\n", array_map(function ($line) { |
|
| 359 | + return implode("\n", array_map(function($line) { |
|
| 360 | 360 | return " " . $line; |
| 361 | 361 | }, explode("\n", $text))); |
| 362 | 362 | } |
@@ -95,19 +95,19 @@ discard block |
||
| 95 | 95 | new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'Recipe file path'), |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - $this['console'] = function () use ($console) { |
|
| 98 | + $this['console'] = function() use ($console) { |
|
| 99 | 99 | return $console; |
| 100 | 100 | }; |
| 101 | - $this['input'] = function () { |
|
| 101 | + $this['input'] = function() { |
|
| 102 | 102 | throw new \RuntimeException('Uninitialized "input" in Deployer container.'); |
| 103 | 103 | }; |
| 104 | - $this['output'] = function () { |
|
| 104 | + $this['output'] = function() { |
|
| 105 | 105 | throw new \RuntimeException('Uninitialized "output" in Deployer container.'); |
| 106 | 106 | }; |
| 107 | - $this['inputDefinition'] = function () { |
|
| 107 | + $this['inputDefinition'] = function() { |
|
| 108 | 108 | return new InputDefinition(); |
| 109 | 109 | }; |
| 110 | - $this['questionHelper'] = function () { |
|
| 110 | + $this['questionHelper'] = function() { |
|
| 111 | 111 | return $this->getHelper('question'); |
| 112 | 112 | }; |
| 113 | 113 | |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | * Config * |
| 116 | 116 | ******************************/ |
| 117 | 117 | |
| 118 | - $this['config'] = function () { |
|
| 118 | + $this['config'] = function() { |
|
| 119 | 119 | return new Configuration(); |
| 120 | 120 | }; |
| 121 | 121 | // -l act as if it had been invoked as a login shell (i.e. source ~/.profile file) |
| 122 | 122 | // -s commands are read from the standard input (no arguments should remain after this option) |
| 123 | - $this->config['shell'] = function () { |
|
| 123 | + $this->config['shell'] = function() { |
|
| 124 | 124 | if (currentHost() instanceof Localhost) { |
| 125 | 125 | return 'bash -s'; // Non-login shell for localhost. |
| 126 | 126 | } |
@@ -133,43 +133,43 @@ discard block |
||
| 133 | 133 | * Core * |
| 134 | 134 | ******************************/ |
| 135 | 135 | |
| 136 | - $this['pop'] = function ($c) { |
|
| 136 | + $this['pop'] = function($c) { |
|
| 137 | 137 | return new Printer($c['output']); |
| 138 | 138 | }; |
| 139 | - $this['sshClient'] = function ($c) { |
|
| 139 | + $this['sshClient'] = function($c) { |
|
| 140 | 140 | return new Client($c['output'], $c['pop'], $c['logger']); |
| 141 | 141 | }; |
| 142 | - $this['rsync'] = function ($c) { |
|
| 142 | + $this['rsync'] = function($c) { |
|
| 143 | 143 | return new Rsync($c['pop'], $c['output']); |
| 144 | 144 | }; |
| 145 | - $this['processRunner'] = function ($c) { |
|
| 145 | + $this['processRunner'] = function($c) { |
|
| 146 | 146 | return new ProcessRunner($c['pop'], $c['logger']); |
| 147 | 147 | }; |
| 148 | - $this['tasks'] = function () { |
|
| 148 | + $this['tasks'] = function() { |
|
| 149 | 149 | return new TaskCollection(); |
| 150 | 150 | }; |
| 151 | - $this['hosts'] = function () { |
|
| 151 | + $this['hosts'] = function() { |
|
| 152 | 152 | return new HostCollection(); |
| 153 | 153 | }; |
| 154 | - $this['scriptManager'] = function ($c) { |
|
| 154 | + $this['scriptManager'] = function($c) { |
|
| 155 | 155 | return new ScriptManager($c['tasks']); |
| 156 | 156 | }; |
| 157 | - $this['selector'] = function ($c) { |
|
| 157 | + $this['selector'] = function($c) { |
|
| 158 | 158 | return new Selector($c['hosts']); |
| 159 | 159 | }; |
| 160 | - $this['fail'] = function () { |
|
| 160 | + $this['fail'] = function() { |
|
| 161 | 161 | return new Collection(); |
| 162 | 162 | }; |
| 163 | - $this['messenger'] = function ($c) { |
|
| 163 | + $this['messenger'] = function($c) { |
|
| 164 | 164 | return new Messenger($c['input'], $c['output'], $c['logger']); |
| 165 | 165 | }; |
| 166 | - $this['server'] = function ($c) { |
|
| 166 | + $this['server'] = function($c) { |
|
| 167 | 167 | return new Server( |
| 168 | 168 | $c['output'], |
| 169 | 169 | $this, |
| 170 | 170 | ); |
| 171 | 171 | }; |
| 172 | - $this['master'] = function ($c) { |
|
| 172 | + $this['master'] = function($c) { |
|
| 173 | 173 | return new Master( |
| 174 | 174 | $c['input'], |
| 175 | 175 | $c['output'], |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $c['messenger'], |
| 178 | 178 | ); |
| 179 | 179 | }; |
| 180 | - $this['importer'] = function () { |
|
| 180 | + $this['importer'] = function() { |
|
| 181 | 181 | return new Importer(); |
| 182 | 182 | }; |
| 183 | 183 | |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | * Logger * |
| 186 | 186 | ******************************/ |
| 187 | 187 | |
| 188 | - $this['log_handler'] = function () { |
|
| 188 | + $this['log_handler'] = function() { |
|
| 189 | 189 | return !empty($this['log']) |
| 190 | 190 | ? new FileHandler($this['log']) |
| 191 | 191 | : new NullHandler(); |
| 192 | 192 | }; |
| 193 | - $this['logger'] = function () { |
|
| 193 | + $this['logger'] = function() { |
|
| 194 | 194 | return new Logger($this['log_handler']); |
| 195 | 195 | }; |
| 196 | 196 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $output->writeln([ |
| 336 | 336 | "<fg=white;bg=red> {$class} </> <comment>in {$file} on line {$exception->getLine()}:</>", |
| 337 | 337 | "", |
| 338 | - implode("\n", array_map(function ($line) { |
|
| 338 | + implode("\n", array_map(function($line) { |
|
| 339 | 339 | return " " . $line; |
| 340 | 340 | }, explode("\n", $exception->getMessage()))), |
| 341 | 341 | "", |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * Silverstripe configuration |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -set('shared_assets', function () { |
|
| 13 | +set('shared_assets', function() { |
|
| 14 | 14 | if (test('[ -d {{release_or_current_path}}/public ]') || test('[ -d {{deploy_path}}/shared/public ]')) { |
| 15 | 15 | return 'public/assets'; |
| 16 | 16 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | ]); |
| 30 | 30 | |
| 31 | 31 | // Silverstripe cli script |
| 32 | -set('silverstripe_cli_script', function () { |
|
| 32 | +set('silverstripe_cli_script', function() { |
|
| 33 | 33 | $paths = [ |
| 34 | 34 | 'framework/cli-script.php', |
| 35 | 35 | 'vendor/silverstripe/framework/cli-script.php', |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | * Helper tasks |
| 46 | 46 | */ |
| 47 | 47 | desc('Runs /dev/build'); |
| 48 | -task('silverstripe:build', function () { |
|
| 48 | +task('silverstripe:build', function() { |
|
| 49 | 49 | run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build'); |
| 50 | 50 | }); |
| 51 | 51 | |
| 52 | 52 | desc('Runs /dev/build?flush=all'); |
| 53 | -task('silverstripe:buildflush', function () { |
|
| 53 | +task('silverstripe:buildflush', function() { |
|
| 54 | 54 | run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build flush=all'); |
| 55 | 55 | }); |
| 56 | 56 | |