Skip to content

Commit 33eac94

Browse files
committed
requires nikic/php-parser 5.0 or newer
1 parent 919a24a commit 33eac94

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"require-dev": {
2222
"nette/tester": "^2.4",
23-
"nikic/php-parser": "^4.18 || ^5.0",
23+
"nikic/php-parser": "^5.0",
2424
"tracy/tracy": "^2.8",
2525
"phpstan/phpstan": "^1.0",
2626
"jetbrains/phpstorm-attributes": "dev-master"

src/PhpGenerator/Extractor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Nette;
1313
use PhpParser;
14+
use PhpParser\Modifiers;
1415
use PhpParser\Node;
1516
use PhpParser\NodeFinder;
1617
use PhpParser\ParserFactory;
@@ -414,9 +415,8 @@ private function setupFunction(GlobalFunction|Method $function, Node\FunctionLik
414415
$function->setReturnType($node->getReturnType() ? $this->toPhp($node->getReturnType()) : null);
415416
foreach ($node->getParams() as $item) {
416417
$visibility = $this->toVisibility($item->flags);
417-
$isReadonly = (bool) ($item->flags & Node\Stmt\Class_::MODIFIER_READONLY);
418418
$param = $visibility
419-
? ($function->addPromotedParameter($item->var->name))->setVisibility($visibility)->setReadonly($isReadonly)
419+
? $function->addPromotedParameter($item->var->name)->setVisibility($visibility)->setReadonly($item->isReadonly())
420420
: $function->addParameter($item->var->name);
421421
$param->setType($item->type ? $this->toPhp($item->type) : null);
422422
$param->setReference($item->byRef);
@@ -483,9 +483,9 @@ private function toValue(Node\Expr $node): mixed
483483
private function toVisibility(int $flags): ?string
484484
{
485485
return match (true) {
486-
(bool) ($flags & Node\Stmt\Class_::MODIFIER_PUBLIC) => ClassType::VisibilityPublic,
487-
(bool) ($flags & Node\Stmt\Class_::MODIFIER_PROTECTED) => ClassType::VisibilityProtected,
488-
(bool) ($flags & Node\Stmt\Class_::MODIFIER_PRIVATE) => ClassType::VisibilityPrivate,
486+
(bool) ($flags & Modifiers::PUBLIC) => ClassType::VisibilityPublic,
487+
(bool) ($flags & Modifiers::PROTECTED) => ClassType::VisibilityProtected,
488+
(bool) ($flags & Modifiers::PRIVATE) => ClassType::VisibilityPrivate,
489489
default => null,
490490
};
491491
}

0 commit comments

Comments
 (0)