I have the following class hierarchy: MDLUser
inherits from MDLPersistentObject
In MDLPersistentObject
I have a static method which returns an array. In MDLUser
I override the static method so that it returns the MDLPersistentObject
’s array, adds its own data, then returns the new array.
But when I call parent::myArrayReturningMethod()
inside MDLUser
it just returns MDLUser
’s implementation (i.e. missing the array data from MDLPersistentObject
. However, if I call it the bad practise way, MDLPersistentObject::myArrayReturningMethod()
, then it returns what I expect.
Is parent::
not the correct late static binding method for calling a parent implementation of a static method?
If you’re wondering what my code looks like:
MDLPersistentObject’s method:
static public function Neo4j_Labels_In_Client( Everyman\Neo4j\Client $client )
{
//
// Create a label called `MDLPersistentObject`
//
$mdlobject_label = $client->makeLabel( get_called_class() );
//
// Return the label in an array
//
$labels = Array(
$mdlobject_label
);
return $labels;
}
MDLUser’s method:
static public function Neo4j_Labels_In_Client( Everyman\Neo4j\Client $client )
{
//
// Get the parent labels
//
$labels = parent::Neo4j_Labels_In_Client( $client );
//
// Add the new labels
//
$user_label = $client->makeLabel( get_called_class() );
array_push( $labels, $user_label );
//
// Return labels
//
return $labels;
}