From 23e4e6110adf0e780bbd9e21507420a6e262d86e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 18 Dec 2021 08:28:26 +0100 Subject: [PATCH] Tokenizer/PHP: readonly bug fix While going through some sniffs to add support, I realized that parameters with a reference were not accounted for correctly. Fixed with test. --- src/Tokenizers/PHP.php | 1 + tests/Core/Tokenizer/BackfillReadonlyTest.inc | 3 +++ tests/Core/Tokenizer/BackfillReadonlyTest.php | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 27f5544e35..68da7f6393 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -2856,6 +2856,7 @@ protected function processAdditional() T_NAME_QUALIFIED => T_NAME_QUALIFIED, T_TYPE_UNION => T_TYPE_UNION, T_BITWISE_OR => T_BITWISE_OR, + T_BITWISE_AND => T_BITWISE_AND, T_ARRAY => T_ARRAY, T_CALLABLE => T_CALLABLE, T_SELF => T_SELF, diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.inc b/tests/Core/Tokenizer/BackfillReadonlyTest.inc index f585134ca3..ab7c16c321 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.inc +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.inc @@ -52,6 +52,9 @@ class Foo public function __construct(private readonly bool $constructorPropertyPromotion) { } + + /* testReadonlyConstructorPropertyPromotionWithReference */ + public function __construct(private ReadOnly bool &$constructorPropertyPromotion) {} } $anonymousClass = new class () { diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index 0f4e922862..d347417143 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -139,6 +139,10 @@ public function dataReadonly() '/* testReadonlyConstructorPropertyPromotion */', 'readonly', ], + [ + '/* testReadonlyConstructorPropertyPromotionWithReference */', + 'ReadOnly', + ], [ '/* testReadonlyPropertyInAnonymousClass */', 'readonly',