As a note, you should set your static variable as follows:
static $privateStaticMethod; $var = self::$privateStaticMethod;
Leaving $ when using self:: will try to access the CONSTANT class, not the variable.
In fact, I think you meant this line:
//Fatal error: Undefined class constant 'privateStaticFunction' $var = self::privateStaticFunction("arga", "argb");
If you are on PHP 5.4, you can do the following in your publicStaticFunction :
$var = function(){ return self::privateStaticFunction(); }; $var();
In PHP 5.4, PHP allows you to access class scope from lambda functions.
Also, have you looked at the ReflectionClass ?
To replace call_user_func_array() in a more OOP style, the following will be used:
<?php $rc = new ReflectionClass('SomeClass'); $class = $rc->newInstanceArgs(array('foo', 'bar')); echo $class->doSomething();
You can write your own class to use ReflectionMethod , which implements ReflectionClass and use setAccessible() to allow access to protected and private methods.
source share