Skip to content

Commit b2feb88

Browse files
Add more nullsafe operators
1 parent 2e77901 commit b2feb88

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

GenericRuntime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class GenericRuntime implements RuntimeInterface
5959
*/
6060
public function __construct(array $options = [])
6161
{
62-
$options['env_var_name'] ?? $options['env_var_name'] = 'APP_ENV';
63-
$debugKey = $options['debug_var_name'] ?? $options['debug_var_name'] = 'APP_DEBUG';
62+
$options['env_var_name'] ??= 'APP_ENV';
63+
$debugKey = $options['debug_var_name'] ??= 'APP_DEBUG';
6464

6565
$debug = $options['debug'] ?? $_SERVER[$debugKey] ?? $_ENV[$debugKey] ?? true;
6666

SymfonyRuntime.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ class SymfonyRuntime extends GenericRuntime
9090
*/
9191
public function __construct(array $options = [])
9292
{
93-
$envKey = $options['env_var_name'] ?? $options['env_var_name'] = 'APP_ENV';
94-
$debugKey = $options['debug_var_name'] ?? $options['debug_var_name'] = 'APP_DEBUG';
93+
$envKey = $options['env_var_name'] ??= 'APP_ENV';
94+
$debugKey = $options['debug_var_name'] ??= 'APP_DEBUG';
9595

9696
if (isset($options['env'])) {
9797
$_SERVER[$envKey] = $options['env'];
@@ -105,14 +105,14 @@ public function __construct(array $options = [])
105105
->setProdEnvs((array) ($options['prod_envs'] ?? ['prod']))
106106
->usePutenv($options['use_putenv'] ?? false)
107107
->bootEnv($options['project_dir'].'/'.($options['dotenv_path'] ?? '.env'), 'dev', (array) ($options['test_envs'] ?? ['test']), $options['dotenv_overload'] ?? false);
108-
$options['debug'] ?? $options['debug'] = '1' === $_SERVER[$debugKey];
108+
$options['debug'] ??= '1' === $_SERVER[$debugKey];
109109
$options['disable_dotenv'] = true;
110110
} else {
111-
$_SERVER[$envKey] ?? $_SERVER[$envKey] = $_ENV[$envKey] ?? 'dev';
112-
$_SERVER[$debugKey] ?? $_SERVER[$debugKey] = $_ENV[$debugKey] ?? !\in_array($_SERVER[$envKey], (array) ($options['prod_envs'] ?? ['prod']), true);
111+
$_SERVER[$envKey] ??= $_ENV[$envKey] ?? 'dev';
112+
$_SERVER[$debugKey] ??= $_ENV[$debugKey] ?? !\in_array($_SERVER[$envKey], (array) ($options['prod_envs'] ?? ['prod']), true);
113113
}
114114

115-
$options['error_handler'] ?? $options['error_handler'] = SymfonyErrorHandler::class;
115+
$options['error_handler'] ??= SymfonyErrorHandler::class;
116116

117117
parent::__construct($options);
118118
}
@@ -128,7 +128,7 @@ public function getRunner(?object $application): RunnerInterface
128128
}
129129

130130
if ($application instanceof Command) {
131-
$console = $this->console ?? $this->console = new Application();
131+
$console = $this->console ??= new Application();
132132
$console->setName($application->getName() ?: $console->getName());
133133

134134
if (!$application->getName() || !$console->has($application->getName())) {
@@ -149,7 +149,7 @@ public function getRunner(?object $application): RunnerInterface
149149

150150
set_time_limit(0);
151151
$defaultEnv = !isset($this->options['env']) ? ($_SERVER[$this->options['env_var_name']] ?? 'dev') : null;
152-
$output = $this->output ?? $this->output = new ConsoleOutput();
152+
$output = $this->output ??= new ConsoleOutput();
153153

154154
return new ConsoleApplicationRunner($application, $defaultEnv, $this->getInput(), $output);
155155
}
@@ -171,13 +171,13 @@ protected function getArgument(\ReflectionParameter $parameter, ?string $type):
171171
return $this->getInput();
172172

173173
case OutputInterface::class:
174-
return $this->output ?? $this->output = new ConsoleOutput();
174+
return $this->output ??= new ConsoleOutput();
175175

176176
case Application::class:
177-
return $this->console ?? $this->console = new Application();
177+
return $this->console ??= new Application();
178178

179179
case Command::class:
180-
return $this->command ?? $this->command = new Command();
180+
return $this->command ??= new Command();
181181
}
182182

183183
return parent::getArgument($parameter, $type);

0 commit comments

Comments
 (0)