#46984 [Ana]: Strict-Warning when overwriting methods with changed parameters
ID: 46984
Updated by: cellog@php.net
Reported By: d_quijote at web dot de
Status: Analyzed
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 5.3.0alpha3
New Comment:
the error occurs regardless of implementing an interface, and is, I
believe, correct. If $y were optional, there is no problem, and no
error
Previous Comments:
------------------------------------------------------------------------
[2009-01-01 00:21:51] felipe@php.net
I agree with you, here is a patch:
http://felipe.ath.cx/diff/bug46984.diff
However it broken some tests, that for me, looks as even they are
wrong.
method overloading with different method signature
[Zend/tests/objects_002.phpt]
method overloading with different method signature
[Zend/tests/objects_003.phpt]
method overloading with different method signature
[Zend/tests/objects_004.phpt]
method overloading with different method signature
[Zend/tests/objects_005.phpt]
method overloading with different method signature
[Zend/tests/objects_006.phpt]
method overloading with different method signature
[Zend/tests/objects_007.phpt]
method overloading with different method signature
[Zend/tests/objects_008.phpt]
method overloading with different method signature
[Zend/tests/objects_009.phpt]
Let's decide the expected behavior, wait...
------------------------------------------------------------------------
[2008-12-31 12:52:32] d_quijote at web dot de
Description:
------------
A Strict-Warning is raised when the parameters of the subclass differ
from the parameters of the overwritten superclass method. This error
seems only to occure if any interface is included in the superclass
Reproduce code:
---------------
class A implements Iterator {
public function current() {}
public function key() {}
public function next() {}
public function rewind() {}
public function valid() {}
public function f($x) {
echo $x.PHP_EOL;
}
}
class B extends A {
public function f($x,$y) {
echo __METHOD__.'('.$x.', '.$y.')'.PHP_EOL;
}
}
$b = new B();
$b->f(1,2);
Expected result:
----------------
B::f(1, 2)
Actual result:
--------------
Strict Standards: Declaration of B::f() should be compatible with that
of A::f() in /index.php on line 19
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46984&edit=1
Thread (5 messages)