diff --git a/composer.json b/composer.json index c98a5a4..9bf8bce 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,12 @@ "phpstan/extension-installer": "^1.4", "tracy/tracy": "^2.10", "symplify/easy-coding-standard": "^12.3", - "rector/rector": "^1.2.4", + "rector/rector": "^1.2.5", "phpunit/phpunit": "^10.5", "tomasvotruba/class-leak": "^0.2.11", "tomasvotruba/type-coverage": "^0.3", - "symplify/easy-ci": "^12.0", - "shipmonk/composer-dependency-analyser": "^1.5", + "symplify/easy-ci": "^12.1", + "shipmonk/composer-dependency-analyser": "^1.7", "symplify/phpstan-rules": "^13.0" }, "autoload": { diff --git a/src/Collectors/PublicStaticPropertyFetchCollector.php b/src/Collectors/PublicStaticPropertyFetchCollector.php index e759d07..44c6f45 100644 --- a/src/Collectors/PublicStaticPropertyFetchCollector.php +++ b/src/Collectors/PublicStaticPropertyFetchCollector.php @@ -57,7 +57,9 @@ public function processNode(Node $node, Scope $scope): ?array return null; } - $classType = $node->class instanceof Name ? $scope->resolveTypeByName($node->class) : $scope->getType($node->class); + $classType = $node->class instanceof Name ? $scope->resolveTypeByName($node->class) : $scope->getType( + $node->class + ); $result = []; foreach ($classType->getObjectClassReflections() as $classReflection) { diff --git a/src/Finder/TemplateFilesFinder.php b/src/Finder/TemplateFilesFinder.php index 30229a0..6b822a7 100644 --- a/src/Finder/TemplateFilesFinder.php +++ b/src/Finder/TemplateFilesFinder.php @@ -4,6 +4,9 @@ namespace TomasVotruba\UnusedPublic\Finder; +/** + * @see \TomasVotruba\UnusedPublic\Tests\Templates\TemplateFilesFinder\TemplateFilesFinderTest + */ final class TemplateFilesFinder { /** @@ -15,10 +18,12 @@ public static function findTemplateFilePaths(array $directories, string $suffix) $templateFilePaths = []; foreach ($directories as $directory) { + $currentTemplateFilePathsL0 = glob($directory . '/*.' . $suffix); $currentTemplateFilePathsL1 = glob($directory . '/*/*.' . $suffix); $currentTemplateFilePathsL2 = glob($directory . '/**/*/*.' . $suffix); $currentTemplateFilePaths = array_merge( + $currentTemplateFilePathsL0 === false ? [] : $currentTemplateFilePathsL0, $currentTemplateFilePathsL1 === false ? [] : $currentTemplateFilePathsL1, $currentTemplateFilePathsL2 === false ? [] : $currentTemplateFilePathsL2 ); diff --git a/tests/Templates/TemplateFilesFinder/Fixture/first.file.twig b/tests/Templates/TemplateFilesFinder/Fixture/first.file.twig new file mode 100644 index 0000000..9c59e24 --- /dev/null +++ b/tests/Templates/TemplateFilesFinder/Fixture/first.file.twig @@ -0,0 +1 @@ +first diff --git a/tests/Templates/TemplateFilesFinder/Fixture/nested/second.file.twig b/tests/Templates/TemplateFilesFinder/Fixture/nested/second.file.twig new file mode 100644 index 0000000..e019be0 --- /dev/null +++ b/tests/Templates/TemplateFilesFinder/Fixture/nested/second.file.twig @@ -0,0 +1 @@ +second diff --git a/tests/Templates/TemplateFilesFinder/TemplateFilesFinderTest.php b/tests/Templates/TemplateFilesFinder/TemplateFilesFinderTest.php new file mode 100644 index 0000000..c3dc376 --- /dev/null +++ b/tests/Templates/TemplateFilesFinder/TemplateFilesFinderTest.php @@ -0,0 +1,15 @@ +assertCount(2, $twigFilePaths); + } +}