Skip to content

Commit b78d092

Browse files
committed
Fix phpstan errors
1 parent 7430772 commit b78d092

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

phive.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="^0.9.1" installed="0.10.7" location="./tools/phpstan" copy="true"/>
3+
<phar name="phpstan" version="^0.9.1" installed="0.11.4" location="./tools/phpstan" copy="true"/>
44
<phar name="phpunit" version="^7.0" installed="7.5.7" location="./tools/phpunit" copy="true"/>
55
<phar name="phpbench" version="^0.16.9" installed="0.16.9" location="./tools/phpbench" copy="true"/>
66
</phive>

phpstan.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ parameters:
22
ignoreErrors:
33

44
- '#Method phpDocumentor\\Reflection\\File\\LocalFile::\md5\(\) should return string but returns string\|false\.#'
5+
- '#Else branch is unreachable because ternary operator condition is always true\.#'
6+
# Design issue that needs to be fixed in factory strategies.
7+
- '#Return type \(phpDocumentor\\Reflection\\DocBlock\|null\) of method phpDocumentor\\Reflection\\Php\\Factory\\DocBlock::create\(\) should be compatible with return type \(phpDocumentor\\Reflection\\Element\) of method phpDocumentor\\Reflection\\Php\\ProjectFactoryStrategy::create\(\)#'
58
#
69
# all these $fqsen errors indicate the need for a decorator class around PhpParser\Node to hold the public $fqsen that Reflection is giving it)
710
#
811
# src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php
12+
- '#Access to an undefined property PhpParser\\Node::\$fqsen\.#'
913
- '#Access to an undefined property PhpParser\\Node\\Stmt\\Namespace_::\$fqsen\.#'
1014
- '#Access to an undefined property PhpParser\\Node\\Stmt\\Interface_::\$fqsen\.#'
1115
- '#Access to an undefined property PhpParser\\Node\\Stmt\\Function_::\$fqsen\.#'
@@ -35,6 +39,9 @@ parameters:
3539
# there are some Elements doubling as Arguments, so we should probably tie their classes together somehow
3640
# src/phpDocumentor/Reflection/Php/Factory/Function_.php
3741
- '#Parameter \#1 \$argument of method phpDocumentor\\Reflection\\Php\\Function\_::addArgument\(\) expects phpDocumentor\\Reflection\\Php\\Argument, phpDocumentor\\Reflection\\Element given\.#'
42+
43+
# Type hint in php-parser is incorrect.
44+
- '#Cannot cast PhpParser\\Node\\Expr\|string to string.#'
3845
#
3946
#
4047
# many classes here that should have relationship to Element

src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ final class ElementNameResolver extends NodeVisitorAbstract
3939
/**
4040
* Resets the object to a known state before start processing.
4141
*/
42-
public function beforeTraverse(array $nodes): void
42+
public function beforeTraverse(array $nodes)
4343
{
4444
$this->resetState('\\');
4545
}
4646

4747
/**
4848
* Performs a reset of the added element when needed.
4949
*/
50-
public function leaveNode(Node $node): void
50+
public function leaveNode(Node $node)
5151
{
5252
switch (get_class($node)) {
5353
case Namespace_::class:
@@ -83,12 +83,11 @@ public function enterNode(Node $node): ?int
8383
case Class_::class:
8484
case Trait_::class:
8585
case Interface_::class:
86-
$this->parts->push((string) $node->name);
87-
8886
if (empty($node->name)) {
8987
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
9088
}
9189

90+
$this->parts->push((string)$node->name);
9291
$node->fqsen = new Fqsen($this->buildName());
9392
break;
9493
case Function_::class:

src/phpDocumentor/Reflection/Php/Factory/DocBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function matches($object): bool
5959
* @param Context $context of the created object
6060
* @return null|DocBlockDescriptor
6161
*/
62-
public function create($object, StrategyContainer $strategies, ?Context $context = null)
62+
public function create($object, StrategyContainer $strategies, ?Context $context = null): ?DocBlockDescriptor
6363
{
6464
if ($object === null) {
6565
return null;

src/phpDocumentor/Reflection/Php/ProjectFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
use phpDocumentor\Reflection\DocBlockFactory;
1818
use phpDocumentor\Reflection\Exception;
19+
use phpDocumentor\Reflection\File as SourceFile;
1920
use phpDocumentor\Reflection\Fqsen;
2021
use phpDocumentor\Reflection\PrettyPrinter;
2122
use phpDocumentor\Reflection\Project as ProjectInterface;
@@ -66,7 +67,7 @@ public static function createInstance(): self
6667
* Creates a project from the set of files.
6768
*
6869
* @param string $name
69-
* @param File[] $files
70+
* @param SourceFile[] $files
7071
* @throws Exception when no matching strategy was found.
7172
*/
7273
public function create($name, array $files): ProjectInterface

src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private function aliasesToFullyQualifiedNames(Namespace_ $namespace) : array
4444
}
4545

4646
/**
47-
* @param null|Namespace_ $namespace
47+
* @param Namespace_ $namespace
4848
*
4949
* @return Use_[]|GroupUse[]
5050
*/

0 commit comments

Comments
 (0)