Skip to content

Commit

Permalink
Bump phpparser top 4.18 min
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapio committed May 7, 2024
1 parent 03c0dbf commit f211c11
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 39 deletions.
3 changes: 2 additions & 1 deletion composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"symbol-whitelist" : [
"null", "true", "false",
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object"
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object",
"PhpParser\\Node\\Stmt\\PropertyProperty"
],
"php-core-extensions" : [
"Core",
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"require": {
"php": "8.1.*|8.2.*|8.3.*",
"nikic/php-parser": "~4.14 || ^5.0",
"nikic/php-parser": "~4.18 || ^5.0",
"phpdocumentor/reflection-common": "^2.1",
"phpdocumentor/reflection-docblock": "^5",
"phpdocumentor/type-resolver": "^1.2",
Expand Down
22 changes: 12 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ parameters:
- '#Parameter \#1 \$fqsen of class phpDocumentor\\Reflection\\Php\\(.*) constructor expects phpDocumentor\\Reflection\\Fqsen, mixed given\.#'
- '#Parameter \#1 \$fqsen of method phpDocumentor\\Reflection\\Php\\File::addNamespace\(\) expects phpDocumentor\\Reflection\\Fqsen, mixed given\.#'
#
# there is one test case that prevents changing PropertyIterator::getDefault() to just return Expr (this is set in PhpParser)
# src/phpDocumentor/Reflection/Php/Factory/Property.php
- '#Parameter \#1 \$node of method PhpParser\\PrettyPrinterAbstract::prettyPrintExpr\(\) expects PhpParser\\Node\\Expr, PhpParser\\Node\\Expr\|string given\.#'
#
# Type hint in php-parser is incorrect.
- '#Cannot cast PhpParser\\Node\\Expr\|string to string.#'

Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
<issueHandlers>
<LessSpecificReturnType errorLevel="info" />
<MoreSpecificImplementedParamType errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
</issueHandlers>
</psalm>
6 changes: 0 additions & 6 deletions src/phpDocumentor/Reflection/Php/Factory/Function_.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
use PhpParser\Node\Stmt\Function_ as FunctionNode;
use Webmozart\Assert\Assert;

use function is_array;

/**
* Strategy to convert Function_ to FunctionDescriptor
*
Expand Down Expand Up @@ -61,10 +59,6 @@ protected function doCreate(

$file->addFunction($function);

if (!is_array($object->stmts)) {
return $function;
}

$thisContext = $context->push($function);
foreach ($object->stmts as $stmt) {
$strategy = $strategies->findMatching($thisContext, $stmt);
Expand Down
6 changes: 3 additions & 3 deletions src/phpDocumentor/Reflection/Php/Factory/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ protected function doCreate(

$iterator = new PropertyIterator($object);
foreach ($iterator as $stmt) {
$default = null;
if ($iterator->getDefault() !== null) {
$default = $this->valueConverter->prettyPrintExpr($iterator->getDefault());
$default = $iterator->getDefault();
if ($default !== null) {
$default = $this->valueConverter->prettyPrintExpr($default);
}

$propertyContainer->addProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getName(): string
/**
* returns the default value of the current property.
*/
public function getDefault(): null|Expr
public function getDefault(): Expr|null
{
return $this->property->props[$this->index]->default;
}
Expand Down
1 change: 0 additions & 1 deletion src/phpDocumentor/Reflection/Php/NodesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace phpDocumentor\Reflection\Php;

use phpDocumentor\Reflection\NodeVisitor\ElementNameResolver;
use PhpParser\Lexer\Emulative;
use PhpParser\Node;
use PhpParser\NodeTraverser;
use PhpParser\NodeTraverserInterface;
Expand Down
24 changes: 15 additions & 9 deletions src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ public function __invoke(Namespace_|null $namespace): Context
private function aliasesToFullyQualifiedNames(Namespace_ $namespace): array
{
// flatten(flatten(map(stuff)))
return array_merge([], ...array_merge([], ...array_map(static fn ($use): array => array_map(static function (UseUse $useUse) use ($use): array {
if ($use instanceof GroupUse) {
return [
(string) $useUse->getAlias() => $use->prefix->toString() . '\\' . $useUse->name->toString(),
];
}

return [(string) $useUse->getAlias() => $useUse->name->toString()];
}, $use->uses), $this->classAlikeUses($namespace))));
return array_merge([], ...array_merge([], ...array_map(
static fn ($use): array => array_map(
static function (Node\UseItem|UseUse $useUse) use ($use): array {
if ($use instanceof GroupUse) {
return [
(string) $useUse->getAlias() => $use->prefix->toString() . '\\' . $useUse->name->toString(),
];
}

return [(string) $useUse->getAlias() => $useUse->name->toString()];
},
$use->uses,
),
$this->classAlikeUses($namespace),
)));
}

/** @return Use_[]|GroupUse[] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use PhpParser\Comment\Doc;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_ as ClassNode;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use PhpParser\Comment\Doc;
use PhpParser\Node\Identifier;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Property as PropertyNode;
use PhpParser\Node\Stmt\PropertyProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace phpDocumentor\Reflection\Php;

use phpDocumentor\Reflection\NodeVisitor\ElementNameResolver;
use PhpParser\Lexer\Emulative;
use PhpParser\NodeTraverser;
use PhpParser\NodeTraverserInterface;
use PhpParser\NodeVisitor\NameResolver;
Expand Down

0 comments on commit f211c11

Please sign in to comment.