diff --git a/.docker/php7.4/Dockerfile b/.docker/php7.4/Dockerfile index 62885d73..918ba660 100644 --- a/.docker/php7.4/Dockerfile +++ b/.docker/php7.4/Dockerfile @@ -10,6 +10,8 @@ RUN apt-get update \ libzip-dev \ && docker-php-ext-install zip \ && docker-php-ext-install opcache \ + && pecl install -o ds \ + && echo "extension=ds.so" > /usr/local/etc/php/conf.d/ds.ini \ && rm -r /var/lib/apt/lists/* RUN pecl install xdebug \ diff --git a/.github/workflows/validate-code.yml b/.github/workflows/validate-code.yml index 8677ea4b..6d614fe7 100644 --- a/.github/workflows/validate-code.yml +++ b/.github/workflows/validate-code.yml @@ -24,7 +24,8 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: composer + tools: composer, pecl + extensions: ds - name: Validate composer.json and composer.lock run: composer validate diff --git a/CHANGELOG.md b/CHANGELOG.md index e01d4ea3..71f586df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index 2d906927..8b57d8cb 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,31 @@ +CONTAINER=composer-unused-7.4 + up: if [ "$(shell docker-machine status default)" != 'Running' ]; then \ docker-machine start default; \ fi; - eval ${docker-machine env} + eval ${shell docker-machine env} docker-compose up -d down: docker-compose down -7.4: - eval $(export COMPOSER_UNUSED_PHP_VERSION=composer-unused-7.4) - -7.3: - eval $(export COMPOSER_UNUSED_PHP_VERSION=composer-unused-7.3) - install: - docker exec -it $(COMPOSER_UNUSED_PHP_VERSION) composer install + docker exec -it $(CONTAINER) composer install update: - docker exec -it $(COMPOSER_UNUSED_PHP_VERSION) composer update + docker exec -it $(CONTAINER) composer update check: csfix cs phpunit analyse phpunit: - docker exec -it $(COMPOSER_UNUSED_PHP_VERSION) vendor/bin/phpunit + docker exec -it $(CONTAINER) vendor/bin/phpunit analyse: - docker exec -it $(COMPOSER_UNUSED_PHP_VERSION) vendor/bin/phpstan analyse + docker exec -it $(CONTAINER) vendor/bin/phpstan analyse cs: - docker exec -it $(COMPOSER_UNUSED_PHP_VERSION) vendor/bin/phpcs + docker exec -it $(CONTAINER) vendor/bin/phpcs csfix: - docker exec -it $(COMPOSER_UNUSED_PHP_VERSION) vendor/bin/phpcbf + docker exec -it $(CONTAINER) vendor/bin/phpcbf diff --git a/src/Parser/PHP/Strategy/PhpExtensionStrategy.php b/src/Parser/PHP/Strategy/PhpExtensionStrategy.php index f301cfdb..238ddb1a 100644 --- a/src/Parser/PHP/Strategy/PhpExtensionStrategy.php +++ b/src/Parser/PHP/Strategy/PhpExtensionStrategy.php @@ -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]; } diff --git a/tests/Integration/Parser/PHP/NodeVisitorTest.php b/tests/Integration/Parser/PHP/NodeVisitorTest.php index 6b465d8d..38b36d80 100644 --- a/tests/Integration/Parser/PHP/NodeVisitorTest.php +++ b/tests/Integration/Parser/PHP/NodeVisitorTest.php @@ -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()) + ], ]; } diff --git a/tests/assets/TestFiles/PhpExtensionStrategy/ClassWithDs.php b/tests/assets/TestFiles/PhpExtensionStrategy/ClassWithDs.php new file mode 100644 index 00000000..ebd72d83 --- /dev/null +++ b/tests/assets/TestFiles/PhpExtensionStrategy/ClassWithDs.php @@ -0,0 +1,13 @@ +