magento-ecg / coding-standard

Magento PHP_CodeSniffer Coding Standard
MIT License
308 stars 99 forks source link

Replace direct array dereferences (not possible for PHP < 5.4) #1

Closed vianetz closed 11 years ago

vianetz commented 11 years ago

Hi,

the direct array dereference (e.g. $phpcs->getTokens()[$next]['content']) is only possible from PHP 5.4 up and should be replaced with temporary variables for lower PHP versions. (Source: http://php.net/manual/en/language.types.array.php#example-88)

Best regards, Chris

zlik commented 11 years ago

Hi Chris,

Thanks for opening this issue. As follows from the announce on PHP official website (http://php.net/archive/2013.php#id2013-07-11-1), all users of PHP are encouraged to upgrade to PHP 5.4 or PHP 5.5 as the older versions will be no longer supported (except security bugfixes). As developers we try to be proactive and promote newer versions of PHP (5.4, 5.5) which enable you to write simpler and safer code. And we love these new beautiful PHP features like array dereferencing, traits, generators and so on.

I specified the minimum required PHP version in the requirements section of the readme file.

Best regards, Alex Zarichnyi

vianetz commented 11 years ago

Hi Alex,

thanks for your fast reply.

You're totally right, I was just too lazy to upgrade yet ;-)

Have a nice day, Chris