From 64d3036f2a69a1019284027463eccf68e80ffb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20P=C3=A9rez=20Pellicer?= <5908855+puntope@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:32:47 +0100 Subject: [PATCH] Fix fatal when trying to call toCodeString() in Node\Expr\Variable class (#40855) --- .../analyzer/changelog/fix-analyzer-expr-variable-exception | 4 ++++ projects/packages/analyzer/src/class-utils.php | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 projects/packages/analyzer/changelog/fix-analyzer-expr-variable-exception diff --git a/projects/packages/analyzer/changelog/fix-analyzer-expr-variable-exception b/projects/packages/analyzer/changelog/fix-analyzer-expr-variable-exception new file mode 100644 index 0000000000000..be1af269bba82 --- /dev/null +++ b/projects/packages/analyzer/changelog/fix-analyzer-expr-variable-exception @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixes a bug in Analyzer tring to call toCodeString() in Variable class. diff --git a/projects/packages/analyzer/src/class-utils.php b/projects/packages/analyzer/src/class-utils.php index 7bb4123fecbaa..6ee5589359ada 100644 --- a/projects/packages/analyzer/src/class-utils.php +++ b/projects/packages/analyzer/src/class-utils.php @@ -152,6 +152,11 @@ public static function has_function_call( $node, $name ) { if ( ! $stmt instanceof Node\Stmt\Expression || ! $stmt->expr instanceof Node\Expr\FuncCall ) { continue; } + + if ( $stmt->expr->name instanceof Node\Expr\Variable ) { + continue; + } + if ( false !== strpos( $stmt->expr->name->toCodeString(), $name ) ) { return true; }