mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-22 18:54:39 +01:00
Add support for case insensitive const renaming
This commit is contained in:
parent
5393711450
commit
c81aa78da8
@ -34,9 +34,6 @@ final class ClassConstantReplacerRector extends AbstractRector
|
||||
$this->identifierRenamer = $identifierRenamer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo complete list with all possibilities
|
||||
*/
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition('Replaces defined class constants in their calls.', [
|
||||
@ -73,7 +70,7 @@ final class ClassConstantReplacerRector extends AbstractRector
|
||||
}
|
||||
|
||||
foreach ($oldToNewConstants as $oldConstant => $newConstant) {
|
||||
if (! $this->isName($node, $oldConstant)) {
|
||||
if (! $this->isNameInsensitive($node, $oldConstant)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,11 @@ trait NameResolverTrait
|
||||
return $this->getName($node) === $name;
|
||||
}
|
||||
|
||||
public function isNameInsensitive(Node $node, string $name): bool
|
||||
{
|
||||
return strtolower($this->getName($node)) === strtolower($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $names
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@ class SomeClass
|
||||
public function subscribe()
|
||||
{
|
||||
return [
|
||||
LocalFormEvents::PRE_SUBMIT,
|
||||
LocalFormEvents::PRE_SUBMIT
|
||||
];
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ class SomeClass
|
||||
public function subscribe()
|
||||
{
|
||||
return [
|
||||
LocalFormEvents::PRE_BIND
|
||||
LocalFormEvents::PRE_BIND,
|
||||
LocalFormEvents::PRE_Bind
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user