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

1. Fix ClassScanner::getInterfaces() which don't work with Interface. #92

Merged
merged 5 commits into from
Sep 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]);
}
}