Skip to content

Commit 94ac4b4

Browse files
chore: use modern ZPP macros in the extension generator (#1703)
1 parent 29c88c0 commit 94ac4b4

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

internal/extgen/templates/extension.c.tpl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ void init_object_handlers() {
6060
static zend_class_entry *{{.Name}}_ce = NULL;
6161

6262
PHP_METHOD({{.Name}}, __construct) {
63-
if (zend_parse_parameters_none() == FAILURE) {
64-
RETURN_THROWS();
65-
}
63+
ZEND_PARSE_PARAMETERS_NONE();
6664

6765
{{$.BaseName}}_object *intern = {{$.BaseName}}_object_from_obj(Z_OBJ_P(ZEND_THIS));
6866

@@ -98,17 +96,15 @@ PHP_METHOD({{.ClassName}}, {{.PhpName}}) {
9896
{{- end}}
9997

10098
{{$requiredCount := 0}}{{range .Params}}{{if not .HasDefault}}{{$requiredCount = add1 $requiredCount}}{{end}}{{end -}}
101-
ZEND_PARSE_PARAMETERS_START({{$requiredCount}}, {{len .Params}});
99+
ZEND_PARSE_PARAMETERS_START({{$requiredCount}}, {{len .Params}})
102100
{{$optionalStarted := false}}{{range .Params}}{{if .HasDefault}}{{if not $optionalStarted -}}
103101
Z_PARAM_OPTIONAL
104102
{{$optionalStarted = true}}{{end}}{{end -}}
105103
{{if .IsNullable}}{{if eq .PhpType "string"}}Z_PARAM_STR_OR_NULL({{.Name}}, {{.Name}}_is_null){{else if eq .PhpType "int"}}Z_PARAM_LONG_OR_NULL({{.Name}}, {{.Name}}_is_null){{else if eq .PhpType "float"}}Z_PARAM_DOUBLE_OR_NULL({{.Name}}, {{.Name}}_is_null){{else if eq .PhpType "bool"}}Z_PARAM_BOOL_OR_NULL({{.Name}}, {{.Name}}_is_null){{end}}{{else}}{{if eq .PhpType "string"}}Z_PARAM_STR({{.Name}}){{else if eq .PhpType "int"}}Z_PARAM_LONG({{.Name}}){{else if eq .PhpType "float"}}Z_PARAM_DOUBLE({{.Name}}){{else if eq .PhpType "bool"}}Z_PARAM_BOOL({{.Name}}){{end}}{{end}}
106104
{{end -}}
107105
ZEND_PARSE_PARAMETERS_END();
108106
{{else}}
109-
if (zend_parse_parameters_none() == FAILURE) {
110-
RETURN_THROWS();
111-
}
107+
ZEND_PARSE_PARAMETERS_NONE();
112108
{{end}}
113109

114110
{{- if ne .ReturnType "void"}}

0 commit comments

Comments
 (0)