I was refactoring some code this week and moved some model meta data from variables into static methods on the classes (so they don’t need to be instantiated to access the meta data). I had a list of the classes in an array and was looping over them, and attempting to call the static method like this:
$test = $foo::bar();
This does not work, you get an “unexpected T_PAAMAYIM_NEKUDOTAYIM” error. This is apparently Hebrew for “two colons”. In other words, PHP doesn’t like you trying to call a static method on a class when the classname is stored in a variable.
Here is the workaround:
$test = call_user_func(array($foo, 'bar'));
Works like a champ.
Your original version will work in 5.3+ I believe – http://us.php.net/ma[...]udotayim.php
Yep, that’s noted in the bug I linked to in the post. Handy if you’re creating hosted services, but not so much for creating apps for distribution.