com php-src: Merge branch 'master' of https://github.com/php/php-src into typed-properties: Zend/zend_API.c Zend/zend_API.h Z end/zend_ast.c
Zend/zend_ast.h Zend/zend_compile .c Zend/zend_compile.h Zend/zend_execute.c Zend /zend_execute.h Zend/zend_execute_API.c Zend/zend _inheritance.c
Zend/zend_language_parser.y Zend/z end_object_handlers.c Zend/zend_types.h Zend/zend _vm_def.h Zend/zend_vm_execute.h ext/opcache/Op
timizer/zend_optimizer.c ext/opcache
| From: | Bob Weinand | Date: | Mon, 23 May 2016 11:48:43 +0000 |
| Subject: | com php-src: Merge branch 'master' of https://github.com/php/php-src into typed-properties: Zend/zend_API.c Zend/zend_API.h Z end/zend_ast.c Zend/zend_ast.h Zend/zend_compile .c Zend/zend_compile.h Zend/zend_execute.c Zend /zend_execute.h Zend/zend_execute_API.c Zend/zend _inheritance.c Zend/zend_language_parser.y Zend/z end_object_handlers.c Zend/zend_types.h Zend/zend _vm_def.h Zend/zend_vm_execute.h ext/opcache/Op timizer/zend_optimizer.c ext/opcache |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95563@lists.php.net to get a copy of this message | ||
Commit: f2845964099df78abb6a5c10a73006955ee2f9ec
Author: Joe Watkins <krakjoe@php.net> Mon, 23 May 2016 12:48:43 +0100
Parents: ecfb1e3835c5227ef0964eb957baa34c49ba4d1e 0cdbabe558dbdbe3bab6ba9102dba8311a5ea7f7
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f2845964099df78abb6a5c10a73006955ee2f9ec
Log:
Merge branch 'master' of https://github.com/php/php-src into typed-properties
Conflicts:
Zend/zend_execute.c
Zend/zend_vm_execute.h
Changed paths:
MM Zend/zend_API.c
MM Zend/zend_API.h
MM Zend/zend_ast.c
MM Zend/zend_ast.h
MM Zend/zend_compile.c
MM Zend/zend_compile.h
MM Zend/zend_execute.c
MM Zend/zend_execute.h
MM Zend/zend_execute_API.c
MM Zend/zend_inheritance..c
MM Zend/zend_language_parser.y
MM Zend/zend_object_handlers.c
MM Zend/zend_types.h
MM Zend/zend_vm_def.h
MM Zend/zend_vm_execute.h
MM ext/opcache/Optimizer/zend_optimizer.c
MM ext/opcache/zend_persist.c
MM ext/reflection/php_reflection.c
MM ext/standard/var.c
Diff:
diff --cc Zend/zend_execute.c
index 1cb0b24,5fb0003..5c74f5f
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@@ -793,97 -770,23 +799,114 @@@ static int zend_verify_internal_arg_typ
return 1;
}
+static inline zend_bool zend_verify_scalar_property_type(zend_uchar type, zval *property,
zend_bool strict) {
+ if (EXPECTED(!strict)) {
+ if (UNEXPECTED(!ZEND_SAME_FAKE_TYPE(type, Z_TYPE_P(property)))) {
+ return zend_verify_weak_scalar_type_hint(type, property);
+ }
+ return 1;
+ }
+
+ if (UNEXPECTED(type == IS_DOUBLE && Z_TYPE_P(property) == IS_LONG)) {
+ double dest = (double) Z_LVAL_P(property);
+ zval_ptr_dtor(property);
+ ZVAL_DOUBLE(property, dest);
+ return 1;
+ }
+
+ return ZEND_SAME_FAKE_TYPE(type, Z_TYPE_P(property));
+}
+
+void zend_verify_property_type_error(zend_property_info *info, zend_string *name, zval *property)
{
+ zend_string *resolved = zend_resolve_property_type(info->type_name, info->ce);
+
+ if (info->type == IS_OBJECT) {
+ zend_throw_exception_ex(zend_ce_type_error, info->type,
+ "Typed property %s::$%s must be an instance of %s, %s used",
+ ZSTR_VAL(info->ce->name),
+ ZSTR_VAL(name),
+ ZSTR_VAL(resolved),
+ Z_TYPE_P(property) == IS_OBJECT ?
+ ZSTR_VAL(Z_OBJCE_P(property)->name) :
+ zend_get_type_by_const(Z_TYPE_P(property)));
+ } else {
+ zend_throw_exception_ex(zend_ce_type_error, info->type,
+ "Typed property %s::$%s must be %s, %s used",
+ ZSTR_VAL(info->ce->name),
+ ZSTR_VAL(name),
+ zend_get_type_by_const(info->type),
+ Z_TYPE_P(property) == IS_OBJECT ?
+ ZSTR_VAL(Z_OBJCE_P(property)->name) :
+ zend_get_type_by_const(Z_TYPE_P(property)));
+ }
+}
+
+zend_bool zend_verify_property_type(zend_property_info *info, zval *property, zend_bool strict) {
+ if (EXPECTED(ZEND_SAME_FAKE_TYPE(info->type, Z_TYPE_P(property)) && Z_TYPE_P(property)
!= IS_OBJECT)) {
+ Z_TYPE_FLAGS_P(property) |= IS_TYPE_VERIFIED;
+ return 1;
+ }
+
+ switch (info->type) {
+ case IS_OBJECT: {
+ zend_string *resolved = zend_resolve_property_type(info->type_name, info->ce);
+
+ if (!info->type_ce) {
+ info->type_ce = zend_lookup_class(resolved);
+ }
+
+ if (!info->type_ce || Z_TYPE_P(property) != IS_OBJECT ||
!instanceof_function(Z_OBJCE_P(property), info->type_ce)) {
+ return 0;
+ }
+
+ Z_TYPE_FLAGS_P(property) |= IS_TYPE_VERIFIED;
+ return 1;
+ }
+
+ case IS_CALLABLE: switch (Z_TYPE_P(property)) {
+ case IS_OBJECT:
+ if (instanceof_function(zend_ce_closure, Z_OBJCE_P(property))) {
+ Z_TYPE_FLAGS_P(property) |= IS_TYPE_VERIFIED;
+ return 1;
+ }
+
+ case IS_STRING:
+ case IS_ARRAY:
+ if (zend_is_callable(property, IS_CALLABLE_CHECK_SILENT, NULL)) {
+ Z_TYPE_FLAGS_P(property) |= IS_TYPE_VERIFIED;
+ return 1;
+ }
+
+ default:
+ return 0;
+ }
+
+ default:
+ if (!zend_verify_scalar_property_type(info->type, property, strict)) {
+ return 0;
+ }
+ Z_TYPE_FLAGS_P(property) |= IS_TYPE_VERIFIED;
+ return 1;
+ }
+}
+
+ static zend_never_inline int zend_verify_internal_arg_types(zend_function *fbc, zend_execute_data
*call)
+ {
+ uint32_t i;
+ uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
+ zval *p = ZEND_CALL_ARG(call, 1);
+
+ for (i = 0; i < num_args; ++i) {
+ if (UNEXPECTED(!zend_verify_internal_arg_type(fbc, i + 1, p))) {
+ EG(current_execute_data) = call->prev_execute_data;
+ zend_vm_stack_free_args(call);
+ return 0;
+ }
+ p++;
+ }
+ return 1;
+ }
+
static zend_always_inline int zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg,
zval *default_value, void **cache_slot)
{
zend_arg_info *cur_arg_info;