Skip to content

Commit

Permalink
[Naming] Skip singularize "cms" on RenameForeachValueVariableToMatchE…
Browse files Browse the repository at this point in the history
…xprVariableRector (#5294)

* [Naming] Skip singularize "cms" on RenameForeachValueVariableToMatchExprVariableRector

* clean up
  • Loading branch information
samsonasik authored Nov 28, 2023
1 parent b5f434b commit 4a2b4a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\Tests\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector\Fixture;

class SkipCmsMiddle
{
public function run()
{
foreach ($cmsBlocks as $cmsBlock) {
}
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ private function singularizeCamelParts(string $currentName): string

$resolvedName = '';
foreach ($camelCases as $camelCase) {
$value = $this->inflector->singularize($camelCase[self::CAMELCASE]);

if (in_array($camelCase[self::CAMELCASE], ['is', 'has'], true)) {
if (in_array($camelCase[self::CAMELCASE], ['is', 'has', 'cms'], true)) {
$value = $camelCase[self::CAMELCASE];
} else {
$value = $this->inflector->singularize($camelCase[self::CAMELCASE]);
}

$resolvedName .= $value;
Expand Down

0 comments on commit 4a2b4a6

Please sign in to comment.