|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43720 Abstract method argument ignoring
Submitted: 2007-12-31 16:21 UTC Modified: 2008-01-01 16:18 UTC
From: phpbugs at dnr dot servegame dot org Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.5 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: phpbugs at dnr dot servegame dot org
New email:
PHP Version: OS:


 [2007-12-31 16:21 UTC] phpbugs at dnr dot servegame dot org
Related to:

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:
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);

$jar = new CookieJar;

Expected result:

Actual result:
Compile time error.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-01 16:18 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 23:01:28 2024 UTC