Skip to content

Commit

Permalink
fix issue #136
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville authored and icanhazstring committed Mar 9, 2024
1 parent c16a55c commit 75bc853
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Parser/PHP/DefinedSymbolCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public function enterNode(Node $node)
}

if (
$node instanceof Node\Stmt\Class_ ||
$node instanceof Node\Stmt\Interface_
$node instanceof Node\Stmt\ClassLike
) {
$this->classes[] = $this->namespace . $node->name;

Expand Down
44 changes: 44 additions & 0 deletions tests/Unit/Parser/PHP/SymbolNameParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,48 @@ function () { echo "Hello Handler\n"; },

self::assertCount(0, $symbols);
}

/**
* @test
* @link https://github.com/composer-unused/symbol-parser/issues/136
*/
public function itShouldParseDefinedClassLikeSymbols(): void
{
$code = <<<CODE
<?php
// @link https://www.php.net/manual/en/language.oop5.traits.php
trait ezcReflectionReturnInfo {
function getReturnType() { /*1*/ }
function getReturnDescription() { /*2*/ }
}
class ezcReflectionMethod extends ReflectionMethod {
use ezcReflectionReturnInfo;
/* ... */
}
class ezcReflectionFunction extends ReflectionFunction {
use ezcReflectionReturnInfo;
/* ... */
}
// @link https://www.php.net/manual/en/language.enumerations.basics.php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
CODE;

$symbols = $this->parseDefinedSymbols($code);

self::assertCount(4, $symbols);
self::assertSame('ezcReflectionReturnInfo', $symbols[0]);
self::assertSame('ezcReflectionMethod', $symbols[1]);
self::assertSame('ezcReflectionFunction', $symbols[2]);
self::assertSame('Suit', $symbols[3]);
}
}

0 comments on commit 75bc853

Please sign in to comment.