Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
Change closures to use as the first parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikbjorn authored and fabpot committed Jul 7, 2015
1 parent b028c59 commit 5efdf83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
21 changes: 10 additions & 11 deletions src/Silex/Application.php
Expand Up @@ -62,45 +62,44 @@ public function __construct(array $values = array())
{
parent::__construct();

$app = $this;

$this['routes_factory'] = $this->factory(function () {
return new RouteCollection();
});
$this['routes'] = function () use ($app) {

$this['routes'] = function ($app) {
return $app['routes_factory'];
};

$this['controllers'] = function () use ($app) {
$this['controllers'] = function ($app) {
return $app['controllers_factory'];
};

$this['controllers_factory'] = $this->factory(function () use ($app) {
$this['controllers_factory'] = $this->factory(function ($app) {
return new ControllerCollection($app['route_factory'], $app['routes_factory']);
});

$this['route_class'] = 'Silex\\Route';
$this['route_factory'] = $this->factory(function () use ($app) {
$this['route_factory'] = $this->factory(function ($app) {
return new $app['route_class']();
});

$this['exception_handler'] = function () use ($app) {
$this['exception_handler'] = function ($app) {
return new ExceptionHandler($app['debug']);
};

$this['callback_resolver'] = function () use ($app) {
$this['callback_resolver'] = function ($app) {
return new CallbackResolver($app);
};

$this['resolver'] = function () use ($app) {
$this['resolver'] = function ($app) {
return new ControllerResolver($app, $app['logger']);
};

$this['kernel'] = function () use ($app) {
$this['kernel'] = function ($app) {
return new HttpKernel($app['dispatcher'], $app['resolver'], $app['request_stack']);
};

$this['request_stack'] = function () use ($app) {
$this['request_stack'] = function () {
return new RequestStack();
};

Expand Down
6 changes: 3 additions & 3 deletions src/Silex/Provider/RoutingServiceProvider.php
Expand Up @@ -34,11 +34,11 @@ public function register(Container $app)
return new UrlGenerator($app['routes'], $app['request_context']);
};

$app['request_matcher'] = function () use ($app) {
$app['request_matcher'] = function ($app) {
return new RedirectableUrlMatcher($app['routes'], $app['request_context']);
};

$app['request_context'] = function () use ($app) {
$app['request_context'] = function ($app) {
$context = new RequestContext();

$context->setHttpPort(isset($app['request.http_port']) ? $app['request.http_port'] : 80);
Expand All @@ -47,7 +47,7 @@ public function register(Container $app)
return $context;
};

$app['routing.listener'] = function () use ($app) {
$app['routing.listener'] = function ($app) {
$urlMatcher = new LazyRequestMatcher(function () use ($app) {
return $app['request_matcher'];
});
Expand Down
2 changes: 1 addition & 1 deletion src/Silex/Provider/SerializerServiceProvider.php
Expand Up @@ -35,7 +35,7 @@ class SerializerServiceProvider implements ServiceProviderInterface
*/
public function register(Container $app)
{
$app['serializer'] = function () use ($app) {
$app['serializer'] = function ($app) {
return new Serializer($app['serializer.normalizers'], $app['serializer.encoders']);
};

Expand Down

0 comments on commit 5efdf83

Please sign in to comment.