#43323 [Asn->Csd]: Wrong count abstract methods

From: Date: Tue, 29 Jan 2008 11:14:04 +0000
Subject: #43323 [Asn->Csd]: Wrong count abstract methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121721@lists.php.net to get a copy of this message
ID: 43323 Updated by: dmitry@php.net Reported By: felipensp at gmail dot com -Status: Assigned +Status: Closed Bug Type: Scripting Engine problem PHP Version: 5.3 Assigned To: dmitry New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2008-01-18 10:44:05] felipe@php.net It also occur in PHP 5.3. (Ugly?) patch: Index: Zend/zend_execute_API.c =================================================================== RCS file: /repository/ZendEngine2/zend_execute_API.c,v retrieving revision 1.331.2.20.2.24.2.19 diff -u -u -r1.331.2.20.2.24.2.19 zend_execute_API.c --- Zend/zend_execute_API.c 15 Jan 2008 11:47:05 -0000 1.331.2.20.2.24.2.19 +++ Zend/zend_execute_API.c 18 Jan 2008 10:32:51 -0000 @@ -1649,15 +1649,21 @@ typedef struct _zend_abstract_info { zend_function *afn[MAX_ABSTRACT_INFO_CNT + 1]; int cnt; + int ctor; } zend_abstract_info; static int zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai TSRMLS_DC) /* {{{ */ { if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) { - if (ai->cnt < MAX_ABSTRACT_INFO_CNT) { + if (ai->cnt < MAX_ABSTRACT_INFO_CNT && ((fn->common.fn_flags & ZEND_ACC_CTOR) == 0 || ai->ctor < 1)) { ai->afn[ai->cnt] = fn; } - ai->cnt++; + if (!ai->ctor || !(fn->common.fn_flags & ZEND_ACC_CTOR)) { + ai->cnt++; + } + if (!ai->ctor && fn->common.fn_flags & ZEND_ACC_CTOR) { + ai->ctor = 1; + } } return 0; } ------------------------------------------------------------------------ [2007-11-18 13:42:05] felipensp at gmail dot com Description: ------------ Wrong count abstract methods when name of method is same class name. When used the same code with namespace, the count is correct. Reproduce code: --------------- <?php // namespace foo; # The count is correct abstract class bar { abstract public function bar(); } class foo extends bar { } Expected result: ---------------- Fatal error: Class foo contains 1 abstract methods and must therefore be declared abstract or implement the remaining methods (bar::bar) Actual result: -------------- Fatal error: Class foo contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (bar::bar, bar::bar) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43323&edit=1

« previous php.bugs (#121721) next »