-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathclass-function-call-reflector.php
51 lines (39 loc) · 1.11 KB
/
class-function-call-reflector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* A reflection class for a function call.
*/
namespace WP_Parser;
use phpDocumentor\Reflection\BaseReflector;
/**
* A reflection of a function call expression.
*/
class Function_Call_Reflector extends BaseReflector {
/**
* Returns the name for this Reflector instance.
*
* @return string
*/
public function getName() {
if ( isset( $this->node->namespacedName ) ) {
return '\\' . implode( '\\', $this->node->namespacedName->parts );
}
$shortName = $this->getShortName();
if ( is_a( $shortName, 'PhpParser\Node\Name\FullyQualified' ) ) {
return '\\' . (string) $shortName;
}
if ( is_a( $shortName, 'PhpParser\Node\Name' ) ) {
return (string) $shortName;
}
/** @var \PhpParser\Node\Expr\ArrayDimFetch $shortName */
if ( is_a( $shortName, 'PhpParser\Node\Expr\ArrayDimFetch' ) ) {
$var = $shortName->var->name;
$dim = $shortName->dim->name->parts[0];
return "\${$var}[{$dim}]";
}
/** @var \PhpParser\Node\Expr\Variable $shortName */
if ( is_a( $shortName, 'PhpParser\Node\Expr\Variable' ) ) {
return $shortName->name;
}
return (string) $shortName;
}
}