Skip to content

Commit 5ed93ff

Browse files
committed
Merge pull request nikic#22 from zeroedin-bill/add-ast-stub
Add ast_stub.php
2 parents c387d50 + a043da0 commit 5ed93ff

File tree

1 file changed

+277
-0
lines changed

1 file changed

+277
-0
lines changed

ast_stub.php

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
<?php
2+
/**
3+
* PHPDoc stub file for ast extension
4+
* @author Bill Schaller <[email protected]>
5+
* @author Nikita Popov <[email protected]>
6+
*/
7+
8+
namespace ast;
9+
10+
// AST CONSTANTS
11+
/* Dumped using command line:
12+
* php.exe -r "foreach(get_defined_constants(true)['ast'] as $constant => $value) {echo \"define('$constant', $value);\n\";}"
13+
*/
14+
// AST KIND CONSTANTS
15+
define('ast\AST_FUNC_DECL', 66);
16+
define('ast\AST_CLOSURE', 67);
17+
define('ast\AST_METHOD', 68);
18+
define('ast\AST_CLASS', 69);
19+
define('ast\AST_ARG_LIST', 128);
20+
define('ast\AST_LIST', 129);
21+
define('ast\AST_ARRAY', 130);
22+
define('ast\AST_ENCAPS_LIST', 131);
23+
define('ast\AST_EXPR_LIST', 132);
24+
define('ast\AST_STMT_LIST', 133);
25+
define('ast\AST_IF', 134);
26+
define('ast\AST_SWITCH_LIST', 135);
27+
define('ast\AST_CATCH_LIST', 136);
28+
define('ast\AST_PARAM_LIST', 137);
29+
define('ast\AST_CLOSURE_USES', 138);
30+
define('ast\AST_PROP_DECL', 139);
31+
define('ast\AST_CONST_DECL', 140);
32+
define('ast\AST_CLASS_CONST_DECL', 141);
33+
define('ast\AST_NAME_LIST', 142);
34+
define('ast\AST_TRAIT_ADAPTATIONS', 143);
35+
define('ast\AST_USE', 144);
36+
define('ast\AST_MAGIC_CONST', 0);
37+
define('ast\AST_TYPE', 1);
38+
define('ast\AST_VAR', 256);
39+
define('ast\AST_CONST', 257);
40+
define('ast\AST_UNPACK', 258);
41+
define('ast\AST_UNARY_PLUS', 259);
42+
define('ast\AST_UNARY_MINUS', 260);
43+
define('ast\AST_CAST', 261);
44+
define('ast\AST_EMPTY', 262);
45+
define('ast\AST_ISSET', 263);
46+
define('ast\AST_SILENCE', 264);
47+
define('ast\AST_SHELL_EXEC', 265);
48+
define('ast\AST_CLONE', 266);
49+
define('ast\AST_EXIT', 267);
50+
define('ast\AST_PRINT', 268);
51+
define('ast\AST_INCLUDE_OR_EVAL', 269);
52+
define('ast\AST_UNARY_OP', 270);
53+
define('ast\AST_PRE_INC', 271);
54+
define('ast\AST_PRE_DEC', 272);
55+
define('ast\AST_POST_INC', 273);
56+
define('ast\AST_POST_DEC', 274);
57+
define('ast\AST_YIELD_FROM', 275);
58+
define('ast\AST_GLOBAL', 276);
59+
define('ast\AST_UNSET', 277);
60+
define('ast\AST_RETURN', 278);
61+
define('ast\AST_LABEL', 279);
62+
define('ast\AST_REF', 280);
63+
define('ast\AST_HALT_COMPILER', 281);
64+
define('ast\AST_ECHO', 282);
65+
define('ast\AST_THROW', 283);
66+
define('ast\AST_GOTO', 284);
67+
define('ast\AST_BREAK', 285);
68+
define('ast\AST_CONTINUE', 286);
69+
define('ast\AST_DIM', 512);
70+
define('ast\AST_PROP', 513);
71+
define('ast\AST_STATIC_PROP', 514);
72+
define('ast\AST_CALL', 515);
73+
define('ast\AST_CLASS_CONST', 516);
74+
define('ast\AST_ASSIGN', 517);
75+
define('ast\AST_ASSIGN_REF', 518);
76+
define('ast\AST_ASSIGN_OP', 519);
77+
define('ast\AST_BINARY_OP', 520);
78+
define('ast\AST_GREATER', 521);
79+
define('ast\AST_GREATER_EQUAL', 522);
80+
define('ast\AST_AND', 523);
81+
define('ast\AST_OR', 524);
82+
define('ast\AST_ARRAY_ELEM', 525);
83+
define('ast\AST_NEW', 526);
84+
define('ast\AST_INSTANCEOF', 527);
85+
define('ast\AST_YIELD', 528);
86+
define('ast\AST_COALESCE', 529);
87+
define('ast\AST_STATIC', 530);
88+
define('ast\AST_WHILE', 531);
89+
define('ast\AST_DO_WHILE', 532);
90+
define('ast\AST_IF_ELEM', 533);
91+
define('ast\AST_SWITCH', 534);
92+
define('ast\AST_SWITCH_CASE', 535);
93+
define('ast\AST_DECLARE', 536);
94+
define('ast\AST_CONST_ELEM', 537);
95+
define('ast\AST_USE_TRAIT', 538);
96+
define('ast\AST_TRAIT_PRECEDENCE', 539);
97+
define('ast\AST_METHOD_REFERENCE', 540);
98+
define('ast\AST_NAMESPACE', 541);
99+
define('ast\AST_USE_ELEM', 542);
100+
define('ast\AST_TRAIT_ALIAS', 543);
101+
define('ast\AST_GROUP_USE', 544);
102+
define('ast\AST_METHOD_CALL', 768);
103+
define('ast\AST_STATIC_CALL', 769);
104+
define('ast\AST_CONDITIONAL', 770);
105+
define('ast\AST_TRY', 771);
106+
define('ast\AST_CATCH', 772);
107+
define('ast\AST_PARAM', 773);
108+
define('ast\AST_PROP_ELEM', 774);
109+
define('ast\AST_FOR', 1024);
110+
define('ast\AST_FOREACH', 1025);
111+
define('ast\AST_NAME', 2048);
112+
define('ast\AST_CLOSURE_VAR', 2049);
113+
114+
// FLAG CONSTANTS
115+
define('ast\flags\NAME_FQ', 0);
116+
define('ast\flags\NAME_NOT_FQ', 1);
117+
define('ast\flags\NAME_RELATIVE', 2);
118+
define('ast\flags\MODIFIER_PUBLIC', 256);
119+
define('ast\flags\MODIFIER_PROTECTED', 512);
120+
define('ast\flags\MODIFIER_PRIVATE', 1024);
121+
define('ast\flags\MODIFIER_STATIC', 1);
122+
define('ast\flags\MODIFIER_ABSTRACT', 2);
123+
define('ast\flags\MODIFIER_FINAL', 4);
124+
define('ast\flags\RETURNS_REF', 67108864);
125+
define('ast\flags\CLASS_ABSTRACT', 32);
126+
define('ast\flags\CLASS_FINAL', 4);
127+
define('ast\flags\CLASS_TRAIT', 128);
128+
define('ast\flags\CLASS_INTERFACE', 64);
129+
define('ast\flags\CLASS_ANONYMOUS', 256);
130+
define('ast\flags\PARAM_REF', 1);
131+
define('ast\flags\PARAM_VARIADIC', 2);
132+
define('ast\flags\TYPE_NULL', 1);
133+
define('ast\flags\TYPE_BOOL', 13);
134+
define('ast\flags\TYPE_LONG', 4);
135+
define('ast\flags\TYPE_DOUBLE', 5);
136+
define('ast\flags\TYPE_STRING', 6);
137+
define('ast\flags\TYPE_ARRAY', 7);
138+
define('ast\flags\TYPE_OBJECT', 8);
139+
define('ast\flags\TYPE_CALLABLE', 14);
140+
define('ast\flags\UNARY_BOOL_NOT', 13);
141+
define('ast\flags\UNARY_BITWISE_NOT', 12);
142+
define('ast\flags\UNARY_SILENCE', 260);
143+
define('ast\flags\UNARY_PLUS', 261);
144+
define('ast\flags\UNARY_MINUS', 262);
145+
define('ast\flags\BINARY_BOOL_AND', 259);
146+
define('ast\flags\BINARY_BOOL_OR', 258);
147+
define('ast\flags\BINARY_BOOL_XOR', 14);
148+
define('ast\flags\BINARY_BITWISE_OR', 9);
149+
define('ast\flags\BINARY_BITWISE_AND', 10);
150+
define('ast\flags\BINARY_BITWISE_XOR', 11);
151+
define('ast\flags\BINARY_CONCAT', 8);
152+
define('ast\flags\BINARY_ADD', 1);
153+
define('ast\flags\BINARY_SUB', 2);
154+
define('ast\flags\BINARY_MUL', 3);
155+
define('ast\flags\BINARY_DIV', 4);
156+
define('ast\flags\BINARY_MOD', 5);
157+
define('ast\flags\BINARY_POW', 166);
158+
define('ast\flags\BINARY_SHIFT_LEFT', 6);
159+
define('ast\flags\BINARY_SHIFT_RIGHT', 7);
160+
define('ast\flags\BINARY_IS_IDENTICAL', 15);
161+
define('ast\flags\BINARY_IS_NOT_IDENTICAL', 16);
162+
define('ast\flags\BINARY_IS_EQUAL', 17);
163+
define('ast\flags\BINARY_IS_NOT_EQUAL', 18);
164+
define('ast\flags\BINARY_IS_SMALLER', 19);
165+
define('ast\flags\BINARY_IS_SMALLER_OR_EQUAL', 20);
166+
define('ast\flags\BINARY_IS_GREATER', 256);
167+
define('ast\flags\BINARY_IS_GREATER_OR_EQUAL', 257);
168+
define('ast\flags\BINARY_SPACESHIP', 170);
169+
define('ast\flags\ASSIGN_BITWISE_OR', 31);
170+
define('ast\flags\ASSIGN_BITWISE_AND', 32);
171+
define('ast\flags\ASSIGN_BITWISE_XOR', 33);
172+
define('ast\flags\ASSIGN_CONCAT', 30);
173+
define('ast\flags\ASSIGN_ADD', 23);
174+
define('ast\flags\ASSIGN_SUB', 24);
175+
define('ast\flags\ASSIGN_MUL', 25);
176+
define('ast\flags\ASSIGN_DIV', 26);
177+
define('ast\flags\ASSIGN_MOD', 27);
178+
define('ast\flags\ASSIGN_POW', 167);
179+
define('ast\flags\ASSIGN_SHIFT_LEFT', 28);
180+
define('ast\flags\ASSIGN_SHIFT_RIGHT', 29);
181+
define('ast\flags\EXEC_EVAL', 1);
182+
define('ast\flags\EXEC_INCLUDE', 2);
183+
define('ast\flags\EXEC_INCLUDE_ONCE', 4);
184+
define('ast\flags\EXEC_REQUIRE', 8);
185+
define('ast\flags\EXEC_REQUIRE_ONCE', 16);
186+
define('ast\flags\USE_NORMAL', 361);
187+
define('ast\flags\USE_FUNCTION', 346);
188+
define('ast\flags\USE_CONST', 347);
189+
define('ast\flags\MAGIC_LINE', 370);
190+
define('ast\flags\MAGIC_FILE', 371);
191+
define('ast\flags\MAGIC_DIR', 372);
192+
define('ast\flags\MAGIC_NAMESPACE', 389);
193+
define('ast\flags\MAGIC_FUNCTION', 376);
194+
define('ast\flags\MAGIC_METHOD', 375);
195+
define('ast\flags\MAGIC_CLASS', 373);
196+
define('ast\flags\MAGIC_TRAIT', 374);
197+
198+
// AST FUNCTION PROTOTYPES
199+
/**
200+
* @param string $filename Code file to parse
201+
* @param int $version API version
202+
* @return Node Root node of AST
203+
* @see https://github.com/nikic/php-ast for version information
204+
*/
205+
function parse_file($filename, $version)
206+
{
207+
}
208+
209+
/**
210+
* Parses code string and returns AST root node.
211+
* @param string $code Code string to parse
212+
* @param int $version API version
213+
* @param string $filename Optional - specifies filename of parsed file
214+
* @return Node Root node of AST
215+
* @see https://github.com/nikic/php-ast for version information
216+
*/
217+
function parse_code($code, $version, $filename = "string code")
218+
{
219+
}
220+
221+
/**
222+
* @param int $kind AST_* constant value defining the kind of an AST node
223+
* @return string string representation of AST kind value
224+
*/
225+
function get_kind_name($kind)
226+
{
227+
}
228+
229+
/**
230+
* @param int $kind AST_* constant value defining the kind of an AST node
231+
* @return bool returns true if AST kind uses flags
232+
*/
233+
function kind_uses_flags($kind)
234+
{
235+
}
236+
237+
/**
238+
* This class describes a single node in a PHP AST.
239+
* @package ast
240+
*/
241+
class Node
242+
{
243+
/** @var int AST Node Kind. Values are one of ast\AST_* constants. */
244+
public $kind;
245+
246+
/**
247+
* @var int AST Flags.
248+
* Certain node kinds have flags that can be set.
249+
* These will be a bitfield of ast\flags\* constants.
250+
*/
251+
public $flags;
252+
253+
/** @var int source line number */
254+
public $lineno;
255+
256+
/** @var array Child nodes, if any exist */
257+
public $children;
258+
}
259+
260+
namespace ast\Node;
261+
262+
/**
263+
* AST Node type for function and class declarations.
264+
* Class Decl
265+
* @package ast\Node
266+
*/
267+
class Decl extends \ast\Node
268+
{
269+
/** @var int end line number of the declaration */
270+
public $endLineno;
271+
272+
/** @var string name of the function or class */
273+
public $name;
274+
275+
/** @var string|null doc comment preceeding the declaration. null if no doc comment was used. */
276+
public $docComment;
277+
}

0 commit comments

Comments
 (0)