I”ve run into a slight issue, and cant’ seem to find any documentation on how to fix, or whether it’s even possible. Here’s some sample code of what I’m trying to do.
class Foo {
public function A ($dynamicValues) {
$var = array($dynamicValues);
}
}
class MyClass extends Foo {
public function A {
var_dump($var);
}
}
As you can see, I’m trying to access the values declared in the parent class’s function A in the $var array, that contains a dynamic array that is passed to it. However, I’m unable to find a way to do so, as the var_dump returns $var as an empty array. The closest thing I’ve found that will achieve my goal would be to set $var in the parent class as static, but since the values it accepts are not static, I believe that would not work.
I don’t know exactly what you’re trying to achieve but depending on the context you can use either of these methods :
If you don’t want to know how Foo:A() computes $var and $var is what is returned by the function, you can call it from the overriding method MyClass:A() like this
If A() returns something else than $var, you can extract a method from Foo::A() to compute $var like this :