summaryrefslogtreecommitdiffstats
path: root/4.patch
blob: c8a8a316ea83e002bb8aca4fcc5670bb0626b3d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From f37ba4a4f42a1f1173fe7de28fb9b71a54c2ff63 Mon Sep 17 00:00:00 2001
From: Jack Cherng <jfcherng@gmail.com>
Date: Wed, 7 Aug 2019 07:32:38 +0800
Subject: [PATCH] Fix PHP 7.4 deprecation: array/string curly braces access

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
---
 Console/Getopt.php | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/Console/Getopt.php b/Console/Getopt.php
index f8df71c..29f86bb 100644
--- a/Console/Getopt.php
+++ b/Console/Getopt.php
@@ -138,10 +138,10 @@ public static function doGetopt($version, $args, $short_options, $long_options =
                 break;
             }
 
-            if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
+            if ($arg[0] != '-' || (strlen($arg) > 1 && $arg[1] == '-' && !$long_options)) {
                 $non_opts = array_merge($non_opts, array_slice($args, $i));
                 break;
-            } elseif (strlen($arg) > 1 && $arg{1} == '-') {
+            } elseif (strlen($arg) > 1 && $arg[1] == '-') {
                 $error = Console_Getopt::_parseLongOption(substr($arg, 2),
                                                           $long_options,
                                                           $opts,
@@ -186,11 +186,11 @@ public static function doGetopt($version, $args, $short_options, $long_options =
     protected static function _parseShortOption($arg, $short_options, &$opts, &$argIdx, $args, $skip_unknown)
     {
         for ($i = 0; $i < strlen($arg); $i++) {
-            $opt     = $arg{$i};
+            $opt     = $arg[$i];
             $opt_arg = null;
 
             /* Try to find the short option in the specifier string. */
-            if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':') {
+            if (($spec = strstr($short_options, $opt)) === false || $arg[$i] == ':') {
                 if ($skip_unknown === true) {
                     break;
                 }
@@ -199,8 +199,8 @@ protected static function _parseShortOption($arg, $short_options, &$opts, &$argI
                 return PEAR::raiseError($msg);
             }
 
-            if (strlen($spec) > 1 && $spec{1} == ':') {
-                if (strlen($spec) > 2 && $spec{2} == ':') {
+            if (strlen($spec) > 1 && $spec[1] == ':') {
+                if (strlen($spec) > 2 && $spec[2] == ':') {
                     if ($i + 1 < strlen($arg)) {
                         /* Option takes an optional argument. Use the remainder of
                            the arg string if there is anything left. */
@@ -296,11 +296,11 @@ protected static function _parseLongOption($arg, $long_options, &$opts, &$argIdx
                 $next_option_rest = '';
             }
 
-            if ($opt_rest != '' && $opt{0} != '=' &&
+            if ($opt_rest != '' && $opt[0] != '=' &&
                 $i + 1 < count($long_options) &&
                 $opt == substr($long_options[$i+1], 0, $opt_len) &&
                 $next_option_rest != '' &&
-                $next_option_rest{0} != '=') {
+                $next_option_rest[0] != '=') {
 
                 $msg = "Console_Getopt: option --$opt is ambiguous";
                 return PEAR::raiseError($msg);