Skip to content

Commit 5231473

Browse files
authored
Merge pull request #130 from jaapio/feature/php-parser-4
Feature/php parser 4
2 parents 4ead7ca + e242c34 commit 5231473

File tree

12 files changed

+30
-22
lines changed

12 files changed

+30
-22
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require": {
2323
"php": ">=7.1",
2424
"psr/log": "~1.0",
25-
"nikic/php-parser": "^3.0",
25+
"nikic/php-parser": "^4.0",
2626
"phpdocumentor/reflection-docblock": "^5"
2727
},
2828
"require-dev": {

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phive.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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.9.1" location="./tools/phpstan"/>
3+
<phar name="phpstan" version="^0.9.1" installed="0.10.2" location="./tools/phpstan" copy="true"/>
4+
<phar name="phpunit" version="^6.0" installed="6.5.5" location="./tools/phpunit" copy="true"/>
45
</phive>

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ parameters:
1111
- '#Access to an undefined property PhpParser\\Node\\Const_::\$fqsen\.#'
1212
- '#Access to an undefined property PhpParser\\Node\\Stmt\\PropertyProperty::\$fqsen\.#'
1313
#
14+
# src/phpDocumentor/Reflection/Php/Factory/Argument.php
15+
- '#Access to an undefined property PhpParser\\Node\\Expr\\Error\|PhpParser\\Node\\Expr\\Variable::\$name\.#'
16+
#
1417
# src/phpDocumentor/Reflection/Php/Factory/Class_.php
1518
- '#Access to an undefined property PhpParser\\Node\\Stmt\\Class_::\$fqsen\.#'
1619
#
@@ -19,7 +22,7 @@ parameters:
1922
#
2023
#
2124
# this is a mismatch inside php-parser, not reflection
22-
- '#Parameter \#1 \$nodes of method PhpParser\\NodeTraverser::traverse\(\) expects array\<PhpParser\\Node>, array\<PhpParser\\Node>\|null given\.#'
25+
- '#Parameter \#1 \$nodes of method PhpParser\\NodeTraverser::traverse\(\) expects array\<PhpParser\\Node>, array\<PhpParser\\Node\\Stmt\>|null given\.#'
2326
#
2427
#
2528
# there is one test case that prevents changing PropertyIterator::getDefault() to just return Expr (this is set in PhpParser)

src/phpDocumentor/Reflection/File/LocalFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(string $path)
4040
*/
4141
public function getContents(): string
4242
{
43-
return file_get_contents($this->path);
43+
return (string) file_get_contents($this->path);
4444
}
4545

4646
/**

src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,6 @@ private function buildName(): string
134134
$name .= $part;
135135
}
136136

137-
return rtrim($name, '\\');
137+
return rtrim((string) $name, '\\');
138138
}
139139
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
use phpDocumentor\Reflection\Php\StrategyContainer;
2020
use phpDocumentor\Reflection\PrettyPrinter;
2121
use phpDocumentor\Reflection\Types\Context;
22+
use PhpParser\Node\Expr\Variable;
2223
use PhpParser\Node\Param;
24+
use Webmozart\Assert\Assert;
2325

2426
/**
2527
* Strategy to convert Param to Argument
@@ -59,11 +61,13 @@ public function matches($object): bool
5961
*/
6062
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
6163
{
64+
Assert::isInstanceOf($object, Param::class);
65+
Assert::isInstanceOf($object->var, Variable::class);
6266
$default = null;
6367
if ($object->default !== null) {
6468
$default = $this->valueConverter->prettyPrintExpr($object->default);
6569
}
6670

67-
return new ArgumentDescriptor($object->name, $default, $object->byRef, $object->variadic);
71+
return new ArgumentDescriptor((string) $object->var->name, $default, $object->byRef, $object->variadic);
6872
}
6973
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getLine(): int
5858
*/
5959
public function getName(): string
6060
{
61-
return $this->classConstants->consts[$this->index]->name;
61+
return (string) $this->classConstants->consts[$this->index]->name;
6262
}
6363

6464
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getDocComment(): ?Doc
104104
*/
105105
public function getName(): string
106106
{
107-
return $this->property->props[$this->index]->name;
107+
return (string) $this->property->props[$this->index]->name;
108108
}
109109

110110
/**

src/phpDocumentor/Reflection/PrettyPrinter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ public function pScalar_String(String_ $node): string
5757
return $node->value;
5858
}
5959

60-
return $this->pNoIndent($node->getAttribute('originalValue'));
60+
return (string) $node->getAttribute('originalValue');
6161
}
6262
}

0 commit comments

Comments
 (0)