PHP 8 compatibility (curly brace string access)
authorMichael Wallner <mike@php.net>
Sat, 26 Sep 2020 06:56:16 +0000 (08:56 +0200)
committerMichael Wallner <mike@php.net>
Sat, 26 Sep 2020 06:56:16 +0000 (08:56 +0200)
src/pharext/Cli/Args.php
src/pharext/Installer.php
src/pharext/License.php

index 7334290f4f070c8b2f5f5474fc619bf6b7a4eb8a..ef46e88a4cb286794da15f70a2069ae2d9768300 100644 (file)
@@ -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";
                        }
index d6b3c671e1f6dc97a61f9e0033225952a985478f..7cbe5e921b99f7854215f05bcb4d2b2464e1f5d5 100644 (file)
@@ -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");
                }
index 0f339fd2728fc77fcac8b4204499f52457bd1bf2..a9c19b70688a92adfdfe3eb4487c82770f8093b7 100644 (file)
@@ -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;