mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
improve SensitiveConstantNameRector code
This commit is contained in:
parent
ef6bd19e70
commit
c93b2db8d8
@ -112,23 +112,29 @@ CODE_SAMPLE
|
|||||||
*/
|
*/
|
||||||
public function refactor(Node $node): ?Node
|
public function refactor(Node $node): ?Node
|
||||||
{
|
{
|
||||||
// is system constant?
|
$constantName = $this->getName($node);
|
||||||
if (in_array(strtoupper((string) $node->name), $this->phpReservedConstants, true)) {
|
if ($constantName === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentConstantName = (string) $node->name;
|
$uppercasedConstantName = strtoupper($constantName);
|
||||||
|
|
||||||
if (\defined($currentConstantName)) {
|
// is system constant?
|
||||||
return null;
|
if (in_array($uppercasedConstantName, $this->phpReservedConstants, true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// constant is defined in current lower/upper case
|
||||||
|
if (defined($constantName)) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is uppercase, all good
|
// is uppercase, all good
|
||||||
if ($currentConstantName === strtoupper($currentConstantName)) {
|
if ($constantName === $uppercasedConstantName) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$node->name = new FullyQualified(strtoupper($currentConstantName));
|
$node->name = new FullyQualified($uppercasedConstantName);
|
||||||
|
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user