summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/errmsg_024.phpt4
-rw-r--r--Zend/tests/lsb_019.phpt48
-rw-r--r--Zend/tests/lsb_020.phpt48
-rw-r--r--Zend/zend_compile.c12
-rwxr-xr-xext/reflection/tests/static_properties_002.phpt10
-rw-r--r--tests/classes/property_override_protectedStatic_publicStatic.phpt4
6 files changed, 106 insertions, 20 deletions
diff --git a/Zend/tests/errmsg_024.phpt b/Zend/tests/errmsg_024.phpt
index d8d06cbce1..011e6fdea9 100644
--- a/Zend/tests/errmsg_024.phpt
+++ b/Zend/tests/errmsg_024.phpt
@@ -1,5 +1,5 @@
--TEST--
-errmsg: cannot change initial value of property
+No more errmsg: can now change initial value of property
--FILE--
<?php
@@ -14,4 +14,4 @@ class test extends test1 {
echo "Done\n";
?>
--EXPECTF--
-Fatal error: Cannot change initial value of property static protected test1::$var in class test in %s on line %d
+Done
diff --git a/Zend/tests/lsb_019.phpt b/Zend/tests/lsb_019.phpt
new file mode 100644
index 0000000000..f0d2bc28c8
--- /dev/null
+++ b/Zend/tests/lsb_019.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test LSB of properties and methods declared as protected and overridden as public.
+--FILE--
+<?php
+class TestClass {
+ protected static $staticVar;
+
+ protected static function staticFunction() {
+ return 'TestClassFunction';
+ }
+
+ public static function testStaticVar() {
+ TestClass::$staticVar = 'TestClassStatic';
+ ChildClass1::$staticVar = 'ChildClassStatic';
+ return static::$staticVar;
+ }
+
+ public static function testStaticFunction() {
+ return static::staticFunction();
+ }
+}
+
+class ChildClass1 extends TestClass {
+ public static $staticVar;
+
+ public static function staticFunction() {
+ return 'ChildClassFunction';
+ }
+}
+
+class ChildClass2 extends TestClass {}
+
+echo TestClass::testStaticVar() . "\n";
+echo TestClass::testStaticFunction() . "\n";
+
+echo ChildClass1::testStaticVar() . "\n";
+echo ChildClass1::testStaticFunction() . "\n";
+
+echo ChildClass2::testStaticVar() . "\n";
+echo ChildClass2::testStaticFunction() . "\n";
+?>
+--EXPECTF--
+TestClassStatic
+TestClassFunction
+ChildClassStatic
+ChildClassFunction
+TestClassStatic
+TestClassFunction \ No newline at end of file
diff --git a/Zend/tests/lsb_020.phpt b/Zend/tests/lsb_020.phpt
new file mode 100644
index 0000000000..f328b01774
--- /dev/null
+++ b/Zend/tests/lsb_020.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test LSB of properties and methods declared as public and overridden as public.
+--FILE--
+<?php
+class TestClass {
+ public static $staticVar;
+
+ public static function staticFunction() {
+ return 'TestClassFunction';
+ }
+
+ public static function testStaticVar() {
+ TestClass::$staticVar = 'TestClassStatic';
+ ChildClass1::$staticVar = 'ChildClassStatic';
+ return static::$staticVar;
+ }
+
+ public static function testStaticFunction() {
+ return static::staticFunction();
+ }
+}
+
+class ChildClass1 extends TestClass {
+ public static $staticVar;
+
+ public static function staticFunction() {
+ return 'ChildClassFunction';
+ }
+}
+
+class ChildClass2 extends TestClass {}
+
+echo TestClass::testStaticVar() . "\n";
+echo TestClass::testStaticFunction() . "\n";
+
+echo ChildClass1::testStaticVar() . "\n";
+echo ChildClass1::testStaticFunction() . "\n";
+
+echo ChildClass2::testStaticVar() . "\n";
+echo ChildClass2::testStaticFunction() . "\n";
+?>
+--EXPECTF--
+TestClassStatic
+TestClassFunction
+ChildClassStatic
+ChildClassFunction
+TestClassStatic
+TestClassFunction \ No newline at end of file
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index f8b380388d..093a441f87 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2482,18 +2482,6 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
ht = &parent_ce->default_static_members;
}
if (zend_hash_find(ht, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) {
- zval **new_prop;
- if (zend_hash_find(&ce->default_static_members, child_info->name, child_info->name_length+1, (void**)&new_prop) == SUCCESS) {
- if (Z_TYPE_PP(new_prop) != IS_NULL && Z_TYPE_PP(prop) != IS_NULL) {
- char *prop_name, *tmp;
- zend_unmangle_property_name(child_info->name, child_info->name_length, &tmp, &prop_name);
-
- zend_error(E_COMPILE_ERROR, "Cannot change initial value of property static protected %s::$%s in class %s",
- parent_ce->name, prop_name, ce->name);
- }
- }
- Z_ADDREF_PP(prop);
- zend_hash_update(&ce->default_static_members, child_info->name, child_info->name_length+1, (void**)prop, sizeof(zval*), NULL);
zend_hash_del(&ce->default_static_members, prot_name, prot_name_length+1);
}
} else {
diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt
index 051b9fb10e..0713af40c4 100755
--- a/ext/reflection/tests/static_properties_002.phpt
+++ b/ext/reflection/tests/static_properties_002.phpt
@@ -19,7 +19,7 @@ class base {
}
class derived extends base {
- static public $prop;
+ static public $prop = 2;
static function show() {
echo __METHOD__ . '(' . self::$prop . ")\n";
@@ -54,9 +54,9 @@ base::show(2)
derived::show(2)
base::inc()
base::show(3)
-derived::show(3)
+derived::show(2)
derived::inc()
-base::show(4)
-derived::show(4)
+base::show(3)
+derived::show(3)
Number of properties: 1
-Done
+Done \ No newline at end of file
diff --git a/tests/classes/property_override_protectedStatic_publicStatic.phpt b/tests/classes/property_override_protectedStatic_publicStatic.phpt
index 7e1955dd99..e437c5f30f 100644
--- a/tests/classes/property_override_protectedStatic_publicStatic.phpt
+++ b/tests/classes/property_override_protectedStatic_publicStatic.phpt
@@ -27,5 +27,7 @@ Redeclare inherited protected static property as public static.
B::showB();
?>
--EXPECTF--
+A::p (static)
+A::p (static)
+B::p (static)
-Fatal error: Cannot change initial value of property static protected A::$p in class B in %s on line 18