I'm hoping I'm missing something simple here. I have a class that creates an array of another class. When I access the element(s) of the array, my IDE (honestly I have yet to try it in run-time because I'm not done coding) doesn't recognize the element as being from the originating class. So either I have to get used to it because that's how PHP works or I need to know the proper way to handle it. This may turn out to be a PHP IDE (PHPStorm) issue, however something doesn't feel right.
e.g. Let's say I have a class defined:
class memberClubAssoc {
private $_id;
function __construct() {
// do stuff
}
// other various functions
}
... and then I have another class. The function in question is dealingWithArray() in which I'm looping over the array of classes and accessing the class instances and then trying to use them as class instances.
class member {
private $_id;
private $_aClubAssociations;
function __construct() {
// do stuff
$this->_aClubAssociations = array();
}
// fill in the array with instances of the memberClubAssoc class
function someFunction() {
$this->_aClubAssociations[0] = new memberClubAssoc(1);
$this->_aClubAssociations[1] = new memberClubAssoc(2);
// ...
}
// here's the function in question
function dealingWithArray() {
foreach ($this->_aClubAssociations as $clubAssoc) {
// how does PHP know that $clubAssoc is actually an instance of
// memberClubAssoc? - PHPStorm certainly does not because when
// I try to access a method on the class PHPStorm says it
// doesn't exist.
}
}
}