1 | <?php |
||
8 | class ParsedFunction |
||
9 | { |
||
10 | /** |
||
11 | * The function name. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $name; |
||
16 | |||
17 | /** |
||
18 | * The line where the function starts. |
||
19 | * |
||
20 | * @var int |
||
21 | */ |
||
22 | protected $line; |
||
23 | |||
24 | /** |
||
25 | * The strings extracted from the function arguments. |
||
26 | * |
||
27 | * @var string[] |
||
28 | */ |
||
29 | protected $arguments; |
||
30 | |||
31 | /** |
||
32 | * The current index of the function (-1 if no arguments). |
||
33 | * |
||
34 | * @var int|null |
||
35 | */ |
||
36 | protected $argumentIndex; |
||
37 | |||
38 | /** |
||
39 | * Shall we stop adding string chunks to the current argument? |
||
40 | * |
||
41 | * @var bool |
||
42 | */ |
||
43 | protected $argumentStopped; |
||
44 | |||
45 | /** |
||
46 | * Extracted comments. |
||
47 | * |
||
48 | * @var string[]|null |
||
49 | */ |
||
50 | protected $comments; |
||
51 | |||
52 | /** |
||
53 | * Initializes the instance. |
||
54 | * |
||
55 | * @param string $name The function name. |
||
56 | * @param int $line The line where the function starts. |
||
57 | */ |
||
58 | public function __construct($name, $line) |
||
59 | { |
||
60 | $this->name = $name; |
||
61 | $this->line = $line; |
||
62 | $this->arguments = []; |
||
63 | $this->argumentIndex = -1; |
||
64 | $this->argumentStopped = false; |
||
65 | $this->comments = null; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Stop extracting strings from the current argument (because we found something that's not a string). |
||
70 | */ |
||
71 | public function stopArgument() |
||
78 | |||
79 | /** |
||
80 | * Go to the next argument because we a comma was found. |
||
81 | */ |
||
82 | public function nextArgument() |
||
92 | |||
93 | /** |
||
94 | * Add a string to the current argument. |
||
95 | * |
||
96 | * @param string|null $chunk |
||
97 | */ |
||
98 | public function addArgumentChunk($chunk) |
||
111 | |||
112 | /** |
||
113 | * Add a comment associated to this function. |
||
114 | * |
||
115 | * @param string $comment |
||
116 | */ |
||
117 | public function addComment($comment) |
||
124 | |||
125 | /** |
||
126 | * Return the line the function starts. |
||
127 | * |
||
128 | * @return int Line number. |
||
129 | */ |
||
130 | public function getLine() |
||
134 | |||
135 | /** |
||
136 | * A closing parenthesis was found: return the final data. |
||
137 | * The array returned has the following values: |
||
138 | * 0 => string The function name. |
||
139 | * 1 => int The line where the function starts. |
||
140 | * 2 => string[] the strings extracted from the function arguments. |
||
141 | * 3 => string[] the comments associated to the function. |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | public function close() |
||
159 | } |
||
160 |