Skip to content

Commit 7e9865c

Browse files
committed
Make stubs namespaced
This is now support in gen_stub.
1 parent f1f89ca commit 7e9865c

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

ast.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ PHP_FUNCTION(get_supported_versions) {
12531253
}
12541254
}
12551255

1256-
PHP_METHOD(ast_Node, __construct) {
1256+
PHP_METHOD(Node, __construct) {
12571257
int num_args = ZEND_NUM_ARGS();
12581258
if (num_args == 0) {
12591259
/* If arguments aren't passed, leave them as their default values. */
@@ -1302,21 +1302,6 @@ PHP_METHOD(ast_Node, __construct) {
13021302
}
13031303
}
13041304

1305-
const zend_function_entry ast_functions[] = {
1306-
ZEND_NS_FE("ast", parse_file, arginfo_parse_file)
1307-
ZEND_NS_FE("ast", parse_code, arginfo_parse_code)
1308-
ZEND_NS_FE("ast", get_kind_name, arginfo_get_kind_name)
1309-
ZEND_NS_FE("ast", kind_uses_flags, arginfo_kind_uses_flags)
1310-
ZEND_NS_FE("ast", get_metadata, arginfo_get_metadata)
1311-
ZEND_NS_FE("ast", get_supported_versions, arginfo_get_supported_versions)
1312-
PHP_FE_END
1313-
};
1314-
1315-
const zend_function_entry ast_node_functions[] = {
1316-
PHP_ME(ast_Node, __construct, arginfo_class_Node___construct, ZEND_ACC_PUBLIC)
1317-
PHP_FE_END
1318-
};
1319-
13201305
PHP_MINFO_FUNCTION(ast) {
13211306
zend_string *info = ast_version_info();
13221307

@@ -1463,7 +1448,7 @@ PHP_MINIT_FUNCTION(ast) {
14631448

14641449
ast_register_flag_constant("PARENTHESIZED_CONDITIONAL", ZEND_PARENTHESIZED_CONDITIONAL);
14651450

1466-
INIT_CLASS_ENTRY(tmp_ce, "ast\\Node", ast_node_functions);
1451+
INIT_CLASS_ENTRY(tmp_ce, "ast\\Node", class_Node_methods);
14671452
ast_node_ce = zend_register_internal_class(&tmp_ce);
14681453
ast_declare_property(ast_node_ce, AST_STR(str_kind), &zv_null);
14691454
ast_declare_property(ast_node_ce, AST_STR(str_flags), &zv_null);
@@ -1491,7 +1476,7 @@ PHP_MSHUTDOWN_FUNCTION(ast) {
14911476
zend_module_entry ast_module_entry = {
14921477
STANDARD_MODULE_HEADER,
14931478
"ast",
1494-
ast_functions,
1479+
ext_functions,
14951480
PHP_MINIT(ast),
14961481
PHP_MSHUTDOWN(ast),
14971482
PHP_RINIT(ast),

ast.stub.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<?php
22

3+
/** @generate-function-entries */
4+
35
/**
46
* USE ast_stub.php INSTEAD IF YOU ARE LOOKING FOR DOCUMENTATION OR STUBS FOR YOUR IDE.
57
*
68
* This is a stub file meant only for use with https://github.com/php/php-src/blob/master/build/gen_stub.php
79
* to generate Reflection information (ReflectionParameter, ReflectionFunction, ReflectionMethod, etc.)
810
*/
911

10-
// XXX: build/gen_stub.php does not support namespace nodes at the time of writing.
11-
// The namespace is thus deliberately omitted so that ast_arginfo.h can be successfully built.
12-
// namespace ast;
13-
12+
namespace ast;
1413

1514
/**
1615
* Parses code file and returns AST root node.

ast_arginfo.h

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 6c168364b94be45e237e47fd5709046457c6cb6b */
2+
* Stub hash: 41024915fb5255fdbd22c2864f1d3793de262593 */
33

4-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_parse_code, 0, 2, ast\\Node, 0)
4+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_ast_parse_code, 0, 2, ast\\Node, 0)
55
ZEND_ARG_TYPE_INFO(0, code, IS_STRING, 0)
66
ZEND_ARG_TYPE_INFO(0, version, IS_LONG, 0)
77
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filename, IS_STRING, 0, "\'string code\'")
88
ZEND_END_ARG_INFO()
99

10-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_parse_file, 0, 2, ast\\Node, 0)
10+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_ast_parse_file, 0, 2, ast\\Node, 0)
1111
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
1212
ZEND_ARG_TYPE_INFO(0, version, IS_LONG, 0)
1313
ZEND_END_ARG_INFO()
1414

15-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_kind_name, 0, 1, IS_STRING, 0)
15+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ast_get_kind_name, 0, 1, IS_STRING, 0)
1616
ZEND_ARG_TYPE_INFO(0, kind, IS_LONG, 0)
1717
ZEND_END_ARG_INFO()
1818

19-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_kind_uses_flags, 0, 1, _IS_BOOL, 0)
19+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ast_kind_uses_flags, 0, 1, _IS_BOOL, 0)
2020
ZEND_ARG_TYPE_INFO(0, kind, IS_LONG, 0)
2121
ZEND_END_ARG_INFO()
2222

23-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_metadata, 0, 0, IS_ARRAY, 0)
23+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ast_get_metadata, 0, 0, IS_ARRAY, 0)
2424
ZEND_END_ARG_INFO()
2525

26-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_supported_versions, 0, 0, IS_ARRAY, 0)
26+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ast_get_supported_versions, 0, 0, IS_ARRAY, 0)
2727
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, exclude_deprecated, _IS_BOOL, 0, "false")
2828
ZEND_END_ARG_INFO()
2929

@@ -33,3 +33,29 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Node___construct, 0, 0, 0)
3333
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, children, IS_ARRAY, 1, "null")
3434
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, lineno, IS_LONG, 1, "null")
3535
ZEND_END_ARG_INFO()
36+
37+
38+
ZEND_FUNCTION(parse_code);
39+
ZEND_FUNCTION(parse_file);
40+
ZEND_FUNCTION(get_kind_name);
41+
ZEND_FUNCTION(kind_uses_flags);
42+
ZEND_FUNCTION(get_metadata);
43+
ZEND_FUNCTION(get_supported_versions);
44+
ZEND_METHOD(Node, __construct);
45+
46+
47+
static const zend_function_entry ext_functions[] = {
48+
ZEND_NS_FE("ast", parse_code, arginfo_ast_parse_code)
49+
ZEND_NS_FE("ast", parse_file, arginfo_ast_parse_file)
50+
ZEND_NS_FE("ast", get_kind_name, arginfo_ast_get_kind_name)
51+
ZEND_NS_FE("ast", kind_uses_flags, arginfo_ast_kind_uses_flags)
52+
ZEND_NS_FE("ast", get_metadata, arginfo_ast_get_metadata)
53+
ZEND_NS_FE("ast", get_supported_versions, arginfo_ast_get_supported_versions)
54+
ZEND_FE_END
55+
};
56+
57+
58+
static const zend_function_entry class_Node_methods[] = {
59+
ZEND_ME(Node, __construct, arginfo_class_Node___construct, ZEND_ACC_PUBLIC)
60+
ZEND_FE_END
61+
};

0 commit comments

Comments
 (0)