From de6fed397636a70821b072a994c20b7c8a25b6a6 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 21 Feb 2025 02:43:05 +0700 Subject: [PATCH] do not rename property on property promotion --- rector.php | 6 +++++- src/base/MemoizableArray.php | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/rector.php b/rector.php index a9a2f3f3f8c..1243ab88d74 100644 --- a/rector.php +++ b/rector.php @@ -6,6 +6,7 @@ use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; +use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php80\Rector\FunctionLike\MixedTypeRector; use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; @@ -41,4 +42,7 @@ MixedTypeRector::class, ]) - ->withPhpSets(php80: true); + ->withPhpSets(php80: true) + ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [ + ClassPropertyAssignToConstructorPromotionRector::RENAME_PROPERTY => false, + ]); diff --git a/src/base/MemoizableArray.php b/src/base/MemoizableArray.php index 9ae8d453bc1..0a1c5dc181d 100644 --- a/src/base/MemoizableArray.php +++ b/src/base/MemoizableArray.php @@ -34,6 +34,11 @@ */ class MemoizableArray implements IteratorAggregate, Countable { + /** + * @var array Array elements + */ + private array $_elements; + /** * @var callable|null Normalizer method */ @@ -52,12 +57,13 @@ class MemoizableArray implements IteratorAggregate, Countable /** * Constructor * - * @param array $_elements The items to be memoized + * @param array $elements The items to be memoized * @param callable|null $normalizer A method that the items should be normalized with when first returned by * [[all()]] or [[firstWhere()]]. */ - public function __construct(private array $_elements, ?callable $normalizer = null) + public function __construct(array $elements, ?callable $normalizer = null) { + $this->_elements = $elements; $this->_normalizer = $normalizer; }