Skip to content

Commit

Permalink
[PHP 5.5] Make StringClassNameToClassConstantRector skip lcfirst (#2888)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Sep 1, 2022
1 parent 88b75c6 commit 2c454d2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Source"
],
"files": [
"stubs/Directory.php",
"stubs/Doctrine/Persistence/ObjectManager.php",
"stubs/Doctrine/Common/Persistence/ObjectManager.php",
"rules-tests/Transform/Rector/FuncCall/FuncCallToMethodCallRector/Source/some_view_function.php",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Rector\Tests\Php55\Rector\String_\StringClassNameToClassConstantRector\Fixture;

final class KeepShortClassNames
{
public function run()
{
return 'directory';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ private function shouldSkip(string $classLikeName, String_ $string): bool
return true;
}

// possibly string
if (ctype_lower($classLikeName[0])) {
return true;
}

foreach ($this->classesToSkip as $classToSkip) {
if ($this->nodeNameResolver->isStringName($classLikeName, $classToSkip)) {
return true;
Expand Down
12 changes: 12 additions & 0 deletions stubs/Directory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

if (class_exists('Directory')) {
return;
}

final class Directory
{

}

0 comments on commit 2c454d2

Please sign in to comment.