<?php

namespace Lily\Mock;

use Lily\Application\MiddlewareApplication;

class MiddlewareApplicationWithMiddleware extends MiddlewareApplication
{
    public $m;

    protected function middleware()
    {
        $m = $this->m;

        return array(
            function ($request) {
                return $request['middleware-message'];
            },
            
            function ($handler) {
                return function ($request) use ($handler, $m) {
                    $request['middleware-message'] = $m;
                    return $handler($request);
                };
            },
        );
    }
}

<?php

namespace Lily\Mock;

use Lily\Application\MiddlewareApplication;

class MiddlewareApplicationWithMiddleware extends MiddlewareApplication
{
    public $m;

    protected function middleware()
    {
        return array(
            function ($request) {
                return $request['middleware-message'];
            },
            
            function ($handler) {
                return function ($request) use ($handler) {
                    $request['middleware-message'] = $this->m;
                    return $handler($request);
                };
            },
        );
    }
}

--- 
+++ 
@@ -10,14 +10,16 @@
 
     protected function middleware()
     {
+        $m = $this->m;
+
         return array(
             function ($request) {
                 return $request['middleware-message'];
             },
             
             function ($handler) {
-                return function ($request) use ($handler) {
-                    $request['middleware-message'] = $this->m;
+                return function ($request) use ($handler, $m) {
+                    $request['middleware-message'] = $m;
                     return $handler($request);
                 };
             },
Fix mock object to work with PHP 5.3