com php-src: Fix some remaining class declaration issues: Zend/tests/bug44414.phpt Zend/zend_compile.c

From: Date: Mon, 21 Jul 2014 16:15:09 +0000
Subject: com php-src: Fix some remaining class declaration issues: Zend/tests/bug44414.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-80963@lists.php.net to get a copy of this message
Commit: 61a6083e99c4f0d836f9488985a35e63a735d703 Author: Nikita Popov <nikic@php.net> Mon, 21 Jul 2014 18:15:09 +0200 Parents: df970e9fc20fa720298d478fd652f1785623793b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=61a6083e99c4f0d836f9488985a35e63a735d703 Log: Fix some remaining class declaration issues Changed paths: M Zend/tests/bug44414.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/bug44414.phpt b/Zend/tests/bug44414.phpt index 1f3a258..e9e6de7 100644 --- a/Zend/tests/bug44414.phpt +++ b/Zend/tests/bug44414.phpt @@ -12,4 +12,4 @@ class C extends A implements B { } ?> --EXPECTF-- -Fatal error: Class C contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (A::foo, B::bar) in %sbug44414.php on line 9 +Fatal error: Class C contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (A::foo, B::bar) in %sbug44414.php on line 8 diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 90316aa..5139a11 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile..c @@ -6673,8 +6673,9 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) { } if (!zend_is_const_default_class_ref(extends_ast)) { + zend_string *extends_name = Z_STR_P(zend_ast_get_zval(extends_ast)); zend_error_noreturn(E_COMPILE_ERROR, - "Cannot use '%s' as class name as it is reserved", name->val); + "Cannot use '%s' as class name as it is reserved", extends_name->val); } zend_compile_class_ref(&extends_node, extends_ast TSRMLS_CC); @@ -6715,7 +6716,27 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) { zend_compile_stmt(stmt_ast TSRMLS_CC); - // TODO.AST validity checks + if (ce->constructor) { + ce->constructor->common.fn_flags |= ZEND_ACC_CTOR; + if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) { + zend_error_noreturn(E_COMPILE_ERROR, "Constructor %s::%s() cannot be static", + ce->name->val, ce->constructor->common.function_name->val); + } + } + if (ce->destructor) { + ce->destructor->common.fn_flags |= ZEND_ACC_DTOR; + if (ce->destructor->common.fn_flags & ZEND_ACC_STATIC) { + zend_error_noreturn(E_COMPILE_ERROR, "Destructor %s::%s() cannot be static", + ce->name->val, ce->destructor->common.function_name->val); + } + } + if (ce->clone) { + ce->clone->common.fn_flags |= ZEND_ACC_CLONE; + if (ce->clone->common.fn_flags & ZEND_ACC_STATIC) { + zend_error_noreturn(E_COMPILE_ERROR, "Clone method %s::%s() cannot be static", + ce->name->val, ce->clone->common.function_name->val); + } + } /* Check for traits and proceed like with interfaces. * The only difference will be a combined handling of them in the end.

« previous php.cvs (#80963) next »