Skip to content

Commit

Permalink
Fix issue where ext-ds was not recognized as used
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
  • Loading branch information
Andreas Frömer authored and icanhazstring committed Jun 10, 2020
1 parent 69e5fb4 commit 98ef045
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]
### Fixed
- Fixed an issue where `ext-ds` classes where not recognized as used

## [0.7.3] - 2020-05-19
### Added
- Added workflow to verify integrity of build `phar` file
Expand Down
3 changes: 2 additions & 1 deletion src/Parser/PHP/Strategy/PhpExtensionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ public function extractNamespaces(Node $node): array
private function getNameFromNode(Node $node): string
{
if ($node instanceof Node\Name\FullyQualified) {
return $node->parts[0];
return implode('\\', $node->parts);
}

if ($node instanceof Node\Stmt\UseUse) {
return $node->name->parts[0];
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Integration/Parser/PHP/NodeVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ public function itShouldParseUsagesDataProvider(): array
'inputFile' => ASSET_DIR . '/TestFiles/PhpExtensionStrategy/ClassWithCore.php',
'strategy' => new PhpExtensionStrategy(['Core'], new NullLogger())
],
'PhpExtensionParseStrategyShouldReturnQualifiedNamespace---11' => [
'expectedUsedNamespaces' => ['ext-ds'],
'inputFile' => ASSET_DIR . '/TestFiles/PhpExtensionStrategy/ClassWithDs.php',
'strategy' => new PhpExtensionStrategy(['ds'], new NullLogger())
],
];
}

Expand Down
13 changes: 13 additions & 0 deletions tests/assets/TestFiles/PhpExtensionStrategy/ClassWithDs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace TestFile {
class ClassWithDs
{
public function foo()
{
$map = new \Ds\Map();
}
}
}

0 comments on commit 98ef045

Please sign in to comment.