postnl/postnl-magento1-End-of-life

PHP 7 incompatibilities in TIG_PostNL_Model_Core_System_Config_Backend_ValidateDefaultOption

Closed this issue · 2 comments

There are three PHP 7 incompatibilities on line line 99 of app/code/community/TIG/PostNL/Model/Core/System/Config/Backend/ValidateDefaultOption.php, caused by the introduction of the uniform variable syntax in PHP 7.0.

The line reads as follows:

$label = (string) $sections->$pathParts[0]->groups->$pathParts[1]->fields->$pathParts[2]->label;

In PHP 5.6 this line is interpreted as follows:

$label = (string) $sections->{$pathParts[0]}->groups->{$pathParts[1]}->fields->{$pathParts[2]}->label;

In PHP 7 indirect access to variables, properties, and methods are evaluated strictly in left-to-right order, which means that the line is interpreted as follows:

$label = (string) ((($sections->$pathParts)[0]->groups->$pathParts)[1]->fields->$pathParts)[2]->label;

This issue can be found using PHP compatiblity tools like php7cc or the PHP Compatibility Coding Standard for PHPCS.

Hi @aadmathijssen,

Thanks a lot for pointing this out. I've created a backlog item for this issue. You can follow the issue on https://jira.tig.nl/browse/POSTNLM1-523.

After reading your issue we decided that we will investigate if it is possible to include php7cc in our Travis checks for our projects, including PostNL Magento 1.

As stated in the pull request of aadmathijssen, we have merged the pull request in our private branch. This got included in version v1.15.3.