Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 7.4 deprecation: array/string curly braces access #97

Merged
merged 2 commits into from
Oct 18, 2019
Merged

Fix PHP 7.4 deprecation: array/string curly braces access #97

merged 2 commits into from
Oct 18, 2019

Conversation

jfcherng
Copy link
Contributor

@jfcherng jfcherng commented Aug 6, 2019

Deprecated: Array and string offset access syntax with curly braces is deprecated

Hopefully these are all (or most) of them:

[Clover@Clover-NB pear-core](fix-deprecation-curly-braces)$ rg -tphp "(\\$|->|::)[A-Za-z0-9_]+\{"
make-gopear-phar.php:43:    if ($entry{0} == '.' || !in_array(substr($entry, -4), array('.tar'))) {
make-installpear-nozlib-phar.php:43:    if ($entry{0} == '.' || !in_array(substr($entry, -4), array('.tar'))) {
make-pear-bundle.php:34:                        $checksum += ord($hdr_data{$i});
make-pear-bundle.php:38:                        $checksum += ord($hdr_data{$i});
System.php:77:                if ($b{0} == '"' || $b{0} == "'") {
OS\Guess.php:256:                if ($line{0} == '#' || trim($line) == '') {
PEAR\Builder.php:194:            if ($ent{0} == '.')
PEAR\Command.php:236:            if ($file{0} == '.' || substr($file, -4) != '.xml') {
PEAR\Common.php:689:                if ($method{0} == '_' || !strcasecmp($method, $class) ||
PEAR\Common.php:701:            if ($function{0} == '_' || isset($this->pkginfo['provides'][$key])) {
PEAR\Config.php:2095:                } elseif ($prepend{0} != '\\') {
PEAR\PackageFile.php:97:        if (!in_array($version{0}, array('1', '2'))) {
PEAR\PackageFile.php:102:        include_once 'PEAR/PackageFile/Parser/v' . $version{0} . '.php';
PEAR\PackageFile.php:103:        $version = $version{0};
PEAR\PackageFile.php:125:        if (!in_array($version{0}, array('1', '2'))) {
PEAR\PackageFile.php:130:        include_once 'PEAR/PackageFile/v' . $version{0} . '.php';
PEAR\PackageFile.php:131:        $version = $version{0};
PEAR\Downloader.php:1159:                } elseif ($prepend{0} != '\\') {
PEAR\Validate.php:212:                while ($majver && !is_numeric($majver{0})) {
PEAR\Validate.php:331:                    while ($majver && !is_numeric($majver{0})) {
PEAR\Validate.php:401:                    while ($majver && !is_numeric($majver{0})) {
PEAR\DependencyDB.php:177:        if ($depdb['_version']{0} > $this->_version{0}) {
PEAR\Start.php:218:            if ($entry{0} == '.' || !in_array(substr($entry, -4), array('.tar', '.tgz'))) {
PEAR\Command\Config.php:318:        if ($root{0} != '/') {
PEAR\Command\Config.php:341:        if ($root{strlen($root) - 1} == '/') {
PEAR\Registry.php:1190:            if ($ent{0} == '.' || substr($ent, -4) != '.reg') {
PEAR\Registry.php:1241:            if ($ent{0} == '.' || substr($ent, -4) != '.reg') {
PEAR\Registry.php:1265:            if ($ent{0} == '.' || substr($ent, -4) != '.reg') {
PEAR\Installer\Role.php:240:            if ($entry{0} == '.' || substr($entry, -4) != '.xml') {
PEAR\PackageFile\v1.php:1578:                if ($method{0} == '_' || !strcasecmp($method, $class) ||
PEAR\PackageFile\v1.php:1589:            if ($function{0} == '_' || isset($this->_packageInfo['provides'][$key])) {
PEAR\Start\CLI.php:448:                if ($dir{strlen($dir) - 1} != '\\') {
PEAR\PackageFile\Generator\v2.php:784:                if (is_string($value) && $value && ($value{strlen($value) - 1} == "\n")) {
PEAR\PackageFile\Generator\v1.php:907:                if ($platform{0} != '!') {
PEAR\PackageFile\Generator\v1.php:916:                    if ($os{0} == '!') {
PEAR\PackageFile\Generator\v1.php:1013:                        if ($platform{0} != '!' && $platform != $os) {
PEAR\PackageFile\v2\Validator.php:422:                        if ($attrib{0} != '?') {
PEAR\PackageFile\v2\Validator.php:430:                    if ($attrib{0} != '?') {
PEAR\PackageFile\v2\Validator.php:453:        $multi = $key{0};
PEAR\PackageFile\v2\Validator.php:455:            $ret['multiple'] = $key{0};
PEAR\PackageFile\v2\Validator.php:2109:                if ($method{0} == '_' || !strcasecmp($method, $class) ||
PEAR\PackageFile\v2\Validator.php:2121:            if ($function{0} == '_' || isset($providesret[$key])) {

https://github.com/php/php-src/blob/0e6e2297fcb27103cc5d550ee8434680ff1e879e/UPGRADING#L356-L357


UPDATE: 20190904 - Add more fixes.

[Clover@Clover-NB pear-core](fix-deprecation-curly-braces)$ rg -tphp "(\])\{"
System.php:268:                if (strlen($opt[1]) && $opt[1]{0} == '0') {
PEAR\DependencyDB.php:177:        if ($depdb['_version']{0} > $this->_version[0]) {
[SKIP] PEAR\Downloader.php:1667:            } elseif (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) {
PEAR\Installer.php:228:            if (strlen($atts['platform']) && $atts['platform']{0} == '!') {
[SKIP] PEAR\Proxy.php:77:            if (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) {
PEAR\Registry.php:2207:                    if ($components['path']{0} == '/') {
[SKIP] PEAR\REST.php:424:            } elseif (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) {
PEAR\Command\Channels.php:676:        if (count($params) !== 2 || (!empty($params[1]) && $params[1]{0} == '-')) {
PEAR\Command\Common.php:149:                if ($info['arg']{0} == '(') {
PEAR\Validate.php:290:                        if ($versioncomponents[2]{0} == '0') {
PEAR\Validate.php:342:                        if ($versioncomponents[2]{0} == '0') {
PEAR\PackageFile\Generator\v1.php:892:                      $package['platform'][$file]{0} == '!') {
PEAR\PackageFile\Generator\v1.php:898:                      $package['platform'][$file]{0} != '!') {
PEAR\PackageFile\Generator\v1.php:962:                              $package['platform'][$file]{0} == '!') {
PEAR\PackageFile\Generator\v1.php:987:                              $package['platform'][$file]{0} != '!' &&
PEAR\PackageFile\v2\Validator.php:1083:                    if ($file['attribs']['name']{0} == '.' &&
PEAR\PackageFile\v2\Validator.php:1084:                          $file['attribs']['name']{1} == '/') {

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
@nikic
Copy link
Contributor

nikic commented Aug 27, 2019

For reference, the sister PR on Console_Getopt that is also needed: pear/Console_Getopt#4

@sanmai
Copy link
Member

sanmai commented Sep 4, 2019

I wonder if you could add 7.4snapshot to the build matrix so we can all see that that's it.

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
@sanmai
Copy link
Member

sanmai commented Sep 5, 2019

Also consider integrating #99, just for the time being, and a green checkmark.

@sanmai sanmai mentioned this pull request Sep 6, 2019
3 tasks
@CloCkWeRX CloCkWeRX closed this Oct 18, 2019
@CloCkWeRX CloCkWeRX reopened this Oct 18, 2019
@CloCkWeRX CloCkWeRX merged commit a8bac58 into pear:master Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants