--TEST--
-errmsg: cannot change initial value of property
+No more errmsg: can now change initial value of property
--FILE--
<?php
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
--- /dev/null
+--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
--- /dev/null
+--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
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 {
}
class derived extends base {
- static public $prop;
+ static public $prop = 2;
static function show() {
echo __METHOD__ . '(' . self::$prop . ")\n";
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
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