com php-src: changes prompted by review: Zend/tests/type_decl arations/typed_properties_053.phpt Zend/tests/typ
e_declarations/typed_properties_054.phpt Zend/z end.c Zend/zend_ast.c Zend/zend_compile.c Zend/ zend_execute.c

From: Date: Tue, 07 Jun 2016 06:09:21 +0000
Subject: com php-src: changes prompted by review: Zend/tests/type_decl arations/typed_properties_053.phpt Zend/tests/typ
e_declarations/typed_properties_054.phpt Zend/z end.c Zend/zend_ast.c Zend/zend_compile.c Zend/ zend_execute.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95490@lists.php.net to get a copy of this message
Commit: de84f5082a2da6944726e2f7cb3ba73b7f568021 Author: Joe Watkins <krakjoe@php.net> Tue, 7 Jun 2016 07:09:21 +0100 Parents: 3bbe52d3a690b3dbb064a67f8bd0307f00559036 Branches: typed_ref_properties Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=de84f5082a2da6944726e2f7cb3ba73b7f568021 Log: changes prompted by review Changed paths: M Zend/tests/type_declarations/typed_properties_053.phpt M Zend/tests/type_declarations/typed_properties_054.phpt M Zend/zend.c M Zend/zend_ast.c M Zend/zend_compile.c M Zend/zend_execute.c Diff: diff --git a/Zend/tests/type_declarations/typed_properties_053.phpt b/Zend/tests/type_declarations/typed_properties_053.phpt index 6fb2519..45255ef 100644 --- a/Zend/tests/type_declarations/typed_properties_053.phpt +++ b/Zend/tests/type_declarations/typed_properties_053.phpt @@ -4,23 +4,15 @@ Default values of callable properties <?php class A { public callable $a1; - public callable $a2 = "foo"; - public callable $a3 = array("A","bar"); + public callable $a2 = null; } $obj = new A; var_dump($obj); ?> --EXPECT-- -object(A)#1 (2) { +object(A)#1 (1) { ["a1"]=> uninitialized(callable) ["a2"]=> - string(3) "foo" - ["a3"]=> - array(2) { - [0]=> - string(1) "A" - [1]=> - string(3) "bar" - } + NULL } diff --git a/Zend/tests/type_declarations/typed_properties_054.phpt b/Zend/tests/type_declarations/typed_properties_054.phpt index eaef421..e6fbf35 100644 --- a/Zend/tests/type_declarations/typed_properties_054.phpt +++ b/Zend/tests/type_declarations/typed_properties_054.phpt @@ -9,4 +9,4 @@ $obj = new A; var_dump($obj); ?> --EXPECTF-- -Fatal error: Default value for properties with callable type can only be a string or an array in %styped_properties_054.php on line 3 +Fatal error: Default value for properties with callable type can only be null in %styped_properties_054.php on line 3 diff --git a/Zend/zend.c b/Zend/zend.c index cffd8cb..af43cb1 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -785,11 +785,13 @@ static void zend_resolve_property_types(void) /* {{{ */ ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) { if (prop_info->type == IS_OBJECT && prop_info->type_name) { + zend_string *type_name = zend_string_tolower(prop_info->type_name); zend_class_entry *prop_ce = - (zend_class_entry*)zend_hash_find(CG(class_table), prop_info->type_name); + (zend_class_entry*)zend_hash_find_ptr(CG(class_table), type_name); assert(prop_ce && prop_ce->type == ZEND_INTERNAL_CLASS); prop_info->type_ce = prop_ce; + zend_string_release(type_name); } }ZEND_HASH_FOREACH_END(); } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 599ecba..a0f6c19 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1152,7 +1152,7 @@ simple_list: if (type_ast->attr & ZEND_TYPE_NULLABLE) { smart_str_appendc(str, '?'); } - zend_ast_export_name( + zend_ast_export_ns_name( str, type_ast, 0, indent); smart_str_appendc(str, ' '); } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 021b297..70a65a4 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2601,7 +2601,7 @@ static void zend_separate_if_call_and_write(znode *node, zend_ast *ast, uint32_t } /* }}} */ -void zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type, int by_ref); +void zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type, zend_bool by_ref); void zend_compile_assign(znode *result, zend_ast *ast); static void zend_compile_list_assign(znode *result, zend_ast *ast, znode *expr_node, zend_bool old_style); @@ -2735,7 +2735,7 @@ zend_op *zend_compile_static_prop_common(znode *result, zend_ast *ast, uint32_t } if (opline->op1_type == IS_CONST) { convert_to_string(CT_CONSTANT(opline->op1)); - zend_alloc_polymorphic_cache_slots(opline->op1.constant, 2); + zend_alloc_polymorphic_cache_slot(opline->op1.constant); } if (class_node.op_type == IS_CONST) { opline->op2_type = IS_CONST; @@ -5608,7 +5608,7 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast) /* {{{ */ zend_const_expr_to_zval(&value_zv, value_ast); if (optional_type && !Z_CONSTANT(value_zv)) { - if (allow_null && Z_TYPE(value_zv) == IS_NULL) { + if (allow_null && Z_TYPE(value_zv) == IS_NULL) { /* pass */ } else if (optional_type == IS_ARRAY) { if (Z_TYPE(value_zv) != IS_ARRAY) { @@ -5616,9 +5616,9 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast) /* {{{ */ "Default value for properties with array type can only be an array"); } } else if (optional_type == IS_CALLABLE) { - if (Z_TYPE(value_zv) != IS_STRING && Z_TYPE(value_zv) != IS_ARRAY) { + if (Z_TYPE(value_zv) != IS_NULL) { zend_error_noreturn(E_COMPILE_ERROR, - "Default value for properties with callable type can only be a string or an array"); + "Default value for properties with callable type can only be null"); } } else if (optional_type == IS_OBJECT) { zend_error_noreturn(E_COMPILE_ERROR, @@ -5637,11 +5637,8 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast) /* {{{ */ } name = zend_new_interned_string_safe(name); - if (optional_type) { - zend_declare_typed_property(ce, name, &value_zv, flags, doc_comment, optional_type, optional_type_name, allow_null); - } else { - zend_declare_property_ex(ce, name, &value_zv, flags, doc_comment); - } + + zend_declare_typed_property(ce, name, &value_zv, flags, doc_comment, optional_type, optional_type_name, allow_null); } } /* }}} */ @@ -7980,7 +7977,7 @@ void zend_compile_var(znode *result, zend_ast *ast, uint32_t type, int by_ref) / } /* }}} */ -void zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type, int by_ref) /* {{{ */ +void zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type, zend_bool by_ref) /* {{{ */ { zend_op *opline; switch (ast->kind) { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 81f6d02..b10f969 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -701,7 +701,7 @@ static zend_bool zend_verify_weak_scalar_type_hint(zend_uchar type_hint, zval *a if (arg != ret) { ZVAL_COPY(ret, arg); - /* on success "arg" is converted to IS_STRING */ + /* on success "ret" is converted to IS_STRING */ if (!zend_parse_arg_str_weak(ret, &dest)) { zval_ptr_dtor(ret); return 0; @@ -709,7 +709,7 @@ static zend_bool zend_verify_weak_scalar_type_hint(zend_uchar type_hint, zval *a zval_ptr_dtor(arg); return 1; } - /* on success "arg" is converted to IS_STRING */ + /* on success "ret" is converted to IS_STRING */ if (!zend_parse_arg_str_weak(ret, &dest)) { return 0; }

« previous php.cvs (#95490) next »