From: alex dot dean at pni dot com Operating system: Ubuntu GNU/Linux 2.6.15-27-386 PHP version: 5CVS-2007-01-23 (snap) PHP Bug Type: Class/Object related Bug description: signature mismatch for abstract/concrete method does not produce a fatal error
Description: ------------ Given abstract and concrete versions of a class method, the first argument is allowed to differ in its usage (or non-usage) of a default value. No other arguments appear to be allowed to do this. Reproduce code: --------------- <?php abstract class TheParent { abstract public function someMethod($argument1,$argument2); } class TheChild extends TheParent { public function someMethod($argument1='',$argument2) { return; } } $test = new TheChild(); ?> Expected result: ---------------- I believe this should produce a fatal error, as the argument list for TheChild::someMethod() does not match the argument list for TheParent::someMethod(). Actual result: -------------- In practice, this code executes without errors. Additionally : * If usage of default values do not match (abstract vs. concrete) for the 2nd argument, a fatal error is produced. * If usage of default values do not match for the first argument (as in the reproduce code), but there is matching usage of default values for the 2nd argument (add a default value to the abstract and concrete someMethod() in the reproduce code), a fatal error is produced. * Using a default value for the first argument of the abstract method, and omitting a default argument from the first argument of the concrete method, executes without errors. For a single abstract/concrete method with 2 arguments, there are 16 possible combinations of usage of default arguments. I've tried all of them by varying the argument list of the provided reproduce code, and these are the only results that seem odd. Apparently, the 1st argument to a method is allowed to differ from its abstract definition in its usage of a default value, though no other arguments are. An addition to the Manual page on abstract methods indicating what constitutes an identical method signature, especially in regards to default arguments, would be very helpful. -- Edit bug report at http://bugs.php.net/?id=40212&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40212&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40212&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40212&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40212&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40212&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40212&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40212&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40212&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40212&r=support Expected behavior: http://bugs.php.net/fix.php?id=40212&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40212&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40212&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40212&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40212&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40212&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40212&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40212&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40212&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40212&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40212&r=mysqlcfg