-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
This report addresses an issue that has been talked about before, but has not yet received a solution that would be viable in the long run as the focus has been mostly on making sure that Magento2 code does not use certain PHP7 features rather than making Framework fully capable of supporting all that PHP7 has to offer.
Therefore the description has been written in a form where existing code is manipulated with to make sure that there's no way to perceive this as a issue that deserves a solution of removing the appearance of the problem (which is fine as an isolated containment of the issue but I would humbly advise against closing the ticket based on said containment).
Same issue reported in different scenarios in:
This issue created on purpose to have an open issue on this topic as all that were previously reported have since been closed (with "fixed" flag).
Environment
- OS: Ubuntu 18.04.2 LTS (Bionic Beaver)
Preconditions
- Use any Magento release (report based on 2.3.2, which at the time of reporting was the latest release), sample data not needed.
- All generated files are removed (
rm -rf generated
) - Application deploy mode is on 'developer' (
bin/magento deploy:mode:set developer
)
Steps to reproduce
-
[terminal] modify Magento\Framework\HTTP\PhpEnvironment\Response :: setHeader method by adding a 'self' return type to it:
sed -i 's/\(ion setHeader(.*\)/\1: self/g' vendor/magento/framework/HTTP/PhpEnvironment/Response.php
-
[browser] navigate to the home page/main page of the store.
Expected result
- Page loads without any issues
- Looking at generated Interceptor class, one should see:
public function setHeader($name, $value, $replace = false) :
\Magento\Framework\HTTP\PhpEnvironment\Response
Actual result
- Page load crashes with fatal error:
Fatal error: Declaration of Magento\Framework\App\Response\Http\Interceptor
::setHeader($name, $value, $replace = false): Magento\Framework\App\Response\Http
must be compatible with Magento\Framework\HTTP\PhpEnvironment\Response
::setHeader($name, $value, $replace = false): Magento\Framework\HTTP\PhpEnvironment\Response
in ../generated/code/Magento/Framework/App/Response/Http/Interceptor.php on line 7
- Interceptor reads:
public function setHeader($name, $value, $replace = false) :
\Magento\Framework\App\Response\Http