I\'ve got a class Foo
with public and protected properties. Foo
needs to have a non-static method, getPublicVars()
that returns a list of
Does not work with php version >=7
As such, I can't really recommend solution any longer.
Use reflection instead
To get the public properties from within the class
$publicProperties = call_user_func('get_object_vars', $this);
the "trick" is that get_object_vars
is being called from the scope of call_user_func
and not the scope of the object
no need for reflection, stand-alone functions, closures, etc