diff --git a/baseline.xml b/baseline.xml
new file mode 100644
index 00000000..9e572e4c
--- /dev/null
+++ b/baseline.xml
@@ -0,0 +1,8 @@
+
+
+
+
+ $node->namespacedName
+
+
+
diff --git a/composer.json b/composer.json
index 1e0849fd..889acd0e 100644
--- a/composer.json
+++ b/composer.json
@@ -38,7 +38,8 @@
"ext-zend-opcache": "*",
"mikey179/vfsstream": "^1.6",
"phpstan/phpstan": "^0.12",
- "phpunit/phpunit": "^8.5.8"
+ "phpunit/phpunit": "^8.5.8",
+ "vimeo/psalm": "^3.12.2"
},
"config": {
"optimize-autoloader": true,
diff --git a/psalm.xml b/psalm.xml
new file mode 100644
index 00000000..d5025223
--- /dev/null
+++ b/psalm.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/ComposerRequireChecker/ASTLocator/LocateASTFromFiles.php b/src/ComposerRequireChecker/ASTLocator/LocateASTFromFiles.php
index 7eebc726..5a509811 100644
--- a/src/ComposerRequireChecker/ASTLocator/LocateASTFromFiles.php
+++ b/src/ComposerRequireChecker/ASTLocator/LocateASTFromFiles.php
@@ -25,9 +25,7 @@ public function __construct(Parser $parser, ?ErrorHandler $errorHandler)
}
/**
- * @param Traversable|string[] $files
- *
- * @return Traversable|array[] a series of AST roots, one for each given file
+ * @return Traversable a series of AST roots, one for each given file
*/
public function __invoke(Traversable $files): Traversable
{
diff --git a/src/ComposerRequireChecker/DefinedSymbolsLocator/LocateDefinedSymbolsFromASTRoots.php b/src/ComposerRequireChecker/DefinedSymbolsLocator/LocateDefinedSymbolsFromASTRoots.php
index 1e5fef11..81378aad 100644
--- a/src/ComposerRequireChecker/DefinedSymbolsLocator/LocateDefinedSymbolsFromASTRoots.php
+++ b/src/ComposerRequireChecker/DefinedSymbolsLocator/LocateDefinedSymbolsFromASTRoots.php
@@ -10,7 +10,7 @@
final class LocateDefinedSymbolsFromASTRoots
{
/**
- * @param Traversable|array[] $ASTs a series of AST roots
+ * @param Traversable $ASTs a series of AST roots
*
* @return string[] all the found symbols
*/
diff --git a/src/ComposerRequireChecker/FileLocator/LocateFilesByGlobPattern.php b/src/ComposerRequireChecker/FileLocator/LocateFilesByGlobPattern.php
index 84ad1052..190ef00a 100644
--- a/src/ComposerRequireChecker/FileLocator/LocateFilesByGlobPattern.php
+++ b/src/ComposerRequireChecker/FileLocator/LocateFilesByGlobPattern.php
@@ -2,7 +2,7 @@
namespace ComposerRequireChecker\FileLocator;
-
+use Generator;
use Webmozart\Glob\Glob;
class LocateFilesByGlobPattern
@@ -11,10 +11,10 @@ class LocateFilesByGlobPattern
/**
* @param string[] $globPatterns a list of glob patterns to find files in
* @param string $rootDir the root directory that should be used when patterns are relative paths
- * @return iterable|string[] the files found by the given glob patterns
+ * @return Generator the files found by the given glob patterns
* @see https://github.com/webmozart/glob
*/
- public function __invoke(array $globPatterns = [], string $rootDir): iterable
+ public function __invoke(array $globPatterns = [], string $rootDir): Generator
{
foreach ($globPatterns as $globPattern) {
yield from Glob::glob(rtrim($rootDir, '/') . '/' . $globPattern);
diff --git a/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php b/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php
index 34bacd4c..acbc9fa4 100644
--- a/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php
+++ b/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php
@@ -123,11 +123,16 @@ private function recordFunctionReturnTypeUsage(Node $node)
if ($node instanceof Node\Stmt\Function_
|| $node instanceof Node\Stmt\ClassMethod
) {
- if ($node->getReturnType() instanceof Node\Name) {
- $this->recordUsageOf($node->getReturnType());
+ $returnType = $node->getReturnType();
+
+ if ($returnType instanceof Node\Name) {
+ $this->recordUsageOf($returnType);
+ }
+ if ($returnType instanceof Node\Identifier) {
+ $this->recordUsageOfByString($returnType->toString());
}
- if (is_string($node->getReturnType()) || $node->getReturnType() instanceof Node\Identifier) {
- $this->recordUsageOfByString($node->getReturnType());
+ if (is_string($returnType)) {
+ $this->recordUsageOfByString($returnType);
}
}
}
diff --git a/src/ComposerRequireChecker/UsedSymbolsLocator/LocateUsedSymbolsFromASTRoots.php b/src/ComposerRequireChecker/UsedSymbolsLocator/LocateUsedSymbolsFromASTRoots.php
index 01b817cb..2d05dc8d 100644
--- a/src/ComposerRequireChecker/UsedSymbolsLocator/LocateUsedSymbolsFromASTRoots.php
+++ b/src/ComposerRequireChecker/UsedSymbolsLocator/LocateUsedSymbolsFromASTRoots.php
@@ -10,7 +10,7 @@
final class LocateUsedSymbolsFromASTRoots
{
/**
- * @param Traversable|array[] $ASTs a series of AST roots
+ * @param Traversable $ASTs a series of AST roots
*
* @return string[] all the found symbols
*/