Reputation: 6274
Probably a stupid question, but my IDE (PHPStorm) and I are having a bit of a disagreement...
class Item_Backpack {
public function Empty() {
// dump contents
}
public function insertThing($thing) {
// insert thing into backpack
}
}
class Student {
private $_Backpack; // is a class, can contain other objects
function __construct() {
$this->_Backpack = new Item_Backpack;
}
public function emptyBackpack() {
$this->_Backpack->Empty(); // IDE says method undefined
// and cannot give method/property hints
// for this object :-3
}
}
The Item_Backpack
class has the method public function Empty()
which ... empties the backpack!
Is my syntax correct here?
Upvotes: 3
Views: 792
Reputation: 684
It's having problems because empty() is a reserved function name in PHP - you just need to rename the function to something else, ie. emptyContents()
Upvotes: 4