Skip to content

Commit

Permalink
ENH PHP 8.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 13, 2022
1 parent deecedd commit ec91eff
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion code/PortChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function isPortOpen($host, $port)
$host = 'localhost';
}

$connection = @fsockopen($host, $port);
$connection = @fsockopen($host ?? '', $port ?? 0);
if (is_resource($connection)) {
fclose($connection);
return true;
Expand Down
6 changes: 3 additions & 3 deletions code/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public function launchServer($options)
$port = PortChecker::findNextAvailablePort($host, $options['preferredPort']);

$base = __DIR__;
$command = "exec " . escapeshellcmd($bin) .
$command = "exec " . escapeshellcmd($bin ?? '') .
' -S ' . escapeshellarg($host . ':' . $port) .
' -t ' . escapeshellarg($this->path) . ' ' .
' -t ' . escapeshellarg($this->path ?? '') . ' ' .
escapeshellarg($base . '/server-handler.php');

if (!empty($options['bootstrapFile'])) {
$command = "SERVE_BOOTSTRAP_FILE=" . escapeshellarg($options['bootstrapFile']) . " $command";
$command = "SERVE_BOOTSTRAP_FILE=" . escapeshellarg($options['bootstrapFile'] ?? '') . " $command";
}

$server = new Server($command, $host, $port);
Expand Down
2 changes: 1 addition & 1 deletion code/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Detect BASE_PATH with public-folder awareness
define(
'BASE_PATH',
basename(getcwd()) === 'public'
basename(getcwd() ?? '') === 'public'
? dirname(getcwd())
: getcwd()
);
2 changes: 1 addition & 1 deletion code/server-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH) ?? ''
);

if ($uri !== "/" && file_exists(PUBLIC_PATH . $uri) && !is_dir(PUBLIC_PATH . $uri)) {
Expand Down

0 comments on commit ec91eff

Please sign in to comment.