|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-11-18 13:42 UTC] 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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 08:00:01 2025 UTC |
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; }