From 9d6f96850c4d27a195376c31e897f95d4e6772f3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 19 Jan 2026 08:55:39 +0700 Subject: [PATCH 1/4] [Php85] Skip as assigned var on ArrayFirstLastRector --- .../Fixture/skip_in_write_context.php.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_in_write_context.php.inc diff --git a/rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_in_write_context.php.inc b/rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_in_write_context.php.inc new file mode 100644 index 00000000000..d83ea8be900 --- /dev/null +++ b/rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_in_write_context.php.inc @@ -0,0 +1,13 @@ + Date: Mon, 19 Jan 2026 08:56:15 +0700 Subject: [PATCH 2/4] fix --- rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php b/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php index 57f655e5bd2..4cb81156ed2 100644 --- a/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php +++ b/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php @@ -180,6 +180,10 @@ private function shouldSkip(ArrayDimFetch $arrayDimFetch, Node $scopeNode): bool return true; } + if ($arrayDimFetch->getAttribute(AttributeKey::IS_BEING_ASSIGNED)) { + return true; + } + return (bool) $arrayDimFetch->getAttribute(AttributeKey::IS_UNSET_VAR); } } From 3b16e4f08d4ff5668133bb76d30e95b1839192c5 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 19 Jan 2026 08:57:59 +0700 Subject: [PATCH 3/4] fix --- rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php b/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php index 4cb81156ed2..e8e33017dff 100644 --- a/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php +++ b/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php @@ -180,7 +180,7 @@ private function shouldSkip(ArrayDimFetch $arrayDimFetch, Node $scopeNode): bool return true; } - if ($arrayDimFetch->getAttribute(AttributeKey::IS_BEING_ASSIGNED)) { + if ($arrayDimFetch->getAttribute(AttributeKey::IS_BEING_ASSIGNED) === true) { return true; } From 83dfe8516cc42b45a1f8e606f527cfdf1008b43f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 19 Jan 2026 09:06:57 +0700 Subject: [PATCH 4/4] final touch: handle also as assign op --- .../Fixture/skip_as_assign_op.php.inc | 13 +++++++++++++ ..._context.php.inc => skip_as_assign_variable.inc} | 4 ++-- .../Rector/ArrayDimFetch/ArrayFirstLastRector.php | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_as_assign_op.php.inc rename rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/{skip_in_write_context.php.inc => skip_as_assign_variable.inc} (68%) diff --git a/rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_as_assign_op.php.inc b/rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_as_assign_op.php.inc new file mode 100644 index 00000000000..882e6488a02 --- /dev/null +++ b/rules-tests/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector/Fixture/skip_as_assign_op.php.inc @@ -0,0 +1,13 @@ +getAttribute(AttributeKey::IS_ASSIGN_OP_VAR) === true) { + return true; + } + return (bool) $arrayDimFetch->getAttribute(AttributeKey::IS_UNSET_VAR); } }