Skip to content

Commit

Permalink
Also support MemberExpression and improve robustness of CallExpressio…
Browse files Browse the repository at this point in the history
…n callees
  • Loading branch information
Herre Groen committed Oct 24, 2018
1 parent 0caa444 commit fcfba1e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/JsFunctionsScanner.php
Expand Up @@ -73,9 +73,17 @@ public function saveGettextFunctions( Translations $translations, array $options
} else if (
'CallExpression' === $node->getCallee()->getType() &&
'Identifier' === $node->getCallee()->getCallee()->getType() &&
'Object' === $node->getCallee()->getCallee()->getName()
'Object' === $node->getCallee()->getCallee()->getName() &&
! empty( $node->getCallee()->getArguments() ) &&
'MemberExpression' === $node->getCallee()->getArguments()[0]->getType() &&
'Identifier' === $node->getCallee()->getArguments()[0]->getProperty()->getType()
) {
$callee = $node->getCallee()->getArguments()[0]->getProperty();
} else if (
'MemberExpression' === $node->getCallee()->getType() &&
'Identifier' === $node->getCallee()->getProperty()->getType()
) {
$callee = $node->getCallee()->getProperty();
}

if ( ! $callee || ! isset( $functions[ $callee->getName() ] ) ) {
Expand Down

0 comments on commit fcfba1e

Please sign in to comment.