summaryrefslogtreecommitdiff
path: root/ext/zend_test
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zend_test')
-rw-r--r--ext/zend_test/php_test.h2
-rw-r--r--ext/zend_test/test.c49
2 files changed, 28 insertions, 23 deletions
diff --git a/ext/zend_test/php_test.h b/ext/zend_test/php_test.h
index b76155e866..9d1784f0d9 100644
--- a/ext/zend_test/php_test.h
+++ b/ext/zend_test/php_test.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c
index 53af862d24..e13ef6257c 100644
--- a/ext/zend_test/test.c
+++ b/ext/zend_test/test.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -50,7 +48,13 @@ ZEND_END_ARG_INFO()
ZEND_FUNCTION(zend_test_func)
{
- /* dummy */
+ RETVAL_STR_COPY(EX(func)->common.function_name);
+
+ /* Cleanup trampoline */
+ ZEND_ASSERT(EX(func)->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE);
+ zend_string_release(EX(func)->common.function_name);
+ zend_free_trampoline(EX(func));
+ EX(func) = NULL;
}
ZEND_FUNCTION(zend_test_array_return)
@@ -144,41 +148,45 @@ static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */
/* }}} */
static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key) /* {{{ */ {
- zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
- fptr->type = ZEND_OVERLOADED_FUNCTION_TEMPORARY;
+ zend_internal_function *fptr;
+
+ if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
+ fptr = (zend_internal_function *) &EG(trampoline);
+ } else {
+ fptr = emalloc(sizeof(zend_internal_function));
+ }
+ memset(fptr, 0, sizeof(zend_internal_function));
+ fptr->type = ZEND_INTERNAL_FUNCTION;
fptr->num_args = 1;
- fptr->arg_info = NULL;
fptr->scope = (*object)->ce;
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
fptr->function_name = zend_string_copy(name);
fptr->handler = ZEND_FN(zend_test_func);
- zend_set_function_arg_flags((zend_function*)fptr);
return (zend_function*)fptr;
}
/* }}} */
static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ {
- zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
- fptr->type = ZEND_OVERLOADED_FUNCTION;
+ zend_internal_function *fptr;
+
+ if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
+ fptr = (zend_internal_function *) &EG(trampoline);
+ } else {
+ fptr = emalloc(sizeof(zend_internal_function));
+ }
+ memset(fptr, 0, sizeof(zend_internal_function));
+ fptr->type = ZEND_INTERNAL_FUNCTION;
fptr->num_args = 1;
- fptr->arg_info = NULL;
fptr->scope = ce;
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
- fptr->function_name = name;
+ fptr->function_name = zend_string_copy(name);
fptr->handler = ZEND_FN(zend_test_func);
- zend_set_function_arg_flags((zend_function*)fptr);
return (zend_function*)fptr;
}
/* }}} */
-static int zend_test_class_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ {
- RETVAL_STR(zend_string_copy(method));
- return 0;
-}
-/* }}} */
-
static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ {
RETURN_TRUE;
}
@@ -209,7 +217,7 @@ PHP_MINIT_FUNCTION(zend_test)
zval val;
ZVAL_LONG(&val, 123);
zend_declare_typed_property(
- zend_test_class, name, &val, ZEND_ACC_PUBLIC, NULL, ZEND_TYPE_ENCODE(IS_LONG, 0));
+ zend_test_class, name, &val, ZEND_ACC_PUBLIC, NULL, ZEND_TYPE_ENCODE_CODE(IS_LONG, 0));
zend_string_release(name);
}
@@ -230,7 +238,7 @@ PHP_MINIT_FUNCTION(zend_test)
ZVAL_LONG(&val, 123);
zend_declare_typed_property(
zend_test_class, name, &val, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC, NULL,
- ZEND_TYPE_ENCODE(IS_LONG, 0));
+ ZEND_TYPE_ENCODE_CODE(IS_LONG, 0));
zend_string_release(name);
}
@@ -239,7 +247,6 @@ PHP_MINIT_FUNCTION(zend_test)
memcpy(&zend_test_class_handlers, &std_object_handlers, sizeof(zend_object_handlers));
zend_test_class_handlers.get_method = zend_test_class_method_get;
- zend_test_class_handlers.call_method = zend_test_class_call_method;
INIT_CLASS_ENTRY(class_entry, "_ZendTestTrait", zend_test_trait_methods);
zend_test_trait = zend_register_internal_class(&class_entry);