com php-src: Remove bad checks for simple property inheritance: Zend/tests/type_declarations/typed_properties_060 .phpt Zend/zend_inheritance.c
| From: | Bob Weinand | Date: | Sat, 28 May 2016 16:39:33 +0000 |
| Subject: | com php-src: Remove bad checks for simple property inheritance: Zend/tests/type_declarations/typed_properties_060 .phpt Zend/zend_inheritance.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95496@lists.php.net to get a copy of this message | ||
Commit: cc19dc51dc83b184b580da6a3421b8fbaa0022ba
Author: Bob Weinand <bobwei9@hotmail.com> Sat, 28 May 2016 18:39:33 +0200
Parents: 03e7112bf477ae2a439ef02aa2120eba80500a9c
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cc19dc51dc83b184b580da6a3421b8fbaa0022ba
Log:
Remove bad checks for simple property inheritance
Changed paths:
A Zend/tests/type_declarations/typed_properties_060.phpt
M Zend/zend_inheritance.c
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_060.phpt
b/Zend/tests/type_declarations/typed_properties_060.phpt
new file mode 100644
index 0000000..b1d16bd
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_060.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test typed properties work fine with simple inheritance
+--FILE--
+<?php
+
+class A {
+ public int $a = 1;
+}
+class B extends A {}
+
+$o = new B;
+var_dump($o->a);
+$o->a = "a";
+
+?>
+--EXPECTF--
+int(1)
+
+Fatal error: Uncaught TypeError: Typed property A::$a must be integer, string used in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
+
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index da23431..0b82707 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -741,26 +741,6 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string
*ke
}
}
} else {
- if (UNEXPECTED(parent_info->type && !(parent_info->flags & ZEND_ACC_PRIVATE)))
{
- if (parent_info->type == IS_OBJECT) {
- zend_error_noreturn(E_COMPILE_ERROR,
- "Type of %s::$%s must be %s%s (as in class %s)",
- ZSTR_VAL(ce->name),
- ZSTR_VAL(key),
- parent_info->allow_null ? "?" : "",
- ZSTR_VAL(zend_resolve_property_type(parent_info->type_name, parent_info->ce)),
- ZSTR_VAL(ce->parent->name));
- } else {
- zend_error_noreturn(E_COMPILE_ERROR,
- "Type of %s::$%s must be %s%s (as in class %s)",
- ZSTR_VAL(ce->name),
- ZSTR_VAL(key),
- parent_info->allow_null ? "?" : "",
- zend_get_type_by_const(parent_info->type),
- ZSTR_VAL(ce->parent->name));
- }
- }
-
if (UNEXPECTED(parent_info->flags & (ZEND_ACC_PRIVATE|ZEND_ACC_SHADOW))) {
if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) {
child_info = zend_duplicate_property_info_internal(parent_info);