Formatted some code, noticed by SensioLabsInsight

* In both locations, anonymous function variables need to be casted as
the expected objects