-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Privatization] Skip variable assign append on ChangeReadOnlyVariable…
…WithDefaultValueToConstantRector (#3687) * fix: checking for other modifying types * fix: added fixture * fix: changed class name * fix: checking if parent class is null * fix: checking for all types of assigning
- Loading branch information
1 parent
1898942
commit 4a340be
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...adOnlyVariableWithDefaultValueToConstantRector/Fixture/skip_variable_array_append.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector\Fixture; | ||
|
||
final class SkipVariableArrayAppend | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
private const VALUES = ['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e']; | ||
|
||
public function run() | ||
{ | ||
$arr = []; | ||
foreach (self::VALUES as $key => $value) { | ||
$arr[$value] ??= 0; | ||
$arr[$value] += $key; | ||
} | ||
return $arr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters