I just started playing with Symfony 2.0 and immediately ran into an error:
[28-Nov-2011 16:51:26] PHP Fatal error: exception for the exception "InvalidArgumentException" with the message "The expected call is expected in AnnotationRegistry :: registerLoader () '.
Digging deeper, I found that an anonymous function is being passed to the registerLoader
function.
$callable = function($class) use ($loader) { $loader->loadClass($class); return class_exists($class, false); }; AnnotationRegistry::registerLoader($callable);
It looks good, right? To be safe, I threw a check:
var_dump(gettype($callable));
Which returns NULL, which obviously cannot be called. I just upgraded to PHP 5.3.2, and according to phpversion()
, this version will be used.
I ran a one-time script outside of Symfony and everything behaved correctly.
$foo = function() { echo 'foo'; }; var_dump(gettype($foo));
// line (6) "object"
Does anyone have any thoughts as to why I see other behavior around anonymous functions inside the Symfony environment?
source share