Skip to content

Commit a8bac58

Browse files
authored
Merge pull request #97 from jfcherng/fix-deprecation-curly-braces
Fix PHP 7.4 deprecation: array/string curly braces access
2 parents 9870277 + 49af2f4 commit a8bac58

25 files changed

+55
-55
lines changed

OS/Guess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function _detectGlibcVersion()
253253
fclose($fp);
254254
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
255255
while ($line = fgets($cpp, 1024)) {
256-
if ($line{0} == '#' || trim($line) == '') {
256+
if ($line[0] == '#' || trim($line) == '') {
257257
continue;
258258
}
259259

PEAR/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function _harvestInstDir($dest_prefix, $dirname, &$built_files)
246246

247247
$ret = true;
248248
while (($ent = readdir($d)) !== false) {
249-
if ($ent{0} == '.')
249+
if ($ent[0] == '.')
250250
continue;
251251

252252
$full = $dirname . DIRECTORY_SEPARATOR . $ent;

PEAR/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public static function registerCommands($merge = false, $dir = null)
233233
}
234234

235235
while ($file = readdir($dp)) {
236-
if ($file{0} == '.' || substr($file, -4) != '.xml') {
236+
if ($file[0] == '.' || substr($file, -4) != '.xml') {
237237
continue;
238238
}
239239

PEAR/Command/Channels.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ function doAlias($command, $options, $params)
673673
return $this->raiseError('No channel alias specified');
674674
}
675675

676-
if (count($params) !== 2 || (!empty($params[1]) && $params[1]{0} == '-')) {
676+
if (count($params) !== 2 || (!empty($params[1]) && $params[1][0] == '-')) {
677677
return $this->raiseError(
678678
'Invalid format, correct is: channel-alias channel alias');
679679
}

PEAR/Command/Common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function getGetoptArgs($command, &$short_args, &$long_args)
146146
foreach ($this->commands[$command]['options'] as $option => $info) {
147147
$larg = $sarg = '';
148148
if (isset($info['arg'])) {
149-
if ($info['arg']{0} == '(') {
149+
if ($info['arg'][0] == '(') {
150150
$larg = '==';
151151
$sarg = '::';
152152
$arg = substr($info['arg'], 1, -1);

PEAR/Command/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ function doConfigCreate($command, $options, $params)
315315
$root = preg_replace(array('!\\\\+!', '!/+!', "!$ds2+!"),
316316
array('/', '/', '/'),
317317
$root);
318-
if ($root{0} != '/') {
318+
if ($root[0] != '/') {
319319
if (!isset($options['windows'])) {
320320
return PEAR::raiseError('Root directory must be an absolute path beginning ' .
321321
'with "/", was: "' . $root . '"');
@@ -338,7 +338,7 @@ function doConfigCreate($command, $options, $params)
338338

339339
$params[1] = realpath($params[1]);
340340
$config = new PEAR_Config($params[1], '#no#system#config#', false, false);
341-
if ($root{strlen($root) - 1} == '/') {
341+
if ($root[strlen($root) - 1] == '/') {
342342
$root = substr($root, 0, strlen($root) - 1);
343343
}
344344

PEAR/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ function buildProvidesArray($srcinfo)
686686
foreach ($methods as $method) {
687687
$function = "$class::$method";
688688
$key = "function;$function";
689-
if ($method{0} == '_' || !strcasecmp($method, $class) ||
689+
if ($method[0] == '_' || !strcasecmp($method, $class) ||
690690
isset($this->pkginfo['provides'][$key])) {
691691
continue;
692692
}
@@ -698,7 +698,7 @@ function buildProvidesArray($srcinfo)
698698

699699
foreach ($srcinfo['declared_functions'] as $function) {
700700
$key = "function;$function";
701-
if ($function{0} == '_' || isset($this->pkginfo['provides'][$key])) {
701+
if ($function[0] == '_' || isset($this->pkginfo['provides'][$key])) {
702702
continue;
703703
}
704704

PEAR/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ static function _prependPath($path, $prepend)
20922092
if (OS_WINDOWS && preg_match('/^[a-z]:/i', $path)) {
20932093
if (preg_match('/^[a-z]:/i', $prepend)) {
20942094
$prepend = substr($prepend, 2);
2095-
} elseif ($prepend{0} != '\\') {
2095+
} elseif ($prepend[0] != '\\') {
20962096
$prepend = "\\$prepend";
20972097
}
20982098
$path = substr($path, 0, 2) . $prepend . substr($path, 2);

PEAR/DependencyDB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function assertDepsDB()
174174
$this->rebuildDB();
175175
}
176176

177-
if ($depdb['_version']{0} > $this->_version{0}) {
177+
if ($depdb['_version'][0] > $this->_version[0]) {
178178
return PEAR::raiseError('Dependency database is version ' .
179179
$depdb['_version'] . ', and we are version ' .
180180
$this->_version . ', cannot continue');

PEAR/Downloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ function _prependPath($path, $prepend)
11571157
if (OS_WINDOWS && preg_match('/^[a-z]:/i', $path)) {
11581158
if (preg_match('/^[a-z]:/i', $prepend)) {
11591159
$prepend = substr($prepend, 2);
1160-
} elseif ($prepend{0} != '\\') {
1160+
} elseif ($prepend[0] != '\\') {
11611161
$prepend = "\\$prepend";
11621162
}
11631163
$path = substr($path, 0, 2) . $prepend . substr($path, 2);

PEAR/Installer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function _installFile($file, $atts, $tmp_path, $options)
225225
$os = new OS_Guess();
226226
}
227227

228-
if (strlen($atts['platform']) && $atts['platform']{0} == '!') {
228+
if (strlen($atts['platform']) && $atts['platform'][0] == '!') {
229229
$negate = true;
230230
$platform = substr($atts['platform'], 1);
231231
} else {

PEAR/Installer/Role.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public static function registerRoles($dir = null)
237237
}
238238

239239
while ($entry = readdir($dp)) {
240-
if ($entry{0} == '.' || substr($entry, -4) != '.xml') {
240+
if ($entry[0] == '.' || substr($entry, -4) != '.xml') {
241241
continue;
242242
}
243243

PEAR/PackageFile.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ function setLogger(&$l)
9494
*/
9595
function &parserFactory($version)
9696
{
97-
if (!in_array($version{0}, array('1', '2'))) {
97+
if (!in_array($version[0], array('1', '2'))) {
9898
$a = false;
9999
return $a;
100100
}
101101

102-
include_once 'PEAR/PackageFile/Parser/v' . $version{0} . '.php';
103-
$version = $version{0};
102+
include_once 'PEAR/PackageFile/Parser/v' . $version[0] . '.php';
103+
$version = $version[0];
104104
$class = "PEAR_PackageFile_Parser_v$version";
105105
$a = new $class;
106106
return $a;
@@ -122,13 +122,13 @@ function getClassPrefix()
122122
*/
123123
function &factory($version)
124124
{
125-
if (!in_array($version{0}, array('1', '2'))) {
125+
if (!in_array($version[0], array('1', '2'))) {
126126
$a = false;
127127
return $a;
128128
}
129129

130-
include_once 'PEAR/PackageFile/v' . $version{0} . '.php';
131-
$version = $version{0};
130+
include_once 'PEAR/PackageFile/v' . $version[0] . '.php';
131+
$version = $version[0];
132132
$class = $this->getClassPrefix() . $version;
133133
$a = new $class;
134134
return $a;

PEAR/PackageFile/Generator/v1.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,13 +889,13 @@ function _convertRelease2_0(&$release, $package)
889889
}
890890
//o <install as=..> tags for <file name=... platform=!... install-as=..>
891891
if (isset($package['platform'][$file]) &&
892-
$package['platform'][$file]{0} == '!') {
892+
$package['platform'][$file][0] == '!') {
893893
$generic[] = $file;
894894
continue;
895895
}
896896
//o <ignore> tags for <file name=... platform=... install-as=..>
897897
if (isset($package['platform'][$file]) &&
898-
$package['platform'][$file]{0} != '!') {
898+
$package['platform'][$file][0] != '!') {
899899
$genericIgnore[] = $file;
900900
continue;
901901
}
@@ -904,7 +904,7 @@ function _convertRelease2_0(&$release, $package)
904904
if (isset($package['install-as'][$file])) {
905905
continue;
906906
}
907-
if ($platform{0} != '!') {
907+
if ($platform[0] != '!') {
908908
//o <ignore> tags for <file name=... platform=...>
909909
$genericIgnore[] = $file;
910910
}
@@ -913,7 +913,7 @@ function _convertRelease2_0(&$release, $package)
913913
$oses = $notplatform = $platform = array();
914914
foreach ($package['platform'] as $file => $os) {
915915
// get a list of oses
916-
if ($os{0} == '!') {
916+
if ($os[0] == '!') {
917917
if (isset($oses[substr($os, 1)])) {
918918
continue;
919919
}
@@ -959,7 +959,7 @@ function _convertRelease2_0(&$release, $package)
959959
// <file name=... platform=!other platform install-as=..>
960960
if (isset($package['platform'][$file]) &&
961961
$package['platform'][$file] != "!$os" &&
962-
$package['platform'][$file]{0} == '!') {
962+
$package['platform'][$file][0] == '!') {
963963
$release[$releaseNum]['filelist']['install'][] =
964964
array(
965965
'attribs' => array(
@@ -984,7 +984,7 @@ function _convertRelease2_0(&$release, $package)
984984
//o <ignore> tags for
985985
// <file name=... platform=other platform install-as=..>
986986
if (isset($package['platform'][$file]) &&
987-
$package['platform'][$file]{0} != '!' &&
987+
$package['platform'][$file][0] != '!' &&
988988
$package['platform'][$file] != $os) {
989989
$release[$releaseNum]['filelist']['ignore'][] =
990990
array(
@@ -1010,7 +1010,7 @@ function _convertRelease2_0(&$release, $package)
10101010
continue;
10111011
}
10121012
//o <ignore> tags for <file name=... platform=other platform>
1013-
if ($platform{0} != '!' && $platform != $os) {
1013+
if ($platform[0] != '!' && $platform != $os) {
10141014
$release[$releaseNum]['filelist']['ignore'][] =
10151015
array(
10161016
'attribs' => array(

PEAR/PackageFile/Generator/v2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ function _serializeArray(&$array, $tagName = null, $attributes = array())
781781
}
782782
}
783783

784-
if (is_string($value) && $value && ($value{strlen($value) - 1} == "\n")) {
784+
if (is_string($value) && $value && ($value[strlen($value) - 1] == "\n")) {
785785
$value .= str_repeat($this->options['indent'], $this->_tagDepth);
786786
}
787787
$tmp .= $this->_createXMLTag(array(

PEAR/PackageFile/v1.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ function _buildProvidesArray($srcinfo)
15751575
foreach ($methods as $method) {
15761576
$function = "$class::$method";
15771577
$key = "function;$function";
1578-
if ($method{0} == '_' || !strcasecmp($method, $class) ||
1578+
if ($method[0] == '_' || !strcasecmp($method, $class) ||
15791579
isset($this->_packageInfo['provides'][$key])) {
15801580
continue;
15811581
}
@@ -1586,7 +1586,7 @@ function _buildProvidesArray($srcinfo)
15861586

15871587
foreach ($srcinfo['declared_functions'] as $function) {
15881588
$key = "function;$function";
1589-
if ($function{0} == '_' || isset($this->_packageInfo['provides'][$key])) {
1589+
if ($function[0] == '_' || isset($this->_packageInfo['provides'][$key])) {
15901590
continue;
15911591
}
15921592
if (!strstr($function, '::') && strncasecmp($function, $pn, $pnl)) {

PEAR/PackageFile/v2/Validator.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,15 @@ function _processAttribs($choice, $tag, $context)
419419
foreach ($tags as $i => $tag) {
420420
if (!is_array($tag) || !isset($tag['attribs'])) {
421421
foreach ($choice['attribs'] as $attrib) {
422-
if ($attrib{0} != '?') {
422+
if ($attrib[0] != '?') {
423423
$ret &= $this->_tagHasNoAttribs($choice['tag'],
424424
$context);
425425
continue 2;
426426
}
427427
}
428428
}
429429
foreach ($choice['attribs'] as $attrib) {
430-
if ($attrib{0} != '?') {
430+
if ($attrib[0] != '?') {
431431
if (!isset($tag['attribs'][$attrib])) {
432432
$ret &= $this->_tagMissingAttribute($choice['tag'],
433433
$attrib, $context);
@@ -450,9 +450,9 @@ function _processStructure($key)
450450
}
451451
return $ret;
452452
}
453-
$multi = $key{0};
453+
$multi = $key[0];
454454
if ($multi == '+' || $multi == '*') {
455-
$ret['multiple'] = $key{0};
455+
$ret['multiple'] = $key[0];
456456
$key = substr($key, 1);
457457
}
458458
if (count($attrs = explode('->', $key)) > 1) {
@@ -1080,8 +1080,8 @@ function _validateFilelist($list = false, $allowignore = false, $dirs = '')
10801080
foreach ($list['file'] as $i => $file)
10811081
{
10821082
if (isset($file['attribs']) && isset($file['attribs']['name'])) {
1083-
if ($file['attribs']['name']{0} == '.' &&
1084-
$file['attribs']['name']{1} == '/') {
1083+
if ($file['attribs']['name'][0] == '.' &&
1084+
$file['attribs']['name'][1] == '/') {
10851085
// name is something like "./doc/whatever.txt"
10861086
$this->_invalidFileName($file['attribs']['name'], $dirname);
10871087
}
@@ -2106,7 +2106,7 @@ function _buildProvidesArray($srcinfo)
21062106
foreach ($methods as $method) {
21072107
$function = "$class::$method";
21082108
$key = "function;$function";
2109-
if ($method{0} == '_' || !strcasecmp($method, $class) ||
2109+
if ($method[0] == '_' || !strcasecmp($method, $class) ||
21102110
isset($providesret[$key])) {
21112111
continue;
21122112
}
@@ -2118,7 +2118,7 @@ function _buildProvidesArray($srcinfo)
21182118

21192119
foreach ($srcinfo['declared_functions'] as $function) {
21202120
$key = "function;$function";
2121-
if ($function{0} == '_' || isset($providesret[$key])) {
2121+
if ($function[0] == '_' || isset($providesret[$key])) {
21222122
continue;
21232123
}
21242124

PEAR/Registry.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ function _listChannels()
11871187

11881188
$dp = opendir($this->channelsdir);
11891189
while ($ent = readdir($dp)) {
1190-
if ($ent{0} == '.' || substr($ent, -4) != '.reg') {
1190+
if ($ent[0] == '.' || substr($ent, -4) != '.reg') {
11911191
continue;
11921192
}
11931193

@@ -1238,7 +1238,7 @@ function _listPackages($channel = false)
12381238
}
12391239

12401240
while ($ent = readdir($dp)) {
1241-
if ($ent{0} == '.' || substr($ent, -4) != '.reg') {
1241+
if ($ent[0] == '.' || substr($ent, -4) != '.reg') {
12421242
continue;
12431243
}
12441244

@@ -1262,7 +1262,7 @@ function _listChannelPackages($channel)
12621262
}
12631263

12641264
while ($ent = readdir($dp)) {
1265-
if ($ent{0} == '.' || substr($ent, -4) != '.reg') {
1265+
if ($ent[0] == '.' || substr($ent, -4) != '.reg') {
12661266
continue;
12671267
}
12681268
$pkglist[] = substr($ent, 0, -4);
@@ -2204,7 +2204,7 @@ function parsePackageName($param, $defaultchannel = 'pear.php.net')
22042204
}
22052205
if (!isset($components['scheme'])) {
22062206
if (strpos($components['path'], '/') !== false) {
2207-
if ($components['path']{0} == '/') {
2207+
if ($components['path'][0] == '/') {
22082208
return PEAR::raiseError('parsePackageName(): this is not ' .
22092209
'a package name, it begins with "/" in "' . $param . '"',
22102210
'invalid', null, null, $param);

PEAR/Start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function locatePackagesToInstall()
215215

216216
$potentials = array();
217217
while (false !== ($entry = readdir($dp))) {
218-
if ($entry{0} == '.' || !in_array(substr($entry, -4), array('.tar', '.tgz'))) {
218+
if ($entry[0] == '.' || !in_array(substr($entry, -4), array('.tar', '.tgz'))) {
219219
continue;
220220
}
221221
$potentials[] = $entry;

PEAR/Start/CLI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ function which($program, $dont_search_in = false)
445445
if (!strlen($dir)) {
446446
continue;
447447
}
448-
if ($dir{strlen($dir) - 1} != '\\') {
448+
if ($dir[strlen($dir) - 1] != '\\') {
449449
$dir .= '\\';
450450
}
451451
$tmp = $dir . $program;

0 commit comments

Comments
 (0)