-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentRelease Line: 2.1bug reportbugfix
Description
Preconditions
- Install latest Magento 2.x (tested on 2.0.x and 2.1.x) - PHP 5.6 or PHP 7.0
- Any custom module with interface defined
Steps to reproduce
- Create module and define Interface with __construct method
- Run
php bin/magento setup:di:compile
Expected result
- Compilation should complete 100% as PHP allows interface to have constructor - I'm not saying it should have, but it can as language allows it - so compiler should honor that
Actual result
- Error:
PHP Notice: Trying to get property of non-object in /var/www/html/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php on line 30
Problem is here
if (!$class->getFileName() || false == $class->hasMethod( |
If class hasn't got '__construct' method it will be skipped, but if method exist
$class->getConstructor()
will return NULL
and
$class->getConstructor()->class
obviously will generate fatal error
Simplest fix
if (!$class->getFileName() || false == $class->hasMethod(
'__construct'
) || !$inherited && null !== $class->getConstructor() && $class->getConstructor()->class != $class->getName()
) {
return $output;
}
Metadata
Metadata
Assignees
Labels
Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentRelease Line: 2.1bug reportbugfix