Bug #72755 [Nab]: Signature mismatch during inheritance

From: Date: Fri, 05 Aug 2016 07:53:07 +0000
Subject: Bug #72755 [Nab]: Signature mismatch during inheritance
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202944@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 User updated by: pawzar at gmail dot com Reported by: pawzar at gmail dot com Summary: Signature mismatch during inheritance 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: cmb Block user comment: N Private report: N New Comment: The examle does not break the Liskov substitution principle. Please note, that the only difference between RedLight and BlueLight classes is "implements SomeInterface". So where it the logic in that? Previous Comments: ------------------------------------------------------------------------ [2016-08-04 13:31:36] cmb@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#202944) next »