magento2: Magento 2.2.0 does not support nullable return types on PHP 7.0.24
Preconditions
- Magento 2.2.0
- PHP 7.0.24
Steps to reproduce
Checking the system requirements for Magento 2.2.0 on http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements-tech.html#php it shows that PHP 7.0 is supported, however the VarTag.php file under vendor/zendframework/zend-code/src/Reflection/DocBlock/Tag/ contains a few methods which returns nullable return types. Like the methods below:
public function getVariableName() : ?string
{
return $this->variableName;
}
public function getDescription() : ?string
{
return $this->description;
}
The nullable return types are not yet supported on PHP7.0. They were introduced from PHP7.1 on. This means that the actions using the methods above (like the login action) thrown syntax error. Please correct the system requirements.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (14 by maintainers)
@mzeis agree with @orlangur Magento itself should not add platform to the distributed
composer.json. However any developer/agency that is installing and working in a mixed php version environment should add platform to their own copy ofcomposer.jsonto avoid exactly this type of issue.The issue that we do have is that Magento pre-generates a zip download available here https://magento.com/tech-resources/download for Magento 2.2 that makes a determination on behalf of the user and generates under php 7.0. (the zip comes with zend/code 3.1.0)
What Magento should do (if they want to continue offering the zip download) is, at a minimum, use platform 7.0 and 7.1 to create two separate zip downloads (I’ll create a separate issue for this).
@esimov can you confirm if you do have a mixed environment of php versions or if you are already using platform or ignore platform reqs? I did an upgrade from 2.1.9 to 2.2.0 via composer on php 7.0 and ended up with the right version:
@orlangur also tested the following on 7.1
seems something is missing from @ytorbyk steps.
Just to copy from the other thread, i believe that if you run PHP7.1 CLI version for composer, and run PHP 7.0 on PHP-FPM, the Magento should warn administrator that something is broken, because users may get unexpected blank screens on unknown places (everywhere where php 7.1 specifi code is used) when php get parse error…
I also agree that if you install using cli 7.1, fpm should be 7.1+, but if webmaster do not notice or forget to update php on webserver, he should get notified somehow…
Strange that it wasn’t revealed by integration tests. Is this code actually used in Magento 2? Could you provide some scenario?
Looks like
3.1.0release ofZend_Codedidn’t support PHP 7.1: https://github.com/zendframework/zend-code/blob/release-3.1.0/composer.json#L16 While3.2.0release does not support PHP 7.0: https://github.com/zendframework/zend-code/blob/release-3.2.0/composer.json#L16Thus there are only two options for Magento 2 to solve the problem directly:
Indirect solution is to fully cover all code which relies on
Zend_Codewith integration tests so that PHP 7.0 workability is preserved.