From e30930a340b060da63ce3aa93422b0242245e36d Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 26 May 2025 21:15:19 +0200 Subject: [PATCH] Ensure namespace->name is valid before using toString() --- Plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugin.php b/Plugin.php index 9ca390b..c3f0a68 100644 --- a/Plugin.php +++ b/Plugin.php @@ -1357,7 +1357,7 @@ public function enterNode( PhpParser\Node $node ) { $this->maxLine = $node->getStartLine(); - if ( $node instanceof Namespace_ ) { + if ( $node instanceof Namespace_ && $node->name instanceof Name ) { // as soon as there is a new namespace, we need to empty the useStatements, as there will be new ones for the given namespace $this->useNamespace = $node->name->toString(); $this->useStatements = [];