Bug #52301 [Opn->Bgs]: signature incompatibility warning when used with interfaces

From: Date: Fri, 09 Jul 2010 15:53:23 +0000
Subject: Bug #52301 [Opn->Bgs]: signature incompatibility warning when used with interfaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-152245@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52301&edit=1

 ID:               52301
 Updated by:       johannes@php.net
 Reported by:      giorgio dot liscio at email dot it
 Summary:          signature incompatibility warning when used with
                   interfaces
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          Class/Object related
 Operating System: all
 PHP Version:      5.3.2

 New Comment:

class MyClass implements A {}
new X_BASED(new MyClass);

won't be accepted while X says MyClass would be valid as a constructor
Parameter -> contract not fullfilled. So PHP's error is correct.


Previous Comments:
------------------------------------------------------------------------
[2010-07-09 17:23:24] giorgio dot liscio at email dot it

Description:
------------
hi, test this:

interface A {}
interface X { public function __construct(A $x); }

class A_BASED implements A {}
class X_BASED implements X { public function __construct(A_BASED $x){}
}


interface X says that the first parameter of the constructor must be
instanceof A

X_BASED implementation has a constructor with first parameter A_BASED

so, this warning is not correct:

Fatal error: Declaration of X_BASED::__construct() must be compatible
with that of X::__construct()

because

"A_BASED implements A"



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52301&edit=1


Thread (7 messages)

« previous php.bugs (#152245) next »