abstract class foo
{
public $blah;
}
class bar extends foo
{
public $baz;
}
Given that I have a foo class that inherits from the abstract bar class how would I get an array of the instance variables that exist only on bar but not on foo (i.e. properties that are defined on the bar level)? In the example above I would want baz but not blah.
As hakre said, use
Reflection. Grab the class’s parent class, and do a diff on the properties, like so:You’d call it like this:
See it working in this demo, which outputs: