com php-src: Respect also immutable values: Zend/tests/type_d eclarations/typed_properties_027.phpt Zend/tests/
type_declarations/typed_properties_041.phpt Zen d/zend_object_handlers.c

From: Date: Tue, 24 May 2016 11:10:00 +0000
Subject: com php-src: Respect also immutable values: Zend/tests/type_d eclarations/typed_properties_027.phpt Zend/tests/
type_declarations/typed_properties_041.phpt Zen d/zend_object_handlers.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95547@lists.php.net to get a copy of this message
Commit: e5f9ada308a1c2c75bf0a2487740b4d945b42e07 Author: Bob Weinand <bobwei9@hotmail.com> Tue, 24 May 2016 13:10:00 +0200 Parents: 758076ab0c6e789b2ae54ae486edf421ca83ab25 Branches: typed_ref_properties Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e5f9ada308a1c2c75bf0a2487740b4d945b42e07 Log: Respect also immutable values Changed paths: M Zend/tests/type_declarations/typed_properties_027.phpt A Zend/tests/type_declarations/typed_properties_041.phpt M Zend/zend_object_handlers.c Diff: diff --git a/Zend/tests/type_declarations/typed_properties_027.phpt b/Zend/tests/type_declarations/typed_properties_027.phpt index f8cea4c..03ce2f1 100644 --- a/Zend/tests/type_declarations/typed_properties_027.phpt +++ b/Zend/tests/type_declarations/typed_properties_027.phpt @@ -2,8 +2,8 @@ Test typed properties float widen at runtime --FILE-- <?php -class Foo { +class Foo { public float $bar = 1.1; } diff --git a/Zend/tests/type_declarations/typed_properties_041.phpt b/Zend/tests/type_declarations/typed_properties_041.phpt new file mode 100644 index 0000000..8e8c856 --- /dev/null +++ b/Zend/tests/type_declarations/typed_properties_041.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test typed properties weak conversion of strings +--FILE-- +<?php + +class Foo { + public int $bar = 1; +} + +$foo = new Foo; +$foo->bar = "10"; + +var_dump($foo->bar); +?> +--EXPECTF-- +int(10) + + + + + + + diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index a7c1414..ffe2efe 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -761,7 +761,7 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v zval val; found: if (UNEXPECTED(prop_info = zend_object_fetch_property_type_info_ex(object, Z_STR_P(member), cache_slot))) { - if (!Z_REFCOUNTED_P(value) || Z_REFCOUNT_P(value) > 1) { + if (!Z_REFCOUNTED_P(value) || Z_IMMUTABLE_P(value) || Z_REFCOUNT_P(value) > 1) { ZVAL_COPY_VALUE(&val, value); value = &val; } @@ -823,7 +823,7 @@ write_std_property: zend_property_info *prop_info; zval val; if (cache_slot ? UNEXPECTED(prop_info = (zend_property_info *) CACHED_PTR_EX(cache_slot + 2)) : UNEXPECTED(prop_info = zend_object_fetch_property_type_info_ex(object, Z_STR_P(member), NULL))) { - if (!Z_REFCOUNTED_P(value) || Z_REFCOUNT_P(value) > 1) { + if (!Z_REFCOUNTED_P(value) || Z_IMMUTABLE_P(value) || Z_REFCOUNT_P(value) > 1) { ZVAL_COPY_VALUE(&val, value); value = &val; }

« previous php.cvs (#95547) next »