-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #11: Add TypedAttributeStrategy
Using this strategy, the collector will recognize consumed symbols by typed properties.
- Loading branch information
1 parent
8573c25
commit 10d94a3
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
PHP_VERSION=7.4 | ||
PHP_VERSION=8.1 | ||
|
||
up: ## Run all containers in all versions | ||
docker compose up -d | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ComposerUnused\SymbolParser\Parser\PHP\Strategy; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Name\FullyQualified; | ||
|
||
final class TypedAttributeStrategy implements StrategyInterface | ||
{ | ||
public function canHandle(Node $node): bool | ||
{ | ||
if (!$node instanceof Node\Stmt\Property) { | ||
return false; | ||
} | ||
|
||
return $node->type instanceof FullyQualified; | ||
} | ||
|
||
/** | ||
* @param Node&Node\Stmt\Property $node | ||
* @return array<string> | ||
*/ | ||
public function extractSymbolNames(Node $node): array | ||
{ | ||
/** @var FullyQualified $type */ | ||
$type = $node->type; | ||
|
||
return [$type->toString()]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters