From: Michael Wallner Date: Sat, 26 Sep 2020 06:56:16 +0000 (+0200) Subject: PHP 8 compatibility (curly brace string access) X-Git-Tag: v4.1.3~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=d86a65973ac3cd8647354274ab9af6ce8c8257fc;p=pharext%2Fpharext PHP 8 compatibility (curly brace string access) --- diff --git a/src/pharext/Cli/Args.php b/src/pharext/Cli/Args.php index 7334290..ef46e88 100644 --- a/src/pharext/Cli/Args.php +++ b/src/pharext/Cli/Args.php @@ -128,14 +128,14 @@ class Args implements \ArrayAccess for ($f = false, $p = 0, $i = 0; $i < $argc; ++$i) { $o = $argv[$i]; - if ($o{0} === "-" && strlen($o) > 2 && $o{1} !== "-") { + if ($o[0] === "-" && strlen($o) > 2 && $o[1] !== "-") { // multiple short opts, e.g. -vps $argc += strlen($o) - 2; array_splice($argv, $i, 1, array_map(function($s) { return "-$s"; }, str_split(substr($o, 1)))); $o = $argv[$i]; - } elseif ($o{0} === "-" && strlen($o) > 2 && $o{1} === "-" && 0 < ($eq = strpos($o, "="))) { + } elseif ($o[0] === "-" && strlen($o) > 2 && $o[1] === "-" && 0 < ($eq = strpos($o, "="))) { // long opt with argument, e.g. --foo=bar $argc++; array_splice($argv, $i, 1, [ @@ -150,7 +150,7 @@ class Args implements \ArrayAccess } if ($f || !isset($this->spec[$o])) { - if ($o{0} !== "-" && isset($this->spec["--$p"])) { + if ($o[0] !== "-" && isset($this->spec["--$p"])) { $this[$p] = $o; if (!$this->optIsMulti($p)) { ++$p; @@ -316,7 +316,7 @@ class Args implements \ArrayAccess if (is_numeric($o)) { return "--$o"; } - if ($o{0} !== '-') { + if ($o[0] !== '-') { if (strlen($o) > 1) { $o = "-$o"; } diff --git a/src/pharext/Installer.php b/src/pharext/Installer.php index d6b3c67..7cbe5e9 100644 --- a/src/pharext/Installer.php +++ b/src/pharext/Installer.php @@ -220,7 +220,7 @@ class Installer implements Command $sudo = isset($this->args->sudo) ? $this->args->sudo : null; $type = $this->metadata("type") ?: "extension"; - $activate = new Task\Activate($temp, $files, $type, $this->args->prefix, $this->args{"common-name"}, $sudo); + $activate = new Task\Activate($temp, $files, $type, $this->args->prefix, $this->args["common-name"], $sudo); if (!$activate->run($this->verbosity())) { $this->info("Extension already activated ...\n"); } diff --git a/src/pharext/License.php b/src/pharext/License.php index 0f339fd..a9c19b7 100644 --- a/src/pharext/License.php +++ b/src/pharext/License.php @@ -29,10 +29,10 @@ trait License $pattern = ""; $length = strlen($upper); for ($i = 0; $i < $length; ++$i) { - if ($lower{$i} === $upper{$i}) { - $pattern .= $upper{$i}; + if ($lower[$i] === $upper[$i]) { + $pattern .= $upper[$i]; } else { - $pattern .= "[" . $upper{$i} . $lower{$i} . "]"; + $pattern .= "[" . $upper[$i] . $lower[$i] . "]"; } } return $pattern;