robinf Mon Mar 3 14:24:11 2008 UTC
Added files:
/ZendEngine2/tests lsb_020.phpt lsb_019.phpt
Modified files:
/ZendEngine2/tests errmsg_024.phpt
/ZendEngine2 zend_compile.c
/php-src/ext/reflection/tests static_properties_002.phpt
/php-src/tests/classes
property_override_protectedStatic_publicStatic.phpt
Log:
Remove inconsistent behaviour when a protected static prop is overridden by
public static prop (details: http://turl.ca/phhhf ).
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/errmsg_024.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/errmsg_024.phpt
diff -u ZendEngine2/tests/errmsg_024.phpt:1.1
ZendEngine2/tests/errmsg_024.phpt:1.2
--- ZendEngine2/tests/errmsg_024.phpt:1.1 Fri Feb 2 12:53:54 2007
+++ ZendEngine2/tests/errmsg_024.phpt Mon Mar 3 14:24:11 2008
@@ -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 @@
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
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.805&r2=1.806&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.805 ZendEngine2/zend_compile.c:1.806
--- ZendEngine2/zend_compile.c:1.805 Sat Mar 1 13:53:10 2008
+++ ZendEngine2/zend_compile.c Mon Mar 3 14:24:11 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.805 2008/03/01 13:53:10 johannes Exp $ */
+/* $Id: zend_compile.c,v 1.806 2008/03/03 14:24:11 robinf Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -2696,18 +2696,6 @@
ht = &parent_ce->default_static_members;
}
if (zend_u_hash_find(ht, utype, prot_name,
prot_name_length+1, (void**)&prop) == SUCCESS) {
- zval **new_prop;
- if
(zend_u_hash_find(&ce->default_static_members, utype, 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) {
- zstr prop_name, tmp;
-
-
zend_u_unmangle_property_name(utype, child_info->name, child_info->name_length,
&tmp, &prop_name);
-
zend_error(E_COMPILE_ERROR, "Cannot change initial value of property static
protected %v::$%v in class %v",
-
parent_ce->name, prop_name, ce->name);
- }
- }
- Z_ADDREF_PP(prop);
-
zend_u_hash_update(&ce->default_static_members, utype, child_info->name,
child_info->name_length+1, (void**)prop, sizeof(zval*), NULL);
zend_u_hash_del(&ce->default_static_members, utype, prot_name,
prot_name_length+1);
}
} else {
@@ -5674,3 +5662,4 @@
* indent-tabs-mode: t
* End:
*/
+
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/static_properties_002.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/reflection/tests/static_properties_002.phpt
diff -u php-src/ext/reflection/tests/static_properties_002.phpt:1.3
php-src/ext/reflection/tests/static_properties_002.phpt:1.4
--- php-src/ext/reflection/tests/static_properties_002.phpt:1.3 Sun Mar 12
12:11:22 2006
+++ php-src/ext/reflection/tests/static_properties_002.phpt Mon Mar 3
14:24:11 2008
@@ -19,7 +19,7 @@
}
class derived extends base {
- static public $prop;
+ static public $prop = 2;
static function show() {
echo __METHOD__ . '(' . self::$prop . ")\n";
@@ -54,9 +54,9 @@
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
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/property_override_protectedStatic_publicStatic.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/tests/classes/property_override_protectedStatic_publicStatic.phpt
diff -u
php-src/tests/classes/property_override_protectedStatic_publicStatic.phpt:1.2
php-src/tests/classes/property_override_protectedStatic_publicStatic.phpt:1.3
---
php-src/tests/classes/property_override_protectedStatic_publicStatic.phpt:1.2
Wed Jan 30 14:29:18 2008
+++ php-src/tests/classes/property_override_protectedStatic_publicStatic.phpt
Mon Mar 3 14:24:11 2008
@@ -27,5 +27,7 @@
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
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/lsb_020.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/lsb_020.phpt
+++ ZendEngine2/tests/lsb_020.phpt
--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
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/lsb_019.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/lsb_019.phpt
+++ ZendEngine2/tests/lsb_019.phpt
--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
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php