cvs: ZendEngine2 / zend_compile.c zend_compile.h /tests bug44414.phpt

[email protected] ("Dmitry Stogov")
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1205315217@cvsserver>
dmitry		Wed Mar 12 09:46:57 2008 UTC

  Modified files:              
    /ZendEngine2	zend_compile.c zend_compile.h 
    /ZendEngine2/tests	bug44414.phpt 
  Log:
  Fixed bug #44414 (Incomplete reporting about abstract methods)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.807&r2=1.808&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.807 ZendEngine2/zend_compile.c:1.808
--- ZendEngine2/zend_compile.c:1.807	Fri Mar  7 00:51:02 2008
+++ ZendEngine2/zend_compile.c	Wed Mar 12 09:46:57 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c,v 1.807 2008/03/07 00:51:02 felipe Exp $ */
+/* $Id: zend_compile.c,v 1.808 2008/03/12 09:46:57 dmitry Exp $ */
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -2803,7 +2803,8 @@
 
 	if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS && ce->type == ZEND_INTERNAL_CLASS) {
 		ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
-	} else {
+	} else if (!(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES)) {
+		/* The verification will be done in runtime by ZEND_VERIFY_ABSTRACT_CLASS */
 		zend_verify_abstract_class(ce TSRMLS_CC);
 	}
 }
@@ -2919,7 +2920,7 @@
 		}
 		return NULL;
 	} else {
-		if (!(ce->ce_flags & ZEND_ACC_INTERFACE)) {
+		if (!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLEMENT_INTERFACES))) {
 			zend_verify_abstract_class(ce TSRMLS_CC);
 		}
 		return ce;
@@ -3478,10 +3479,13 @@
 		}
 	}
 	/* Inherit interfaces; reset number to zero, we need it for above check and
-	 * will restore it during actual implementation. */
+	 * will restore it during actual implementation. 
+	 * The ZEND_ACC_IMPLEMENT_INTERFACES flag disables double call to
+	 * zend_verify_abstract_class() */
 	if (ce->num_interfaces > 0) {
 		ce->interfaces = NULL;
 		ce->num_interfaces = 0;
+		ce->ce_flags |= ZEND_ACC_IMPLEMENT_INTERFACES;
 	}
 	CG(active_class_entry) = NULL;
 }
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.374&r2=1.375&diff_format=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.374 ZendEngine2/zend_compile.h:1.375
--- ZendEngine2/zend_compile.h:1.374	Tue Feb 12 01:02:06 2008
+++ ZendEngine2/zend_compile.h	Wed Mar 12 09:46:57 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.h,v 1.374 2008/02/12 01:02:06 stas Exp $ */
+/* $Id: zend_compile.h,v 1.375 2008/03/12 09:46:57 dmitry Exp $ */
 
 #ifndef ZEND_COMPILE_H
 #define ZEND_COMPILE_H
@@ -147,6 +147,10 @@
 /* deprecation flag */
 #define ZEND_ACC_DEPRECATED 0x40000
 
+/* class implement interface(s) flag */
+#define ZEND_ACC_IMPLEMENT_INTERFACES 0x80000
+
+
 char *zend_visibility_string(zend_uint fn_flags);
 
 
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug44414.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug44414.phpt
diff -u /dev/null ZendEngine2/tests/bug44414.phpt:1.2
--- /dev/null	Wed Mar 12 09:46:57 2008
+++ ZendEngine2/tests/bug44414.phpt	Wed Mar 12 09:46:57 2008
@@ -0,0 +1,15 @@
+--TEST--
+Bug #44414 (incomplete reporting about abstract methods)
+--FILE--
+<?php
+abstract class A {
+  abstract function foo();
+}
+interface B {
+  function bar();
+}
+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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.