ID: 43720 Updated by: [EMAIL PROTECTED] Reported By: phpbugs at dnr dot servegame dot org -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: * PHP Version: 5.2.5 New Comment:
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 CookieJar hast to have a is-a relationship with Container and the methods have tot take the same parameters but Container::pushBack() would allow any type as parameter, but CookieJar::pushBack() just instances of cookie which violates the is-a relationship. Previous Comments: ------------------------------------------------------------------------ [2007-12-31 16:21:22] phpbugs at dnr dot servegame dot org 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 this bug report at http://bugs.php.net/?id=43720&edit=1
