I just started playing around with Symfony 2.0 and immediately ran into an error:
[28-Nov-2011 16:51:26] PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'A callable is expected in AnnotationRegistry::registerLoader().'
Digging deeper, I found that an anonymous function was getting passed into the registerLoader
function.
$callable = function($class) use ($loader)
{
$loader->loadClass($class);
return class_exists($class, false);
};
AnnotationRegistry::registerLoader($callable);
Looks fine, right? Just to be safe, I threw in a check:
var_dump(gettype($callable));
Which returned NULL, which is obviously not callable. I just upgraded to PHP 5.3.2, and according to phpversion()
that's the version that is getting used.
I ran a one-off script outside of the Symfony environment and everything behaved correctly.
$foo = function()
{
echo 'foo';
};
var_dump(gettype($foo));
//string(6) "object"
Anyone have any thoughts as to why I'm seeing different behavior around anonymous functions inside the Symfony environment?