Skip to content

Commit

Permalink
add pslam with level 4, fix pslam errors, add baseline because of a p…
Browse files Browse the repository at this point in the history
…roperty check on interface see vimeo/psalm#2206
  • Loading branch information
DanielBadura committed Jul 28, 2020
1 parent 364fece commit ea3badf
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 13 deletions.
8 changes: 8 additions & 0 deletions baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.12.2@7c7ebd068f8acaba211d4a2c707c4ba90874fa26">
<file src="src/ComposerRequireChecker/NodeVisitor/DefinedSymbolCollector.php">
<NoInterfaceProperties occurrences="1">
<code>$node-&gt;namespacedName</code>
</NoInterfaceProperties>
</file>
</files>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
4 changes: 1 addition & 3 deletions src/ComposerRequireChecker/ASTLocator/LocateASTFromFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ComposerRequireChecker\FileLocator;


use Generator;
use Webmozart\Glob\Glob;

class LocateFilesByGlobPattern
Expand All @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit ea3badf

Please sign in to comment.