From 869f4ec062eaf5250ba0e978acfe84846b136a94 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Mon, 23 Mar 2026 14:03:52 +0100 Subject: [PATCH] fix: don't parenthesize assign inside static variable declaration --- src/needs-parens.mjs | 2 +- tests/static/__snapshots__/jsfmt.spec.mjs.snap | 6 +++++- tests/static/static.php | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/needs-parens.mjs b/src/needs-parens.mjs index 8ea379e2c..2bbf380ff 100644 --- a/src/needs-parens.mjs +++ b/src/needs-parens.mjs @@ -166,7 +166,7 @@ function needsParens(path, options) { return false; } else if (parent.kind === "assign") { return false; - } else if (parent.kind === "static") { + } else if (parent.kind === "staticvariable") { return false; } else if ( ["if", "do", "while", "foreach", "switch"].includes(parent.kind) diff --git a/tests/static/__snapshots__/jsfmt.spec.mjs.snap b/tests/static/__snapshots__/jsfmt.spec.mjs.snap index b7053ed68..ac5bf294c 100644 --- a/tests/static/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/static/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`static.php 1`] = ` ====================================options===================================== @@ -43,6 +43,8 @@ string string', $b = 'string string string'; +static $x = $a = 1; +static $x = $a = $b = 1; =====================================output=====================================