This problem is pretty simple, im sure, i just dont know the answer.
I have a class that extends another class. When I try parent::method to use the functionality from the parent class, I get "Call to undefined method 'parentClass'::getid()".
What its doing is, it is forcing the method name to be lowercased. from the example above, parent::getId() is being forced to parent::getid();
I do not know why this is? Any thoughts?
Code example
Class myClass extends OtherClass {
public function getProductList() {
//does other stuff
return parent::getId();
}
}
tried to run parent::getid() instead of parent::getId(). getId() is just a getter on the parent class which is a database model class.
Also worked locally, its only after my beta push that this happend.
update
parent::getId()
invokes the __call
method
/**
* @method __call
* @public
* @brief Facilitates the magic getters and setters.
* @description
* Allows for the use of getters and setters for accessing data. An exception will be thrown for
* any call that is not either already defined or is not a getter or setter for a member of the
* internal data array.
* @example
* class MyCodeModelUser extends TruDatabaseModel {
* ...
* protected $data = array(
* 'id' => null,
* 'name' => null
* );
* ...
* }
*
* ...
*
* $user->getId(); //gets the id
* $user->setId(2); //sets the id
* $user->setDateOfBirth('1/1/1980'); //throws an undefined method exception
*/
public function __call ($function, $arguments) {
$original = $function;
$function = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $function));
$prefix = substr($function, 0, 4);
if ($prefix == 'get_' || $prefix == 'set_') {
$key = substr($function, 4);
if (array_key_exists($key, $this->data)) {
if ($prefix == 'get_') {
return $this->data[$key];
} else {
$this->data[$key] = $arguments[0];
return;
}
}
}
$this->tru->error->throwException(array(
'type' => 'database.model',
'dependency' => array(
'basic',
'database'
)
), 'Call to undefined method '.get_class($this).'::'.$original.'()');
}
Here's an example that throws the same error on PHP.net: http://www.php.net/manual/en/keyword.parent.php#91315