return 1;
}
- /* No implementation checks for constructors */
- if (fe->common.fn_flags & ZEND_ACC_CTOR) {
+ /* Checks for constructors only if they are declared in an interface */
+ if ((fe->common.fn_flags & ZEND_ACC_CTOR) && !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) {
return 1;
}
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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