Skip to content

Commit e30d499

Browse files
set default value for superglobals
Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com>
1 parent 539cb56 commit e30d499

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

system/Commands/Utilities/Environment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ final class Environment extends BaseCommand
8686
public function run(array $params)
8787
{
8888
if ($params === []) {
89-
CLI::write(sprintf('Your environment is currently set as %s.', CLI::color(service('superglobals')->server('CI_ENVIRONMENT') ?? ENVIRONMENT, 'green')));
89+
CLI::write(sprintf('Your environment is currently set as %s.', CLI::color(service('superglobals')->server('CI_ENVIRONMENT', ENVIRONMENT), 'green')));
9090
CLI::newLine();
9191

9292
return EXIT_ERROR;
@@ -150,7 +150,7 @@ private function writeNewEnvironmentToEnvFile(string $newEnv): bool
150150
copy($baseEnv, $envFile);
151151
}
152152

153-
$pattern = preg_quote(service('superglobals')->server('CI_ENVIRONMENT') ?? ENVIRONMENT, '/');
153+
$pattern = preg_quote(service('superglobals')->server('CI_ENVIRONMENT', ENVIRONMENT), '/');
154154
$pattern = sprintf('/^[#\s]*CI_ENVIRONMENT[=\s]+%s$/m', $pattern);
155155

156156
return file_put_contents(

system/Config/Services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ public static function createRequest(App $config, bool $isCli = false): void
543543
$request = AppServices::incomingrequest($config);
544544

545545
// guess at protocol if needed
546-
$request->setProtocolVersion(static::superglobals()->server('SERVER_PROTOCOL') ?? 'HTTP/1.1');
546+
$request->setProtocolVersion(static::superglobals()->server('SERVER_PROTOCOL', 'HTTP/1.1'));
547547
}
548548

549549
// Inject the request object into Services.

system/HTTP/MessageTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function appendBody($data): self
8686
*/
8787
public function populateHeaders(): void
8888
{
89-
$contentType = service('superglobals')->server('CONTENT_TYPE') ?? getenv('CONTENT_TYPE');
89+
$contentType = service('superglobals')->server('CONTENT_TYPE', (string) getenv('CONTENT_TYPE'));
9090
if (! empty($contentType)) {
9191
$this->setHeader('Content-Type', $contentType);
9292
}

system/Pager/Pager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ protected function calculateCurrentPage(string $group)
434434
} else {
435435
$pageSelector = $this->groups[$group]['pageSelector'];
436436

437-
$page = (int) (service('superglobals')->get($pageSelector) ?? 1);
437+
$page = (int) (service('superglobals')->get($pageSelector, 1));
438438

439439
$this->groups[$group]['currentPage'] = $page < 1 ? 1 : $page;
440440
}

0 commit comments

Comments
 (0)