Skip to content

Commit

Permalink
MAGETWO-69019: #8607: Interface constructor if present will break Mag…
Browse files Browse the repository at this point in the history
…ento compilation #9524
  • Loading branch information
Oleksii Korshenko authored May 15, 2017
2 parents 847d23f + 89d43e8 commit 0a8ee90
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ public function getConstructorArguments(\ReflectionClass $class, $groupByPositio
/**
* Skip native PHP types, classes without constructor
*/
if (!$class->getFileName() || false == $class->hasMethod(
'__construct'
) || !$inherited && $class->getConstructor()->class != $class->getName()
if ($class->isInterface() ||
!$class->getFileName() ||
false == $class->hasMethod('__construct') ||
!$inherited &&
$class->getConstructor()->class != $class->getName()
) {
return $output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ public function testGetConstructorArgumentsClassWithoutOwnConstructorInheritedFa
$this->assertEquals([], $actualResult);
}

public function testGetConstructorArgumentsWhenInputTypeIsInterfaceWithParam()
{
$class = new \ReflectionClass('InterfaceTypeWithConstructorMethodAndParams');
$actualResult = $this->_model->getConstructorArguments($class);
$this->assertEquals([], $actualResult);
}

public function testGetConstructorArgumentsWhenInputTypeIsInterfaceWithoutParam()
{
$class = new \ReflectionClass('InterfaceTypeWithConstructorMethodWithoutParams');
$actualResult = $this->_model->getConstructorArguments($class);
$this->assertEquals([], $actualResult);
}

public function testGetConstructorArgumentsClassWithoutOwnConstructorInheritedTrue()
{
$expectedResult = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,21 @@ public function __construct(\stdClass $stdClassObject, \ClassExtendsDefaultPhpTy
$this->argumentTwo = $secondClass;
}
}

interface InterfaceTypeWithConstructorMethodAndParams
{
/**
* We do not expect that this is valid case. There is no need to declare interface with method __construct
*
* @param $paramOne
* @param $paramTwo
*/
public function __construct($paramOne, $paramTwo);
}
interface InterfaceTypeWithConstructorMethodWithoutParams
{
/**
* We do not expect that this is valid case. There is no need to declare interface with method __construct
*/
public function __construct();
}

0 comments on commit 0a8ee90

Please sign in to comment.