Bug #72755 [Opn->Nab]: Signature mismatch during inheritance
| From: | cmb@php.net | Date: | Thu, 04 Aug 2016 13:31:37 +0000 |
| Subject: | Bug #72755 [Opn->Nab]: Signature mismatch during inheritance | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202928@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72755&edit=1
ID: 72755
Updated by: cmb@php.net
Reported by: pawzar at gmail dot com
Summary: Signature mismatch during inheritance
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Linux 4.4.0-31-generic
PHP Version: 5.6.24
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
PHP does not support covariant parameter types. For now only
invariant parameter types are supported (i.e. the parameter types
of overriden methods must be identical to the inherited methods).
Sometime, contravariant parameter types might be supported, but
most likely never covariant parameter types, as these break the
Liskov substitution principle.
Previous Comments:
------------------------------------------------------------------------
[2016-08-04 13:11:14] pawzar at gmail dot com
Description:
------------
I am trying to adjst some code to E_STRICT standards but I am getting a "Signature mismatch
during inheritance" error, when it seems that there sould be none.
What is more bizarre is that this error only occurs when I am trying to implement SomeInterface in
the extendig class.
Test script:
---------------
interface SomeInterface
{
}
abstract class FooClass
{
}
abstract class FooBarClass extends FooClass
{
}
abstract class LightAbstract
{
public function returnArgument(FooClass $arg)
{
return $arg;
}
}
// OK
class RedLight extends LightAbstract
{
public function returnArgument(FooBarClass $arg)
{
return parent::returnArgument($arg);
}
}
// Outputs an error (E_STRICT)
class BlueLight extends LightAbstract implements SomeInterface
{
public function returnArgument(FooBarClass $arg)
{
return parent::returnArgument($arg);
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72755&edit=1