felipe                                   Sat, 19 Nov 2011 13:36:03 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=319548

Log:
- Fixed bug #43200 (Interface implementation / inheritence not possible in 
abstract classes)

Bug: https://bugs.php.net/43200 (Closed) Interface implementation / inheritence 
not possible in abstract classes
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    A   php/php-src/branches/PHP_5_3/Zend/tests/bug43200.phpt
    A   php/php-src/branches/PHP_5_3/Zend/tests/bug43200_2.phpt
    U   php/php-src/branches/PHP_5_3/Zend/zend_compile.c
    U   php/php-src/branches/PHP_5_4/NEWS
    A   php/php-src/branches/PHP_5_4/Zend/tests/bug43200.phpt
    A   php/php-src/branches/PHP_5_4/Zend/tests/bug43200_2.phpt
    U   php/php-src/branches/PHP_5_4/Zend/zend_compile.c
    A   php/php-src/trunk/Zend/tests/bug43200.phpt
    A   php/php-src/trunk/Zend/tests/bug43200_2.phpt
    U   php/php-src/trunk/Zend/zend_compile.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2011-11-19 13:23:16 UTC (rev 319547)
+++ php/php-src/branches/PHP_5_3/NEWS	2011-11-19 13:36:03 UTC (rev 319548)
@@ -10,6 +10,10 @@
     (klightspeed at netspace dot net dot au)
   . Fixed bug #52624 (tempnam() by-pass open_basedir with nonnexistent
     directory). (Felipe)
+
+- Zend Engine:
+  . Fixed bug #43200 (Interface implementation / inheritence not possible in
+    abstract classes). (Felipe)

 - PHP-FPM SAPI:
   . Fixed bug #60179 (php_flag and php_value does not work properly). (fat)

Added: php/php-src/branches/PHP_5_3/Zend/tests/bug43200.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug43200.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug43200.phpt	2011-11-19 13:36:03 UTC (rev 319548)
@@ -0,0 +1,51 @@
+--TEST--
+Bug #43200 (Interface implementation / inheritence not possible in abstract classes)
+--FILE--
+<?php
+
+interface a {
+	function foo();
+	function bar();
+}
+interface b {
+	function foo();
+}
+
+abstract class c {
+	function bar() { }
+}
+
+class x extends c implements a, b {
+	function foo() { }
+}
+
+ReflectionClass::export('x');
+
+?>
+--EXPECTF--
+Class [ <user> class x extends c implements a, b ] {
+  @@ %s 15-17
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Methods [2] {
+    Method [ <user, prototype b> public method foo ] {
+      @@ %s 16 - 16
+    }
+
+    Method [ <user, inherits c, prototype a> public method bar ] {
+      @@ %s 12 - 12
+    }
+  }
+}
+

Added: php/php-src/branches/PHP_5_3/Zend/tests/bug43200_2.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug43200_2.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug43200_2.phpt	2011-11-19 13:36:03 UTC (rev 319548)
@@ -0,0 +1,25 @@
+--TEST--
+Bug #43200.2 (Interface implementation / inheritence not possible in abstract classes)
+--FILE--
+<?php
+
+interface A {
+	function foo();
+}
+
+abstract class B implements A {
+	abstract public function foo();
+}
+
+class C extends B {
+	public function foo() {
+		echo 'works';
+	}
+}
+
+$o = new C();
+$o->foo();
+
+?>
+--EXPECTF--
+works

Modified: php/php-src/branches/PHP_5_3/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_compile.c	2011-11-19 13:23:16 UTC (rev 319547)
+++ php/php-src/branches/PHP_5_3/Zend/zend_compile.c	2011-11-19 13:36:03 UTC (rev 319548)
@@ -2628,7 +2628,8 @@
 		return 1; /* method doesn't exist in child, copy from parent */
 	}

-	if (parent->common.fn_flags & ZEND_ACC_ABSTRACT
+	if ((parent->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
+		&& parent->common.fn_flags & ZEND_ACC_ABSTRACT
 		&& parent->common.scope != (child->common.prototype ? child->common.prototype->common.scope : child->common.scope)
 		&& child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) {
 		zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)",

Modified: php/php-src/branches/PHP_5_4/NEWS
===================================================================
--- php/php-src/branches/PHP_5_4/NEWS	2011-11-19 13:23:16 UTC (rev 319547)
+++ php/php-src/branches/PHP_5_4/NEWS	2011-11-19 13:36:03 UTC (rev 319548)
@@ -13,6 +13,10 @@
   . Fixed bug #55748 (multiple NULL Pointer Dereference with zend_strndup())
     (CVE-2011-4153). (Stas)

+- Zend Engine:
+  . Fixed bug #43200 (Interface implementation / inheritence not possible in
+    abstract classes). (Felipe)
+
 - MS SQL:
   . Fixed bug #60267 (Compile failure with freetds 0.91). (Felipe)


Added: php/php-src/branches/PHP_5_4/Zend/tests/bug43200.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug43200.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug43200.phpt	2011-11-19 13:36:03 UTC (rev 319548)
@@ -0,0 +1,51 @@
+--TEST--
+Bug #43200 (Interface implementation / inheritence not possible in abstract classes)
+--FILE--
+<?php
+
+interface a {
+	function foo();
+	function bar();
+}
+interface b {
+	function foo();
+}
+
+abstract class c {
+	function bar() { }
+}
+
+class x extends c implements a, b {
+	function foo() { }
+}
+
+ReflectionClass::export('x');
+
+?>
+--EXPECTF--
+Class [ <user> class x extends c implements a, b ] {
+  @@ %s 15-17
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Methods [2] {
+    Method [ <user, prototype b> public method foo ] {
+      @@ %s 16 - 16
+    }
+
+    Method [ <user, inherits c, prototype a> public method bar ] {
+      @@ %s 12 - 12
+    }
+  }
+}
+

Added: php/php-src/branches/PHP_5_4/Zend/tests/bug43200_2.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug43200_2.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug43200_2.phpt	2011-11-19 13:36:03 UTC (rev 319548)
@@ -0,0 +1,25 @@
+--TEST--
+Bug #43200.2 (Interface implementation / inheritence not possible in abstract classes)
+--FILE--
+<?php
+
+interface A {
+	function foo();
+}
+
+abstract class B implements A {
+	abstract public function foo();
+}
+
+class C extends B {
+	public function foo() {
+		echo 'works';
+	}
+}
+
+$o = new C();
+$o->foo();
+
+?>
+--EXPECTF--
+works

Modified: php/php-src/branches/PHP_5_4/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend_compile.c	2011-11-19 13:23:16 UTC (rev 319547)
+++ php/php-src/branches/PHP_5_4/Zend/zend_compile.c	2011-11-19 13:36:03 UTC (rev 319548)
@@ -3173,7 +3173,8 @@
 	zend_uint child_flags;
 	zend_uint parent_flags = parent->common.fn_flags;

-	if (parent->common.fn_flags & ZEND_ACC_ABSTRACT
+	if ((parent->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
+		&& parent->common.fn_flags & ZEND_ACC_ABSTRACT
 		&& parent->common.scope != (child->common.prototype ? child->common.prototype->common.scope : child->common.scope)
 		&& child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) {
 		zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)",

Added: php/php-src/trunk/Zend/tests/bug43200.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug43200.phpt	                        (rev 0)
+++ php/php-src/trunk/Zend/tests/bug43200.phpt	2011-11-19 13:36:03 UTC (rev 319548)
@@ -0,0 +1,51 @@
+--TEST--
+Bug #43200 (Interface implementation / inheritence not possible in abstract classes)
+--FILE--
+<?php
+
+interface a {
+	function foo();
+	function bar();
+}
+interface b {
+	function foo();
+}
+
+abstract class c {
+	function bar() { }
+}
+
+class x extends c implements a, b {
+	function foo() { }
+}
+
+ReflectionClass::export('x');
+
+?>
+--EXPECTF--
+Class [ <user> class x extends c implements a, b ] {
+  @@ %s 15-17
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Methods [2] {
+    Method [ <user, prototype b> public method foo ] {
+      @@ %s 16 - 16
+    }
+
+    Method [ <user, inherits c, prototype a> public method bar ] {
+      @@ %s 12 - 12
+    }
+  }
+}
+

Added: php/php-src/trunk/Zend/tests/bug43200_2.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug43200_2.phpt	                        (rev 0)
+++ php/php-src/trunk/Zend/tests/bug43200_2.phpt	2011-11-19 13:36:03 UTC (rev 319548)
@@ -0,0 +1,25 @@
+--TEST--
+Bug #43200.2 (Interface implementation / inheritence not possible in abstract classes)
+--FILE--
+<?php
+
+interface A {
+	function foo();
+}
+
+abstract class B implements A {
+	abstract public function foo();
+}
+
+class C extends B {
+	public function foo() {
+		echo 'works';
+	}
+}
+
+$o = new C();
+$o->foo();
+
+?>
+--EXPECTF--
+works

Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c	2011-11-19 13:23:16 UTC (rev 319547)
+++ php/php-src/trunk/Zend/zend_compile.c	2011-11-19 13:36:03 UTC (rev 319548)
@@ -3173,7 +3173,8 @@
 	zend_uint child_flags;
 	zend_uint parent_flags = parent->common.fn_flags;

-	if (parent->common.fn_flags & ZEND_ACC_ABSTRACT
+	if ((parent->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
+		&& parent->common.fn_flags & ZEND_ACC_ABSTRACT
 		&& parent->common.scope != (child->common.prototype ? child->common.prototype->common.scope : child->common.scope)
 		&& child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) {
 		zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)",
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to