PHPUnit - Serialization of Closure is not allowed in Symfony 2

by Steve Hoeksema, posted 18 Mar 2013.

If you get an error like this:

PHPUnit_Framework_Exception: PHP Fatal error:
Uncaught exception 'Exception' with message
'Serialization of 'Closure' is not allowed'
in vendor/symfony/src/Symfony/Component/HttpFoundation/Session.php:383

It might be because your unit test references an uninitialized variable or array index.

No, really.

(Thanks @ethos49)

Also available as an Atom feed.
This post licensed as CC BY-NC-SA.