Skip to content

Commit adf204b

Browse files
committed
fix function scanner #3
1 parent 0ad8516 commit adf204b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/JsNodeVisitor.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ protected static function getFunctionName(CallExpression $node): ?string
8787
case 'Identifier':
8888
return $callee->getName();
8989
case 'MemberExpression':
90-
return $callee->getProperty()->getName();
90+
$property = $callee->getProperty();
91+
92+
if ($property->getType() === 'Identifier') {
93+
return $property->getName();
94+
}
95+
return null;
9196
default:
9297
return null;
9398
}

tests/assets/functions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ fn9(ARG_8);
2727
/* No Related comment 4 */
2828
);
2929
})
30-
fn13(fn14(fn15('foo')));
30+
fn13(fn14(fn15('foo')));
31+
32+
// https://github.com/php-gettext/JS-Scanner/issues/3
33+
var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;

0 commit comments

Comments
 (0)