#42439 [Bgs->Opn]: Derivating a method in a class that implements an interface that declares it
| From: | romain dot tartiere at healthgrid dot org | Date: | Wed, 29 Aug 2007 14:05:01 +0000 |
| Subject: | #42439 [Bgs->Opn]: Derivating a method in a class that implements an interface that declares it | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116824@lists.php.net to get a copy of this message | ||
ID: 42439
User updated by: romain dot tartiere at healthgrid dot org
Reported By: romain dot tartiere at healthgrid dot org
-Status: Bogus
+Status: Open
Bug Type: Class/Object related
Operating System: GNU/Linux
PHP Version: 5.2.3
New Comment:
Reopen bug since it seems to have been closed too quickly.
Previous Comments:
------------------------------------------------------------------------
[2007-08-27 12:43:04] romain dot tartiere at healthgrid dot org
Thank you for your personalised answer and taking time to read and
understand my bug report.
This is obviously a bug. A class method prototype does not have to
comply with an interface method prototype if this class does not
implements this interface.
This is a regression: everything was OK with PHP 5.0.
Thank you to take this bug report into account.
------------------------------------------------------------------------
[2007-08-27 10:24:59] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2007-08-27 09:35:06] romain dot tartiere at healthgrid dot org
Description:
------------
Considering a class that implements an interface and has methods that
require many arguments. You may expect to make your life easier
derivating this class and providing simpler methods.
Reproduce code:
---------------
<?php
interface i_foo {
function fooize($str, $n);
}
class c_foo implements i_foo { /* painful ($class->fooize($str, $n))
*/
function fooize($str, $n) {
echo "$str $n\n";
}
}
class c_bar extends c_foo {
function fooize($str) { /* simple ($class->fooize($str)) */
$n = strlen($str);
parent::fooize($str, $n);
}
}
?>
Expected result:
----------------
This should not pose any kind of problem.
Actual result:
--------------
Fatal error: Declaration of c_bar::fooize() must be compatible with
that of i_foo::fooize()
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42439&edit=1