From: phpbugs at dnr dot servegame dot org Operating system: * PHP version: 5.2.5 PHP Bug Type: Class/Object related Bug description: Abstract method argument ignoring
Description: ------------ Related to: http://bugs.php.net/bug.php?id=36601 However, there's another case where it's nice if arguments for an abstract method can be ignored. I'd call it a 'loose abstract method' and maybe loose should be the keyword used to indicate it. I bumped into this, when trying to make a simple container abstract class, that could be extended for specific containers (see example). Not only is typehinting a problem, since inheritance isn't checked, but I'd like to be able to use more or less arguments depending on the container type. So I guess, this is a feature request for a 'loose' abstract method declaration that simply ignores method arguments at compile time. The implemented method still needs to be checked for any type hints though. Reproduce code: --------------- <?php abstract class Container { protected $storage; public $index; public function __construct() { $this->storage = array(); $this->index = 0; } /** * @brief setter overloader * * Guards index from going negative, instead it goes to end of the array, * minus the offset given. */ public function __set($nm, $val) { if( $val < 0 ) $val = count($this->storage) - $val; if( $nm == 'index' ) $this->idx = $val; } /* loose */ abstract public function pushBack($thing); } class Cookie { protected $name; public function __construct($name) { $this->name = $name; } } class CookieJar extends Container { public function pushBack(Cookie $cookie) { array_push($this->storage, $cookie); $this->index++; } } $jar = new CookieJar; Expected result: ---------------- Nothing. Actual result: -------------- Compile time error. -- Edit bug report at http://bugs.php.net/?id=43720&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43720&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43720&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43720&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43720&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43720&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43720&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43720&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43720&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43720&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43720&r=support Expected behavior: http://bugs.php.net/fix.php?id=43720&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43720&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43720&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43720&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43720&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43720&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43720&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43720&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43720&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43720&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43720&r=mysqlcfg
