Skip to content

Commit ee170a8

Browse files
committed
Merge branch 'fix/zendframework#92-zendframework#90-fix-class-scanner-get-interfaces'
Close zendframework#90 Close zendframework#92
2 parents 66d1a05 + 430dd90 commit ee170a8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/Scanner/ClassScanner.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,11 @@ protected function scan()
985985
case T_STRING:
986986
switch ($classContext) {
987987
case T_EXTENDS:
988-
$this->shortParentClass .= $tokenContent;
988+
if ($this->isInterface) {
989+
$this->shortInterfaces[$classInterfaceIndex] .= $tokenContent;
990+
} else {
991+
$this->shortParentClass .= $tokenContent;
992+
}
989993
break;
990994
case T_IMPLEMENTS:
991995
$this->shortInterfaces[$classInterfaceIndex] .= $tokenContent;
@@ -1006,7 +1010,8 @@ protected function scan()
10061010
// goto no break needed
10071011

10081012
case null:
1009-
if ($classContext == T_IMPLEMENTS && $tokenContent == ',') {
1013+
if (($classContext == T_IMPLEMENTS && $tokenContent == ',')
1014+
|| ($classContext == T_EXTENDS && $tokenContent == ',' && $this->isInterface)) {
10101015
$classInterfaceIndex++;
10111016
$this->shortInterfaces[$classInterfaceIndex] = '';
10121017
}

test/Scanner/ClassScannerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,13 @@ public function testTraitIsNotInstantiable()
307307
$this->assertTrue($class->isTrait());
308308
$this->assertFalse($class->isInstantiable());
309309
}
310+
311+
public function testGetInterfacesFromInterface()
312+
{
313+
$file = new FileScanner(__DIR__ . '/../TestAsset/FooInterface.php');
314+
$class = $file->getClass('ZendTest\Code\TestAsset\FooInterface');
315+
$this->assertTrue($class->isInterface());
316+
$this->assertEquals(1, count($class->getInterfaces()));
317+
$this->assertEquals('ArrayAccess', $class->getInterfaces()[0]);
318+
}
310319
}

0 commit comments

Comments
 (0)