RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c php-src/tests/classes ctor_in_interface_01.phpt ctor_in_interface_02.phpt
ctor_in_interface_03.phpt ctor_in_interface_04.phpt interface_construct.phpt

From: Date: Mon, 06 Mar 2006 07:29:50 +0000
Subject: RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c php-src/tests/classes ctor_in_interface_01.phpt ctor_in_interface_02.phpt
ctor_in_interface_03.phpt ctor_in_interface_04.phpt interface_construct.phpt
References: 1  Groups: php.zend-engine.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Marcus,

Is it your answer to my "break label" patch? :(

I didn't see final PDM's decision about constructor in interfaces.
And I didn't see any discussion about this, however may be I missed it.

The question about constructors in interfaces is not simple, and both points
of view make sense.
So I would like to see your and others arguments?

Thanks. Dmitry.


> -----Original Message-----
> From: Marcus Boerger [mailto:[email protected]] 
> Sent: Sunday, March 05, 2006 9:24 PM
> To: [email protected]
> Subject: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c 
> php-src/tests/classes ctor_in_interface_01.phpt 
> ctor_in_interface_02.phpt ctor_in_interface_03.phpt 
> ctor_in_interface_04.phpt interface_construct.phpt 
> 
> 
> helly		Sun Mar  5 18:23:56 2006 UTC
> 
>   Added files:                 
>     /php-src/tests/classes	ctor_in_interface_01.phpt 
>                           	ctor_in_interface_02.phpt 
>                           	ctor_in_interface_03.phpt 
>                           	ctor_in_interface_04.phpt 
> 
>   Removed files:               
>     /php-src/tests/classes	interface_construct.phpt 
> 
>   Modified files:              
>     /ZendEngine2	zend_compile.c 
>   Log:
>   - Fix Bug #34019 by popular demand: Implementing interface with a 
>     __construct method strange behaviour 
>   
>   
> http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_compile.c?r1=1
> .689&r2=1.690&diff_format=u
> Index: ZendEngine2/zend_compile.c
> diff -u ZendEngine2/zend_compile.c:1.689 
> ZendEngine2/zend_compile.c:1.690
> --- ZendEngine2/zend_compile.c:1.689	Fri Mar  3 13:09:13 2006
> +++ ZendEngine2/zend_compile.c	Sun Mar  5 18:23:56 2006
> @@ -17,7 +17,7 @@
>     
> +-------------------------------------------------------------
> ---------+
>  */
>  
> -/* $Id: zend_compile.c,v 1.689 2006/03/03 13:09:13 dmitry Exp $ */
> +/* $Id: zend_compile.c,v 1.690 2006/03/05 18:23:56 helly Exp $ */
>  
>  #include <zend_language_parser.h>
>  #include "zend.h"
> @@ -2055,7 +2055,7 @@
>  	}
>  
>  	/* No implementation checks for constructors */
> -	if (fe->common.fn_flags & ZEND_ACC_CTOR) {
> +	if ((fe->common.fn_flags & ZEND_ACC_CTOR) && 
> +!(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) {
>  		return 1;
>  	}
>  
> 
> http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/ctor_in_i
> nterface_01.phpt?view=markup&rev=1.1
> Index: php-src/tests/classes/ctor_in_interface_01.phpt
> +++ php-src/tests/classes/ctor_in_interface_01.phpt
> --TEST--
> ZE2 A class constructor must keep the signature of an interface
> --FILE--
> <?php
> interface constr
> {
> 	function __construct();
> }
> 
> class implem implements constr
> {
> 	function __construct($a)
> 	{
> 	}
> }
> 
> ?>
> --EXPECTF--
> Fatal error: Declaration of implem::__construct() must be 
> compatible with that of constr::__construct() in %s on line %d
> 
> http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/ctor_in_i
> nterface_02.phpt?view=markup&rev=1.1
> Index: php-src/tests/classes/ctor_in_interface_02.phpt
> +++ php-src/tests/classes/ctor_in_interface_02.phpt
> --TEST--
> ZE2 A class constructor must keep the signature of all interfaces
> --FILE--
> <?php
> interface constr1
> {
> 	function __construct();
> }
> 
> interface constr2 extends constr1
> {
> }
> 
> class implem12 implements constr2
> {
> 	function __construct()
> 	{
> 	}
> }
> 
> interface constr3
> {
> 	function __construct($a);
> }
> 
> class implem13 implements constr1, constr3
> {
> 	function __construct()
> 	{
> 	}
> }
> 
> ?>
> --EXPECTF--
> Fatal error: Can't inherit abstract function 
> constr3::__construct() (previously declared abstract in 
> constr1) in %s on line %d
> 
> http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/ctor_in_i
> nterface_03.phpt?view=markup&rev=1.1
> Index: php-src/tests/classes/ctor_in_interface_03.phpt
> +++ php-src/tests/classes/ctor_in_interface_03.phpt
> --TEST--
> ZE2 A class constructor must keep the signature of base class 
> interfaces
> --FILE--
> <?php
> interface constr
> {
> 	function __construct();
> }
> 
> abstract class implem implements constr
> {
> }
> 
> class derived extends implem
> {
> 	function __construct($a)
> 	{
> 	}
> }
> 
> ?>
> --EXPECTF--
> Fatal error: Declaration of derived::__construct() must be 
> compatible with that of constr::__construct() in %s on line %d
> 
> http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/ctor_in_i
nterface_04.phpt?view=markup&rev=1.1
Index: php-src/tests/classes/ctor_in_interface_04.phpt
+++ php-src/tests/classes/ctor_in_interface_04.phpt
--TEST--
ZE2 A class constructor must keep the signature of base class interfaces
--FILE--
<?php
interface constr
{
	function __construct();
}

class implem implements constr
{
	function __construct()
	{
	}
}

class derived extends implem
{
	function __construct($a)
	{
	}
}

?>
--EXPECTF--
Fatal error: Declaration of derived::__construct() must be compatible with
that of constr::__construct() in %s on line %d

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Thread (15 messages)

« previous php.zend-engine.cvs (#4677) next »