Skip to content

Commit

Permalink
Fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Aug 28, 2023
1 parent 26e527a commit e1ef744
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ function getAncestorNode(path, typeOrTypes) {
return counter === -1 ? null : path.getParentNode(counter);
}

const magicMethods = new Set([
const magicMethods = [
"__construct",
"__destruct",
"__call",
Expand All @@ -664,13 +664,16 @@ const magicMethods = new Set([
"__set_state",
"__clone",
"__debugInfo",
]);
];
const magicMethodsMap = new Map(
magicMethods.map((name) => [name.toLowerCase(), name])
);

function normalizeMagicMethodName(name) {
const loweredName = name.toLowerCase();

if (magicMethods.has(loweredName)) {
return loweredName;
if (magicMethodsMap.has(loweredName)) {
return magicMethodsMap.get(loweredName);
}

return name;
Expand Down
6 changes: 3 additions & 3 deletions tests/case/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ class Connection
{
}
public static function __CALLSTATIC($name, $arguments)
public static function __callStatic($name, $arguments)
{
}
Expand Down Expand Up @@ -623,7 +623,7 @@ class Connection
{
}
public function __TOSTRING()
public function __toString()
{
}
Expand All @@ -639,7 +639,7 @@ class Connection
{
}
public function __DEBUGINFO()
public function __debugInfo()
{
}
Expand Down

0 comments on commit e1ef744

Please sign in to comment.