Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'fix/#92-#90-fix-class-scanner-get-interfaces' into develop
Browse files Browse the repository at this point in the history
Forward port #90
Forward port #92
  • Loading branch information
Ocramius committed Sep 20, 2016
2 parents 3712b82 + de130a5 commit 85c5e66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Scanner/ClassScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,11 @@ protected function scan()
case T_STRING:
switch ($classContext) {
case T_EXTENDS:
$this->shortParentClass .= $tokenContent;
if ($this->isInterface) {
$this->shortInterfaces[$classInterfaceIndex] .= $tokenContent;
} else {
$this->shortParentClass .= $tokenContent;
}
break;
case T_IMPLEMENTS:
$this->shortInterfaces[$classInterfaceIndex] .= $tokenContent;
Expand All @@ -1006,7 +1010,8 @@ protected function scan()
// goto no break needed

case null:
if ($classContext == T_IMPLEMENTS && $tokenContent == ',') {
if (($classContext == T_IMPLEMENTS && $tokenContent == ',')
|| ($classContext == T_EXTENDS && $tokenContent == ',' && $this->isInterface)) {
$classInterfaceIndex++;
$this->shortInterfaces[$classInterfaceIndex] = '';
}
Expand Down
9 changes: 9 additions & 0 deletions test/Scanner/ClassScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,13 @@ public function testTraitIsNotInstantiable()
$this->assertTrue($class->isTrait());
$this->assertFalse($class->isInstantiable());
}

public function testGetInterfacesFromInterface()
{
$file = new FileScanner(__DIR__ . '/../TestAsset/FooInterface.php');
$class = $file->getClass('ZendTest\Code\TestAsset\FooInterface');
$this->assertTrue($class->isInterface());
$this->assertEquals(1, count($class->getInterfaces()));
$this->assertEquals('ArrayAccess', $class->getInterfaces()[0]);
}
}

0 comments on commit 85c5e66

Please sign in to comment.