cvs: ZendEngine2(PHP_5_3) / zend_compile.c /tests access_modifiers_001.phpt access_modifiers_002.phpt access_modifiers_003.phpt
access_modifiers_004.phpt access_modifiers_005.phpt access_modifiers_006.phpt access_modifiers_007.phpt

From: Date: Tue, 13 Nov 2007 16:52:14 +0000
Subject: cvs: ZendEngine2(PHP_5_3) / zend_compile.c /tests access_modifiers_001.phpt access_modifiers_002.phpt access_modifiers_003.phpt
access_modifiers_004.phpt access_modifiers_005.phpt access_modifiers_006.phpt access_modifiers_007.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6162@lists.php.net to get a copy of this message
tony2001 Tue Nov 13 16:52:14 2007 UTC Added files: (Branch: PHP_5_3) /ZendEngine2/tests access_modifiers_001.phpt access_modifiers_002.phpt access_modifiers_003.phpt access_modifiers_004.phpt access_modifiers_005.phpt access_modifiers_006.phpt access_modifiers_007.phpt Modified files: /ZendEngine2 zend_compile.c Log: MFH: disallow multiple access modifiers and 'abstract abstract' methods (patch by Etienne Kneuss) add tests http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.20&r2=1.647.2.27.2.41.2.21&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.20 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.21 --- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.20 Mon Nov 12 17:52:15 2007 +++ ZendEngine2/zend_compile.c Tue Nov 13 16:52:13 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.20 2007/11/12 17:52:15 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.21 2007/11/13 16:52:13 tony2001 Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1057,10 +1057,21 @@ int zend_do_verify_access_types(znode *current_access_type, znode *new_modifier) { if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_PPP_MASK) - && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK) - && ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_PPP_MASK) != (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK))) { + && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK)) { zend_error(E_COMPILE_ERROR, "Multiple access type modifiers are not allowed"); } + if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_ABSTRACT) + && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_ABSTRACT)) { + zend_error(E_COMPILE_ERROR, "Multiple abstract modifiers are not allowed"); + } + if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_STATIC) + && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_STATIC)) { + zend_error(E_COMPILE_ERROR, "Multiple static modifiers are not allowed"); + } + if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_FINAL) + && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_FINAL)) { + zend_error(E_COMPILE_ERROR, "Multiple final modifiers are not allowed"); + } if (((Z_LVAL(current_access_type->u.constant) | Z_LVAL(new_modifier->u.constant)) & (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) { zend_error(E_COMPILE_ERROR, "Cannot use the final modifier on an abstract class member"); } http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/access_modifiers_001.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/access_modifiers_001.phpt +++ ZendEngine2/tests/access_modifiers_001.phpt --TEST-- using multiple access modifiers (methods) --FILE-- <?php class test { static public public static final public final function foo() { } } echo "Done\n"; ?> --EXPECTF-- Fatal error: Multiple access type modifiers are not allowed in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/access_modifiers_002.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/access_modifiers_002.phpt +++ ZendEngine2/tests/access_modifiers_002.phpt --TEST-- using multiple access modifiers (attributes) --FILE-- <?php class test { static public public static final public final $var; } echo "Done\n"; ?> --EXPECTF-- Fatal error: Multiple access type modifiers are not allowed in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/access_modifiers_003.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/access_modifiers_003.phpt +++ ZendEngine2/tests/access_modifiers_003.phpt --TEST-- using multiple access modifiers (classes) --FILE-- <?php final final class test { function foo() {} } echo "Done\n"; ?> --EXPECTF-- Parse error: syntax error, unexpected T_FINAL, expecting T_CLASS in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/access_modifiers_004.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/access_modifiers_004.phpt +++ ZendEngine2/tests/access_modifiers_004.phpt --TEST-- using multiple access modifiers (abstract methods) --FILE-- <?php class test { abstract abstract function foo() { } } echo "Done\n"; ?> --EXPECTF-- Fatal error: Multiple abstract modifiers are not allowed in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/access_modifiers_005.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/access_modifiers_005.phpt +++ ZendEngine2/tests/access_modifiers_005.phpt --TEST-- using multiple access modifiers (final methods) --FILE-- <?php class test { final final function foo() { } } echo "Done\n"; ?> --EXPECTF-- Fatal error: Multiple final modifiers are not allowed in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/access_modifiers_006.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/access_modifiers_006.phpt +++ ZendEngine2/tests/access_modifiers_006.phpt --TEST-- using multiple access modifiers (static methods) --FILE-- <?php class test { static static function foo() { } } echo "Done\n"; ?> --EXPECTF-- Fatal error: Multiple static modifiers are not allowed in %s on line %d http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/access_modifiers_007.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/access_modifiers_007.phpt +++ ZendEngine2/tests/access_modifiers_007.phpt --TEST-- abstract final methods errmsg --FILE-- <?php class test { final abstract function foo(); } echo "Done\n"; ?> --EXPECTF-- Fatal error: Cannot use the final modifier on an abstract class member in %s on line %d

« previous php.zend-engine.cvs (#6162) next »