Commit a4a5ad03 authored by Fabien Potencier's avatar Fabien Potencier

fixed CS

parent 24244da6
......@@ -23,8 +23,6 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpKernel\EventListener\ResponseListener;
use Symfony\Component\HttpKernel\EventListener\RouterListener;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -36,12 +34,8 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Exception\ExceptionInterface as RoutingException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Silex\RedirectableUrlMatcher;
use Silex\ControllerResolver;
......@@ -119,6 +113,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
$ret = call_user_func($callback, $event->getRequest());
if ($ret instanceof Response) {
$event->setResponse($ret);
return;
} elseif (null !== $ret) {
throw new \RuntimeException('Middleware for route "'.$event->getRequest()->attributes->get('_route').'" returned an invalid response value. Must return null or an instance of Response.');
......@@ -159,7 +154,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
* You can optionally specify HTTP methods that should be matched.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -172,7 +167,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
* Maps a GET request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -185,7 +180,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
* Maps a POST request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -198,7 +193,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
* Maps a PUT request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -211,7 +206,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
* Maps a DELETE request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -384,8 +379,8 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
/**
* Mounts an application under the given route prefix.
*
* @param string $prefix The route prefix
* @param ControllerCollection|ControllerProviderInterface $app A ControllerCollection or a ControllerProviderInterface instance
* @param string $prefix The route prefix
* @param ControllerCollection|ControllerProviderInterface $app A ControllerCollection or a ControllerProviderInterface instance
*/
public function mount($prefix, $app)
{
......
......@@ -158,7 +158,7 @@ class Controller
* Sets a callback to handle before triggering the route callback.
* (a.k.a. "Route Middleware")
*
* @param mixed $callback A PHP callback to be triggered when the Route is matched, just before the route callback
* @param mixed $callback A PHP callback to be triggered when the Route is matched, just before the route callback
* @return Controller $this The current Controller instance
*/
public function middleware($callback)
......
......@@ -35,7 +35,7 @@ class ControllerCollection
* You can optionally specify HTTP methods that should be matched.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -52,7 +52,7 @@ class ControllerCollection
* Maps a GET request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -65,7 +65,7 @@ class ControllerCollection
* Maps a POST request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -78,7 +78,7 @@ class ControllerCollection
* Maps a PUT request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......@@ -91,7 +91,7 @@ class ControllerCollection
* Maps a DELETE request to a callable.
*
* @param string $pattern Matched route pattern
* @param mixed $to Callback that returns the response when matched
* @param mixed $to Callback that returns the response when matched
*
* @return Silex\Controller
*/
......
......@@ -11,8 +11,6 @@
namespace Silex;
use Silex\Application;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Debug\ExceptionHandler as DebugExceptionHandler;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......
......@@ -11,9 +11,7 @@
namespace Silex;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Request;
/**
* GetResponseForExceptionEvent with additional setStringResponse method
......
......@@ -40,6 +40,7 @@ class LazyUrlMatcher implements UrlMatcherInterface
if (!$urlMatcher instanceof UrlMatcherInterface) {
throw new \LogicException("Factory supplied to LazyUrlMatcher must return implementation of UrlMatcherInterface.");
}
return $urlMatcher;
}
......
......@@ -19,7 +19,6 @@ use Silex\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Monolog Provider.
......
......@@ -12,7 +12,6 @@
namespace Silex;
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\HttpKernel\Test\WebTestCase as BaseWebTestCase;
/**
* WebTestCase is the base class for functional tests.
......@@ -44,8 +43,8 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
/**
* Creates a Client.
*
* @param array $options An array of options to pass to the createKernel class
* @param array $server An array of server parameters
* @param array $options An array of options to pass to the createKernel class
* @param array $server An array of server parameters
*
* @return Client A Client instance
*/
......
......@@ -191,6 +191,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$app->get('/reached', function () use (&$middlewareTarget) {
$middlewareTarget[] = 'route_triggered';
return 'hello';
})
->middleware($middleware1)
......
......@@ -15,7 +15,6 @@ use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Error handler test cases.
......@@ -60,6 +59,7 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
$app->match('/foo', function () use (&$i) {
$i++;
return new Response('foo');
});
......
......@@ -11,14 +11,11 @@
namespace Silex\Tests;
use Silex\Application;
use Silex\Controller;
use Silex\ControllerCollection;
use Silex\Exception\ControllerFrozenException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
/**
* ControllerCollection test cases.
......
......@@ -139,6 +139,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$app->error(function ($e) use (&$errors) {
$errors++;
return new Response('foo exception handler');
});
......
......@@ -13,8 +13,6 @@ namespace Silex\Tests;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
/**
* JSON test cases.
......
......@@ -36,6 +36,7 @@ class SessionServiceProviderTest extends \PHPUnit_Framework_TestCase
$app->get('/login', function () use ($app) {
$app['session']->set('logged_in', true);
return 'Logged in successfully.';
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment