Skip to content

Commit 558c182

Browse files
committed
fixup! Generate hook names using parsed Node instead of pretty-printed name.
1 parent e860d73 commit 558c182

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/class-hook-reflector.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace WP_Parser;
44

55
use phpDocumentor\Reflection\BaseReflector;
6+
use PhpParser\Node;
67
use PHPParser_PrettyPrinter_Default;
78

89
/**
@@ -29,16 +30,13 @@ class Hook_Reflector extends BaseReflector {
2930
* from: do_action( $filter_name, $args );
3031
* name: {$filter_name}
3132
*
32-
* @param ?\PhpParser\Node $node Use this instead of the current node.
33-
* @return string
33+
* @param ?Node $node Which node to examine; defaults to the parser's current node.
34+
* @return string Represents the hook's name, including any interpolations into the hook name.
3435
*/
3536
public function getName( $node = null ) {
36-
/**
37-
* The current Node being examined.
38-
*
39-
* @var \PhpParser\Node
40-
*/
41-
$node = $node ?? $this->node->args[0]->value;
37+
if ( null === $node ) {
38+
$node = $this->node->args[0]->value;
39+
}
4240
$printer = new PHPParser_PrettyPrinter_Default;
4341
$name = $printer->prettyPrintExpr( $node );
4442

0 commit comments

Comments
 (0)