-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgument.php
More file actions
114 lines (100 loc) · 2.1 KB
/
Copy pathArgument.php
File metadata and controls
114 lines (100 loc) · 2.1 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Argument
*
* @author SolveBeam <info@solvebeam.com>
* @copyright 2005-2022 SolveBeam
* @license GPL-3.0-or-later
* @package SolveBeam\WordPress\Documentor
*/
namespace SolveBeam\WordPress\Documentor;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use PhpParser\Node\Arg;
/**
* Argument
*
* @author Remco Tolsma
* @version 1.0.0
* @since 1.0.0
*/
class Argument {
/**
* PHP Parser argument object.
*
* @link https://github.com/nikic/PHP-Parser/blob/v4.10.4/lib/PhpParser/Node/Arg.php
* @var Arg
*/
private $arg;
/**
* Parameter tag.
*
* @link https://github.com/phpDocumentor/ReflectionDocBlock/blob/5.2.2/src/DocBlock/Tags/Param.php
* @var Param|null
*/
private $param_tag;
/**
* Construct hook argument.
*
* @param Arg $arg Argument.
*/
public function __construct( Arg $arg ) {
$this->arg = $arg;
}
/**
* Get PHP Parser argument object.
*
* @return Arg
*/
public function get_php_parser_argument() {
return $this->arg;
}
/**
* Get name.
*
* @return string
*/
public function get_name() {
$pretty_printer = new \PhpParser\PrettyPrinter\Standard();
return $pretty_printer->prettyPrint( [ $this->arg ] );
}
/**
* Get param tag.
*
* @return Param|null
*/
public function get_param_tag() {
return $this->param_tag;
}
/**
* Set param tag.
*
* @param Param|null $param_tag Param tag.
*/
public function set_param_tag( ?Param $param_tag = null ) {
$this->param_tag = $param_tag;
}
/**
* Get type,
*
* @link https://github.com/phpDocumentor/ReflectionDocBlock/blob/5.2.2/src/DocBlock/Tags/TagWithType.php#L27-L33
* @return string|null
*/
public function get_type() {
if ( null === $this->param_tag ) {
return null;
}
return \strval( $this->param_tag->getType() );
}
/**
* Get description.
*
* @link https://github.com/phpDocumentor/ReflectionDocBlock/blob/5.2.2/src/DocBlock/Tags/BaseTag.php#L40-L43
* @return string|null
*/
public function get_description() {
if ( null === $this->param_tag ) {
return null;
}
return \strval( $this->param_tag->getDescription() );
}
}