Commit a8ea59d2 authored by Fabien Potencier's avatar Fabien Potencier

minor #1599 Fix CS (fabpot)

This PR was squashed before being merged into the 2.2.x-dev branch (closes #1599).

Discussion
----------

Fix CS

Commits
-------

c5ec5245 switched to short array notation
08d04b40 fixed CS
parents 029f3d05 c5ec5245
<?php
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit48Migration:risky' => true,
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
'array_syntax' => array('syntax' => 'short'),
'protected_to_private' => false,
))
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src/')
->in(__DIR__.'/tests/')
->name('*.php')
)
;
...@@ -34,7 +34,7 @@ class AppArgumentValueResolver implements ArgumentValueResolverInterface ...@@ -34,7 +34,7 @@ class AppArgumentValueResolver implements ArgumentValueResolverInterface
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument)
{ {
return null !== $argument->getType() && ($argument->getType() === Application::class || is_subclass_of($argument->getType(), Application::class)); return null !== $argument->getType() && (Application::class === $argument->getType() || is_subclass_of($argument->getType(), Application::class));
} }
/** /**
......
...@@ -46,7 +46,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -46,7 +46,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
const EARLY_EVENT = 512; const EARLY_EVENT = 512;
const LATE_EVENT = -512; const LATE_EVENT = -512;
protected $providers = array(); protected $providers = [];
protected $booted = false; protected $booted = false;
/** /**
...@@ -54,9 +54,9 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -54,9 +54,9 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* *
* Objects and parameters can be passed as argument to the constructor. * Objects and parameters can be passed as argument to the constructor.
* *
* @param array $values The parameters or objects. * @param array $values the parameters or objects
*/ */
public function __construct(array $values = array()) public function __construct(array $values = [])
{ {
parent::__construct(); parent::__construct();
...@@ -83,7 +83,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -83,7 +83,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* *
* @return Application * @return Application
*/ */
public function register(ServiceProviderInterface $provider, array $values = array()) public function register(ServiceProviderInterface $provider, array $values = [])
{ {
$this->providers[] = $provider; $this->providers[] = $provider;
...@@ -311,7 +311,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -311,7 +311,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* @param string $message The status message * @param string $message The status message
* @param array $headers An array of HTTP headers * @param array $headers An array of HTTP headers
*/ */
public function abort($statusCode, $message = '', array $headers = array()) public function abort($statusCode, $message = '', array $headers = [])
{ {
throw new HttpException($statusCode, $message, null, $headers); throw new HttpException($statusCode, $message, null, $headers);
} }
...@@ -385,7 +385,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -385,7 +385,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* *
* @return StreamedResponse * @return StreamedResponse
*/ */
public function stream($callback = null, $status = 200, array $headers = array()) public function stream($callback = null, $status = 200, array $headers = [])
{ {
return new StreamedResponse($callback, $status, $headers); return new StreamedResponse($callback, $status, $headers);
} }
...@@ -414,7 +414,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -414,7 +414,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* *
* @return JsonResponse * @return JsonResponse
*/ */
public function json($data = array(), $status = 200, array $headers = array()) public function json($data = [], $status = 200, array $headers = [])
{ {
return new JsonResponse($data, $status, $headers); return new JsonResponse($data, $status, $headers);
} }
...@@ -429,7 +429,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -429,7 +429,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* *
* @return BinaryFileResponse * @return BinaryFileResponse
*/ */
public function sendFile($file, $status = 200, array $headers = array(), $contentDisposition = null) public function sendFile($file, $status = 200, array $headers = [], $contentDisposition = null)
{ {
return new BinaryFileResponse($file, $status, $headers, true, $contentDisposition); return new BinaryFileResponse($file, $status, $headers, true, $contentDisposition);
} }
......
...@@ -32,7 +32,7 @@ trait FormTrait ...@@ -32,7 +32,7 @@ trait FormTrait
* *
* @return FormBuilder * @return FormBuilder
*/ */
public function form($data = null, array $options = array(), $type = null) public function form($data = null, array $options = [], $type = null)
{ {
return $this['form.factory']->createBuilder($type ?: FormType::class, $data, $options); return $this['form.factory']->createBuilder($type ?: FormType::class, $data, $options);
} }
...@@ -47,7 +47,7 @@ trait FormTrait ...@@ -47,7 +47,7 @@ trait FormTrait
* *
* @return FormBuilder * @return FormBuilder
*/ */
public function namedForm($name, $data = null, array $options = array(), $type = null) public function namedForm($name, $data = null, array $options = [], $type = null)
{ {
return $this['form.factory']->createNamedBuilder($name, $type ?: FormType::class, $data, $options); return $this['form.factory']->createNamedBuilder($name, $type ?: FormType::class, $data, $options);
} }
......
...@@ -29,7 +29,7 @@ trait MonologTrait ...@@ -29,7 +29,7 @@ trait MonologTrait
* *
* @return bool Whether the record has been processed * @return bool Whether the record has been processed
*/ */
public function log($message, array $context = array(), $level = Logger::INFO) public function log($message, array $context = [], $level = Logger::INFO)
{ {
return $this['monolog']->addRecord($level, $message, $context); return $this['monolog']->addRecord($level, $message, $context);
} }
......
...@@ -44,7 +44,7 @@ trait SecurityTrait ...@@ -44,7 +44,7 @@ trait SecurityTrait
* *
* @return bool * @return bool
* *
* @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token. * @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token
*/ */
public function isGranted($attributes, $object = null) public function isGranted($attributes, $object = null)
{ {
......
...@@ -28,7 +28,7 @@ trait TranslationTrait ...@@ -28,7 +28,7 @@ trait TranslationTrait
* *
* @return string The translated string * @return string The translated string
*/ */
public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null) public function trans($id, array $parameters = [], $domain = 'messages', $locale = null)
{ {
return $this['translator']->trans($id, $parameters, $domain, $locale); return $this['translator']->trans($id, $parameters, $domain, $locale);
} }
...@@ -44,7 +44,7 @@ trait TranslationTrait ...@@ -44,7 +44,7 @@ trait TranslationTrait
* *
* @return string The translated string * @return string The translated string
*/ */
public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) public function transChoice($id, $number, array $parameters = [], $domain = 'messages', $locale = null)
{ {
return $this['translator']->transChoice($id, $number, $parameters, $domain, $locale); return $this['translator']->transChoice($id, $number, $parameters, $domain, $locale);
} }
......
...@@ -32,7 +32,7 @@ trait TwigTrait ...@@ -32,7 +32,7 @@ trait TwigTrait
* *
* @return Response A Response instance * @return Response A Response instance
*/ */
public function render($view, array $parameters = array(), Response $response = null) public function render($view, array $parameters = [], Response $response = null)
{ {
$twig = $this['twig']; $twig = $this['twig'];
...@@ -58,7 +58,7 @@ trait TwigTrait ...@@ -58,7 +58,7 @@ trait TwigTrait
* *
* @return string The rendered view * @return string The rendered view
*/ */
public function renderView($view, array $parameters = array()) public function renderView($view, array $parameters = [])
{ {
return $this['twig']->render($view, $parameters); return $this['twig']->render($view, $parameters);
} }
......
...@@ -28,7 +28,7 @@ trait UrlGeneratorTrait ...@@ -28,7 +28,7 @@ trait UrlGeneratorTrait
* *
* @return string The generated path * @return string The generated path
*/ */
public function path($route, $parameters = array()) public function path($route, $parameters = [])
{ {
return $this['url_generator']->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH); return $this['url_generator']->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH);
} }
...@@ -41,7 +41,7 @@ trait UrlGeneratorTrait ...@@ -41,7 +41,7 @@ trait UrlGeneratorTrait
* *
* @return string The generated URL * @return string The generated URL
*/ */
public function url($route, $parameters = array()) public function url($route, $parameters = [])
{ {
return $this['url_generator']->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_URL); return $this['url_generator']->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_URL);
} }
......
...@@ -43,13 +43,13 @@ class CallbackResolver ...@@ -43,13 +43,13 @@ class CallbackResolver
* *
* @return callable * @return callable
* *
* @throws \InvalidArgumentException In case the method does not exist. * @throws \InvalidArgumentException in case the method does not exist
*/ */
public function convertCallback($name) public function convertCallback($name)
{ {
if (preg_match(static::SERVICE_PATTERN, $name)) { if (preg_match(static::SERVICE_PATTERN, $name)) {
list($service, $method) = explode(':', $name, 2); list($service, $method) = explode(':', $name, 2);
$callback = array($this->app[$service], $method); $callback = [$this->app[$service], $method];
} else { } else {
$service = $name; $service = $name;
$callback = $this->app[$name]; $callback = $this->app[$name];
...@@ -69,7 +69,7 @@ class CallbackResolver ...@@ -69,7 +69,7 @@ class CallbackResolver
* *
* @return string|callable A callable value or the string passed in * @return string|callable A callable value or the string passed in
* *
* @throws \InvalidArgumentException In case the method does not exist. * @throws \InvalidArgumentException in case the method does not exist
*/ */
public function resolveCallback($name) public function resolveCallback($name)
{ {
......
...@@ -91,7 +91,7 @@ class Controller ...@@ -91,7 +91,7 @@ class Controller
throw new \BadMethodCallException(sprintf('Method "%s::%s" does not exist.', get_class($this->route), $method)); throw new \BadMethodCallException(sprintf('Method "%s::%s" does not exist.', get_class($this->route), $method));
} }
call_user_func_array(array($this->route, $method), $arguments); call_user_func_array([$this->route, $method], $arguments);
return $this; return $this;
} }
...@@ -111,7 +111,7 @@ class Controller ...@@ -111,7 +111,7 @@ class Controller
$methods = implode('_', $this->route->getMethods()).'_'; $methods = implode('_', $this->route->getMethods()).'_';
$routeName = $methods.$prefix.$this->route->getPath(); $routeName = $methods.$prefix.$this->route->getPath();
$routeName = str_replace(array('/', ':', '|', '-'), '_', $routeName); $routeName = str_replace(['/', ':', '|', '-'], '_', $routeName);
$routeName = preg_replace('/[^a-z0-9A-Z_.]+/', '', $routeName); $routeName = preg_replace('/[^a-z0-9A-Z_.]+/', '', $routeName);
// Collapse consecutive underscores down into a single underscore. // Collapse consecutive underscores down into a single underscore.
......
...@@ -39,7 +39,7 @@ use Symfony\Component\HttpFoundation\Request; ...@@ -39,7 +39,7 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class ControllerCollection class ControllerCollection
{ {
protected $controllers = array(); protected $controllers = [];
protected $defaultRoute; protected $defaultRoute;
protected $defaultController; protected $defaultController;
protected $prefix; protected $prefix;
...@@ -184,10 +184,10 @@ class ControllerCollection ...@@ -184,10 +184,10 @@ class ControllerCollection
throw new \BadMethodCallException(sprintf('Method "%s::%s" does not exist.', get_class($this->defaultRoute), $method)); throw new \BadMethodCallException(sprintf('Method "%s::%s" does not exist.', get_class($this->defaultRoute), $method));
} }
call_user_func_array(array($this->defaultRoute, $method), $arguments); call_user_func_array([$this->defaultRoute, $method], $arguments);
foreach ($this->controllers as $controller) { foreach ($this->controllers as $controller) {
call_user_func_array(array($controller, $method), $arguments); call_user_func_array([$controller, $method], $arguments);
} }
return $this; return $this;
...@@ -211,7 +211,7 @@ class ControllerCollection ...@@ -211,7 +211,7 @@ class ControllerCollection
private function doFlush($prefix, RouteCollection $routes) private function doFlush($prefix, RouteCollection $routes)
{ {
if ($prefix !== '') { if ('' !== $prefix) {
$prefix = '/'.trim(trim($prefix), '/'); $prefix = '/'.trim(trim($prefix), '/');
} }
...@@ -233,7 +233,7 @@ class ControllerCollection ...@@ -233,7 +233,7 @@ class ControllerCollection
} }
} }
$this->controllers = array(); $this->controllers = [];
return $routes; return $routes;
} }
......
...@@ -59,8 +59,8 @@ class ConverterListener implements EventSubscriberInterface ...@@ -59,8 +59,8 @@ class ConverterListener implements EventSubscriberInterface
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return [
KernelEvents::CONTROLLER => 'onKernelController', KernelEvents::CONTROLLER => 'onKernelController',
); ];
} }
} }
...@@ -116,19 +116,19 @@ class LogListener implements EventSubscriberInterface ...@@ -116,19 +116,19 @@ class LogListener implements EventSubscriberInterface
*/ */
protected function logException(\Exception $e) protected function logException(\Exception $e)
{ {
$this->logger->log(call_user_func($this->exceptionLogFilter, $e), sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), array('exception' => $e)); $this->logger->log(call_user_func($this->exceptionLogFilter, $e), sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), ['exception' => $e]);
} }
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return [
KernelEvents::REQUEST => array('onKernelRequest', 0), KernelEvents::REQUEST => ['onKernelRequest', 0],
KernelEvents::RESPONSE => array('onKernelResponse', 0), KernelEvents::RESPONSE => ['onKernelResponse', 0],
/* /*
* Priority -4 is used to come after those from SecurityServiceProvider (0) * Priority -4 is used to come after those from SecurityServiceProvider (0)
* but before the error handlers added with Silex\Application::error (defaults to -8) * but before the error handlers added with Silex\Application::error (defaults to -8)
*/ */
KernelEvents::EXCEPTION => array('onKernelException', -4), KernelEvents::EXCEPTION => ['onKernelException', -4],
); ];
} }
} }
...@@ -87,10 +87,10 @@ class MiddlewareListener implements EventSubscriberInterface ...@@ -87,10 +87,10 @@ class MiddlewareListener implements EventSubscriberInterface
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return [
// this must be executed after the late events defined with before() (and their priority is -512) // this must be executed after the late events defined with before() (and their priority is -512)
KernelEvents::REQUEST => array('onKernelRequest', -1024), KernelEvents::REQUEST => ['onKernelRequest', -1024],
KernelEvents::RESPONSE => array('onKernelResponse', 128), KernelEvents::RESPONSE => ['onKernelResponse', 128],
); ];
} }
} }
...@@ -44,8 +44,8 @@ class StringToResponseListener implements EventSubscriberInterface ...@@ -44,8 +44,8 @@ class StringToResponseListener implements EventSubscriberInterface
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return [
KernelEvents::VIEW => array('onKernelView', -10), KernelEvents::VIEW => ['onKernelView', -10],
); ];
} }
} }
...@@ -51,6 +51,6 @@ class ExceptionHandler implements EventSubscriberInterface ...@@ -51,6 +51,6 @@ class ExceptionHandler implements EventSubscriberInterface
*/ */
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array(KernelEvents::EXCEPTION => array('onSilexError', -255)); return [KernelEvents::EXCEPTION => ['onSilexError', -255]];
} }
} }
...@@ -32,11 +32,11 @@ class AssetServiceProvider implements ServiceProviderInterface ...@@ -32,11 +32,11 @@ class AssetServiceProvider implements ServiceProviderInterface
public function register(Container $app) public function register(Container $app)
{ {
$app['assets.packages'] = function ($app) { $app['assets.packages'] = function ($app) {
$packages = array(); $packages = [];
foreach ($app['assets.named_packages'] as $name => $package) { foreach ($app['assets.named_packages'] as $name => $package) {
$version = $app['assets.strategy_factory'](isset($package['version']) ? $package['version'] : null, isset($package['version_format']) ? $package['version_format'] : null, isset($package['json_manifest_path']) ? $package['json_manifest_path'] : null, $name); $version = $app['assets.strategy_factory'](isset($package['version']) ? $package['version'] : null, isset($package['version_format']) ? $package['version_format'] : null, isset($package['json_manifest_path']) ? $package['json_manifest_path'] : null, $name);
$packages[$name] = $app['assets.package_factory'](isset($package['base_path']) ? $package['base_path'] : '', isset($package['base_urls']) ? $package['base_urls'] : array(), $version, $name); $packages[$name] = $app['assets.package_factory'](isset($package['base_path']) ? $package['base_path'] : '', isset($package['base_urls']) ? $package['base_urls'] : [], $version, $name);
} }
return new Packages($app['assets.default_package'], $packages); return new Packages($app['assets.default_package'], $packages);
...@@ -53,12 +53,12 @@ class AssetServiceProvider implements ServiceProviderInterface ...@@ -53,12 +53,12 @@ class AssetServiceProvider implements ServiceProviderInterface
}; };
$app['assets.base_path'] = ''; $app['assets.base_path'] = '';
$app['assets.base_urls'] = array(); $app['assets.base_urls'] = [];
$app['assets.version'] = null; $app['assets.version'] = null;
$app['assets.version_format'] = null; $app['assets.version_format'] = null;
$app['assets.json_manifest_path'] = null; $app['assets.json_manifest_path'] = null;
$app['assets.named_packages'] = array(); $app['assets.named_packages'] = [];
// prototypes // prototypes
......
...@@ -27,13 +27,13 @@ class DoctrineServiceProvider implements ServiceProviderInterface ...@@ -27,13 +27,13 @@ class DoctrineServiceProvider implements ServiceProviderInterface
{ {
public function register(Container $app) public function register(Container $app)
{ {
$app['db.default_options'] = array( $app['db.default_options'] = [
'driver' => 'pdo_mysql', 'driver' => 'pdo_mysql',
'dbname' => null, 'dbname' => null,
'host' => 'localhost', 'host' => 'localhost',
'user' => 'root', 'user' => 'root',
'password' => null, 'password' => null,
); ];
$app['dbs.options.initializer'] = $app->protect(function () use ($app) { $app['dbs.options.initializer'] = $app->protect(function () use ($app) {
static $initialized = false; static $initialized = false;
...@@ -45,7 +45,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface ...@@ -45,7 +45,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface
$initialized = true; $initialized = true;
if (!isset($app['dbs.options'])) { if (!isset($app['dbs.options'])) {
$app['dbs.options'] = array('default' => isset($app['db.options']) ? $app['db.options'] : array()); $app['dbs.options'] = ['default' => isset($app['db.options']) ? $app['db.options'] : []];
} }
$tmp = $app['dbs.options']; $tmp = $app['dbs.options'];
......
...@@ -34,15 +34,15 @@ class FormServiceProvider implements ServiceProviderInterface ...@@ -34,15 +34,15 @@ class FormServiceProvider implements ServiceProviderInterface
} }
$app['form.types'] = function ($app) { $app['form.types'] = function ($app) {
return array(); return [];
}; };
$app['form.type.extensions'] = function ($app) { $app['form.type.extensions'] = function ($app) {
return array(); return [];
}; };
$app['form.type.guessers'] = function ($app) { $app['form.type.guessers'] = function ($app) {
return array(); return [];
}; };
$app['form.extension.csrf'] = function ($app) { $app['form.extension.csrf'] = function ($app) {
...@@ -58,9 +58,9 @@ class FormServiceProvider implements ServiceProviderInterface ...@@ -58,9 +58,9 @@ class FormServiceProvider implements ServiceProviderInterface
}; };
$app['form.extensions'] = function ($app) { $app['form.extensions'] = function ($app) {
$extensions = array( $extensions = [
new HttpFoundationExtension(), new HttpFoundationExtension(),
); ];
if (isset($app['csrf.token_manager'])) { if (isset($app['csrf.token_manager'])) {
$extensions[] = $app['form.extension.csrf']; $extensions[] = $app['form.extension.csrf'];
......
...@@ -31,9 +31,9 @@ class HttpCacheServiceProvider implements ServiceProviderInterface, EventListene ...@@ -31,9 +31,9 @@ class HttpCacheServiceProvider implements ServiceProviderInterface, EventListene
{ {
$app['http_cache'] = function ($app) { $app['http_cache'] = function ($app) {
$app['http_cache.options'] = array_replace( $app['http_cache.options'] = array_replace(
array( [
'debug' => $app['debug'], 'debug' => $app['debug'],
), $app['http_cache.options'] ], $app['http_cache.options']
); );
return new HttpCache($app, $app['http_cache.store'], $app['http_cache.esi'], $app['http_cache.options']); return new HttpCache($app, $app['http_cache.store'], $app['http_cache.esi'], $app['http_cache.options']);
...@@ -51,7 +51,7 @@ class HttpCacheServiceProvider implements ServiceProviderInterface, EventListene ...@@ -51,7 +51,7 @@ class HttpCacheServiceProvider implements ServiceProviderInterface, EventListene
return new SurrogateListener($app['http_cache.esi']); return new SurrogateListener($app['http_cache.esi']);
}; };
$app['http_cache.options'] = array(); $app['http_cache.options'] = [];
} }
public function subscribe(Container $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
......
...@@ -69,7 +69,7 @@ class HttpFragmentServiceProvider implements ServiceProviderInterface, EventList ...@@ -69,7 +69,7 @@ class HttpFragmentServiceProvider implements ServiceProviderInterface, EventList
$app['fragment.path'] = '/_fragment'; $app['fragment.path'] = '/_fragment';
$app['fragment.renderer.hinclude.global_template'] = null; $app['fragment.renderer.hinclude.global_template'] = null;
$app['fragment.renderers'] = function ($app) { $app['fragment.renderers'] = function ($app) {
$renderers = array($app['fragment.renderer.inline'], $app['fragment.renderer.hinclude']); $renderers = [$app['fragment.renderer.inline'], $app['fragment.renderer.hinclude']];
if (isset($app['http_cache.esi'])) { if (isset($app['http_cache.esi'])) {
$renderers[] = $app['fragment.renderer.esi']; $renderers[] = $app['fragment.renderer.esi'];
......
...@@ -48,16 +48,16 @@ class HttpKernelServiceProvider implements ServiceProviderInterface, EventListen ...@@ -48,16 +48,16 @@ class HttpKernelServiceProvider implements ServiceProviderInterface, EventListen
}; };
$app['argument_value_resolvers'] = function ($app) { $app['argument_value_resolvers'] = function ($app) {
if (Kernel::VERSION_ID < 30200) { if (Kernel::VERSION_ID < 30200) {
return array( return [
new AppArgumentValueResolver($app), new AppArgumentValueResolver($app),
new RequestAttributeValueResolver(), new RequestAttributeValueResolver(),
new RequestValueResolver(), new RequestValueResolver(),
new DefaultValueResolver(), new DefaultValueResolver(),
new VariadicValueResolver(), new VariadicValueResolver(),
); ];
} }
return array_merge(array(new AppArgumentValueResolver($app)), ArgumentResolver::getDefaultArgumentValueResolvers()); return array_merge([new AppArgumentValueResolver($app)], ArgumentResolver::getDefaultArgumentValueResolvers());
}; };
} }
......
...@@ -75,10 +75,10 @@ class LocaleListener implements EventSubscriberInterface ...@@ -75,10 +75,10 @@ class LocaleListener implements EventSubscriberInterface
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return [
// must be registered after the Router to have access to the _locale // must be registered after the Router to have access to the _locale
KernelEvents::REQUEST => array(array('onKernelRequest', 16)), KernelEvents::REQUEST => [['onKernelRequest', 16]],
KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), KernelEvents::FINISH_REQUEST => [['onKernelFinishRequest', 0]],
); ];
} }
} }
...@@ -46,7 +46,7 @@ class MonologServiceProvider implements ServiceProviderInterface, BootableProvid ...@@ -46,7 +46,7 @@ class MonologServiceProvider implements ServiceProviderInterface, BootableProvid
if (isset($app['request_stack'])) { if (isset($app['request_stack'])) {
$app['monolog.not_found_activation_strategy'] = function () use ($app) { $app['monolog.not_found_activation_strategy'] = function () use ($app) {
return new NotFoundActivationStrategy($app['request_stack'], array('^/'), $app['monolog.level']); return new NotFoundActivationStrategy($app['request_stack'], ['^/'], $app['monolog.level']);
}; };
} }
} }
...@@ -88,7 +88,7 @@ class MonologServiceProvider implements ServiceProviderInterface, BootableProvid ...@@ -88,7 +88,7 @@ class MonologServiceProvider implements ServiceProviderInterface, BootableProvid
}; };
$app['monolog.handlers'] = function () use ($app, $defaultHandler) { $app['monolog.handlers'] = function () use ($app, $defaultHandler) {
$handlers = array(); $handlers = [];
// enables the default handler if a logfile was set or the monolog.handler service was redefined // enables the default handler if a logfile was set or the monolog.handler service was redefined
if ($app['monolog.logfile'] || $defaultHandler !== $app->raw('monolog.handler')) { if ($app['monolog.logfile'] || $defaultHandler !== $app->raw('monolog.handler')) {
......
...@@ -54,17 +54,17 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen ...@@ -54,17 +54,17 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen
$app['security.authentication_provider.'.$name.'.remember_me'] = $app['security.authentication_provider.remember_me._proto']($name, $options); $app['security.authentication_provider.'.$name.'.remember_me'] = $app['security.authentication_provider.remember_me._proto']($name, $options);
} }
return array( return [
'security.authentication_provider.'.$name.'.remember_me', 'security.authentication_provider.'.$name.'.remember_me',
'security.authentication_listener.'.$name.'.remember_me', 'security.authentication_listener.'.$name.'.remember_me',
null, // entry point null, // entry point
'remember_me', 'remember_me',
); ];
}); });
$app['security.remember_me.service._proto'] = $app->protect(function ($providerKey, $options) use ($app) { $app['security.remember_me.service._proto'] = $app->protect(function ($providerKey, $options) use ($app) {
return function () use ($providerKey, $options, $app) { return function () use ($providerKey, $options, $app) {
$options = array_replace(array( $options = array_replace([
'name' => 'REMEMBERME', 'name' => 'REMEMBERME',
'lifetime' => 31536000, 'lifetime' => 31536000,
'path' => '/', 'path' => '/',
...@@ -73,9 +73,9 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen ...@@ -73,9 +73,9 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen
'httponly' => true, 'httponly' => true,
'always_remember_me' => false, 'always_remember_me' => false,
'remember_me_parameter' => '_remember_me', 'remember_me_parameter' => '_remember_me',
), $options); ], $options);
return new TokenBasedRememberMeServices(array($app['security.user_provider.'.$providerKey]), $options['key'], $providerKey, $options, $app['logger']); return new TokenBasedRememberMeServices([$app['security.user_provider.'.$providerKey]], $options['key'], $providerKey, $options, $app['logger']);
}; };
}); });
......
...@@ -29,7 +29,7 @@ class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher ...@@ -29,7 +29,7 @@ class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher
$url = $this->context->getBaseUrl().$path; $url = $this->context->getBaseUrl().$path;
$query = $this->context->getQueryString() ?: ''; $query = $this->context->getQueryString() ?: '';
if ($query !== '') { if ('' !== $query) {
$url .= '?'.$query; $url .= '?'.$query;
} }
...@@ -46,10 +46,10 @@ class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher ...@@ -46,10 +46,10 @@ class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher
} }
} }
return array( return [
'_controller' => function ($url) { return new RedirectResponse($url, 301); }, '_controller' => function ($url) { return new RedirectResponse($url, 301); },
'_route' => $route, '_route' => $route,
'url' => $url, 'url' => $url,
); ];
} }
} }
...@@ -40,11 +40,11 @@ class SerializerServiceProvider implements ServiceProviderInterface ...@@ -40,11 +40,11 @@ class SerializerServiceProvider implements ServiceProviderInterface
}; };
$app['serializer.encoders'] = function () { $app['serializer.encoders'] = function () {
return array(new JsonEncoder(), new XmlEncoder()); return [new JsonEncoder(), new XmlEncoder()];
}; };
$app['serializer.normalizers'] = function () { $app['serializer.normalizers'] = function () {
return array(new CustomNormalizer(), new GetSetMethodNormalizer()); return [new CustomNormalizer(), new GetSetMethodNormalizer()];
}; };
} }
} }
...@@ -68,7 +68,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -68,7 +68,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
return new TestSessionListener($app); return new TestSessionListener($app);
}; };
$app['session.storage.options'] = array(); $app['session.storage.options'] = [];
$app['session.default_locale'] = 'en'; $app['session.default_locale'] = 'en';
$app['session.storage.save_path'] = null; $app['session.storage.save_path'] = null;
$app['session.attribute_bag'] = null; $app['session.attribute_bag'] = null;
......
...@@ -28,7 +28,7 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -28,7 +28,7 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
{ {
public function register(Container $app) public function register(Container $app)
{ {
$app['swiftmailer.options'] = array(); $app['swiftmailer.options'] = [];
$app['swiftmailer.use_spool'] = true; $app['swiftmailer.use_spool'] = true;
$app['mailer.initialized'] = false; $app['mailer.initialized'] = false;
...@@ -51,11 +51,11 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -51,11 +51,11 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
$app['swiftmailer.transport'] = function ($app) { $app['swiftmailer.transport'] = function ($app) {
$transport = new \Swift_Transport_EsmtpTransport( $transport = new \Swift_Transport_EsmtpTransport(
$app['swiftmailer.transport.buffer'], $app['swiftmailer.transport.buffer'],
array($app['swiftmailer.transport.authhandler']), [$app['swiftmailer.transport.authhandler']],
$app['swiftmailer.transport.eventdispatcher'] $app['swiftmailer.transport.eventdispatcher']
); );
$options = $app['swiftmailer.options'] = array_replace(array( $options = $app['swiftmailer.options'] = array_replace([
'host' => 'localhost', 'host' => 'localhost',
'port' => 25, 'port' => 25,
'username' => '', 'username' => '',
...@@ -63,7 +63,7 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -63,7 +63,7 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
'encryption' => null, 'encryption' => null,
'auth_mode' => null, 'auth_mode' => null,
'stream_context_options' => [], 'stream_context_options' => [],
), $app['swiftmailer.options']); ], $app['swiftmailer.options']);
$transport->setHost($options['host']); $transport->setHost($options['host']);
$transport->setPort($options['port']); $transport->setPort($options['port']);
...@@ -81,11 +81,11 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -81,11 +81,11 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
}; };
$app['swiftmailer.transport.authhandler'] = function () { $app['swiftmailer.transport.authhandler'] = function () {
return new \Swift_Transport_Esmtp_AuthHandler(array( return new \Swift_Transport_Esmtp_AuthHandler([
new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(),
new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(),
new \Swift_Transport_Esmtp_Auth_PlainAuthenticator(), new \Swift_Transport_Esmtp_Auth_PlainAuthenticator(),
)); ]);
}; };
$app['swiftmailer.transport.eventdispatcher'] = function ($app) { $app['swiftmailer.transport.eventdispatcher'] = function ($app) {
...@@ -112,12 +112,12 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -112,12 +112,12 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
}; };
$app['swiftmailer.plugins'] = function ($app) { $app['swiftmailer.plugins'] = function ($app) {
return array(); return [];
}; };
$app['swiftmailer.sender_address'] = null; $app['swiftmailer.sender_address'] = null;
$app['swiftmailer.delivery_addresses'] = array(); $app['swiftmailer.delivery_addresses'] = [];
$app['swiftmailer.delivery_whitelist'] = array(); $app['swiftmailer.delivery_whitelist'] = [];
} }
public function subscribe(Container $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
......
...@@ -81,11 +81,11 @@ class TranslationServiceProvider implements ServiceProviderInterface, EventListe ...@@ -81,11 +81,11 @@ class TranslationServiceProvider implements ServiceProviderInterface, EventListe
}; };
$app['translator.resources'] = function ($app) { $app['translator.resources'] = function ($app) {
return array(); return [];
}; };
$app['translator.domains'] = array(); $app['translator.domains'] = [];
$app['locale_fallbacks'] = array('en'); $app['locale_fallbacks'] = ['en'];
$app['translator.cache_dir'] = null; $app['translator.cache_dir'] = null;
} }
......
...@@ -38,10 +38,10 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -38,10 +38,10 @@ class TwigServiceProvider implements ServiceProviderInterface
{ {
public function register(Container $app) public function register(Container $app)
{ {
$app['twig.options'] = array(); $app['twig.options'] = [];
$app['twig.form.templates'] = array('form_div_layout.html.twig'); $app['twig.form.templates'] = ['form_div_layout.html.twig'];
$app['twig.path'] = array(); $app['twig.path'] = [];
$app['twig.templates'] = array(); $app['twig.templates'] = [];
$app['twig.date.format'] = 'F j, Y H:i'; $app['twig.date.format'] = 'F j, Y H:i';
$app['twig.date.interval_format'] = '%d days'; $app['twig.date.interval_format'] = '%d days';
...@@ -53,11 +53,11 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -53,11 +53,11 @@ class TwigServiceProvider implements ServiceProviderInterface
$app['twig'] = function ($app) { $app['twig'] = function ($app) {
$app['twig.options'] = array_replace( $app['twig.options'] = array_replace(
array( [
'charset' => $app['charset'], 'charset' => $app['charset'],
'debug' => $app['debug'], 'debug' => $app['debug'],
'strict_variables' => $app['debug'], 'strict_variables' => $app['debug'],
), $app['twig.options'] ], $app['twig.options']
); );
$twig = $app['twig.environment_factory']($app); $twig = $app['twig.environment_factory']($app);
...@@ -155,7 +155,7 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -155,7 +155,7 @@ class TwigServiceProvider implements ServiceProviderInterface
$app['twig.loader.filesystem'] = function ($app) { $app['twig.loader.filesystem'] = function ($app) {
$loader = new \Twig_Loader_Filesystem(); $loader = new \Twig_Loader_Filesystem();
foreach (is_array($app['twig.path']) ? $app['twig.path'] : array($app['twig.path']) as $key => $val) { foreach (is_array($app['twig.path']) ? $app['twig.path'] : [$app['twig.path']] as $key => $val) {
if (is_string($key)) { if (is_string($key)) {
$loader->addPath($key, $val); $loader->addPath($key, $val);
} else { } else {
...@@ -171,10 +171,10 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -171,10 +171,10 @@ class TwigServiceProvider implements ServiceProviderInterface
}; };
$app['twig.loader'] = function ($app) { $app['twig.loader'] = function ($app) {
return new \Twig_Loader_Chain(array( return new \Twig_Loader_Chain([
$app['twig.loader.array'], $app['twig.loader.array'],
$app['twig.loader.filesystem'], $app['twig.loader.filesystem'],
)); ]);
}; };
$app['twig.environment_factory'] = $app->protect(function ($app) { $app['twig.environment_factory'] = $app->protect(function ($app) {
...@@ -186,10 +186,10 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -186,10 +186,10 @@ class TwigServiceProvider implements ServiceProviderInterface
}; };
$app['twig.runtimes'] = function ($app) { $app['twig.runtimes'] = function ($app) {
return array( return [
HttpKernelRuntime::class => 'twig.runtime.httpkernel', HttpKernelRuntime::class => 'twig.runtime.httpkernel',
TwigRenderer::class => 'twig.form.renderer', TwigRenderer::class => 'twig.form.renderer',
); ];
}; };
$app['twig.runtime_loader'] = function ($app) { $app['twig.runtime_loader'] = function ($app) {
......
...@@ -39,7 +39,7 @@ class ConstraintValidatorFactory extends BaseConstraintValidatorFactory ...@@ -39,7 +39,7 @@ class ConstraintValidatorFactory extends BaseConstraintValidatorFactory
* @param Container $container DI container * @param Container $container DI container
* @param array $serviceNames Validator service names * @param array $serviceNames Validator service names
*/ */
public function __construct(Container $container, array $serviceNames = array(), $propertyAccessor = null) public function __construct(Container $container, array $serviceNames = [], $propertyAccessor = null)
{ {
parent::__construct($propertyAccessor); parent::__construct($propertyAccessor);
......
...@@ -54,9 +54,9 @@ class ValidatorServiceProvider implements ServiceProviderInterface ...@@ -54,9 +54,9 @@ class ValidatorServiceProvider implements ServiceProviderInterface
}; };
$app['validator.object_initializers'] = function ($app) { $app['validator.object_initializers'] = function ($app) {
return array(); return [];
}; };
$app['validator.validator_service_ids'] = array(); $app['validator.validator_service_ids'] = [];
} }
} }
...@@ -35,7 +35,7 @@ class Route extends BaseRoute ...@@ -35,7 +35,7 @@ class Route extends BaseRoute
* @param string|array $schemes A required URI scheme or an array of restricted schemes * @param string|array $schemes A required URI scheme or an array of restricted schemes
* @param string|array $methods A required HTTP method or an array of restricted methods * @param string|array $methods A required HTTP method or an array of restricted methods
*/ */
public function __construct($path = '/', array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array()) public function __construct($path = '/', array $defaults = [], array $requirements = [], array $options = [], $host = '', $schemes = [], $methods = [])
{ {
// overridden constructor to make $path optional // overridden constructor to make $path optional
parent::__construct($path, $defaults, $requirements, $options, $host, $schemes, $methods); parent::__construct($path, $defaults, $requirements, $options, $host, $schemes, $methods);
......
...@@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; ...@@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
/** /**
* Enables name_of_service:method_name syntax for declaring controllers. * Enables name_of_service:method_name syntax for declaring controllers.
* *
* @link http://silex.sensiolabs.org/doc/providers/service_controller.html * @see http://silex.sensiolabs.org/doc/providers/service_controller.html
*/ */
class ServiceControllerResolver implements ControllerResolverInterface class ServiceControllerResolver implements ControllerResolverInterface
{ {
......
...@@ -54,7 +54,7 @@ abstract class WebTestCase extends TestCase ...@@ -54,7 +54,7 @@ abstract class WebTestCase extends TestCase
* *
* @return Client A Client instance * @return Client A Client instance
*/ */
public function createClient(array $server = array()) public function createClient(array $server = [])
{ {
if (!class_exists('Symfony\Component\BrowserKit\Client')) { if (!class_exists('Symfony\Component\BrowserKit\Client')) {
throw new \LogicException('Component "symfony/browser-kit" is required by WebTestCase.'.PHP_EOL.'Run composer require symfony/browser-kit'); throw new \LogicException('Component "symfony/browser-kit" is required by WebTestCase.'.PHP_EOL.'Run composer require symfony/browser-kit');
......
...@@ -28,7 +28,7 @@ class MonologTraitTest extends TestCase ...@@ -28,7 +28,7 @@ class MonologTraitTest extends TestCase
$app = $this->createApplication(); $app = $this->createApplication();
$app->log('Foo'); $app->log('Foo');
$app->log('Bar', array(), Logger::DEBUG); $app->log('Bar', [], Logger::DEBUG);
$this->assertTrue($app['monolog.handler']->hasInfo('Foo')); $this->assertTrue($app['monolog.handler']->hasInfo('Foo'));
$this->assertTrue($app['monolog.handler']->hasDebug('Bar')); $this->assertTrue($app['monolog.handler']->hasDebug('Bar'));
} }
...@@ -36,12 +36,12 @@ class MonologTraitTest extends TestCase ...@@ -36,12 +36,12 @@ class MonologTraitTest extends TestCase
public function createApplication() public function createApplication()
{ {
$app = new MonologApplication(); $app = new MonologApplication();
$app->register(new MonologServiceProvider(), array( $app->register(new MonologServiceProvider(), [
'monolog.handler' => function () use ($app) { 'monolog.handler' => function () use ($app) {
return new TestHandler($app['monolog.level']); return new TestHandler($app['monolog.level']);
}, },
'monolog.logfile' => 'php://memory', 'monolog.logfile' => 'php://memory',
)); ]);
return $app; return $app;
} }
......
...@@ -25,9 +25,9 @@ class SecurityTraitTest extends TestCase ...@@ -25,9 +25,9 @@ class SecurityTraitTest extends TestCase
{ {
public function testEncodePassword() public function testEncodePassword()
{ {
$app = $this->createApplication(array( $app = $this->createApplication([
'fabien' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), 'fabien' => ['ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'],
)); ]);
$user = new User('foo', 'bar'); $user = new User('foo', 'bar');
$password = 'foo'; $password = 'foo';
...@@ -53,10 +53,10 @@ class SecurityTraitTest extends TestCase ...@@ -53,10 +53,10 @@ class SecurityTraitTest extends TestCase
{ {
$request = Request::create('/'); $request = Request::create('/');
$app = $this->createApplication(array( $app = $this->createApplication([
'fabien' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), 'fabien' => ['ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'],
'monique' => array('ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), 'monique' => ['ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'],
)); ]);
$app->get('/', function () { return 'foo'; }); $app->get('/', function () { return 'foo'; });
// User is Monique (ROLE_USER) // User is Monique (ROLE_USER)
...@@ -74,17 +74,17 @@ class SecurityTraitTest extends TestCase ...@@ -74,17 +74,17 @@ class SecurityTraitTest extends TestCase
$this->assertTrue($app->isGranted('ROLE_ADMIN')); $this->assertTrue($app->isGranted('ROLE_ADMIN'));
} }
public function createApplication($users = array()) public function createApplication($users = [])
{ {
$app = new SecurityApplication(); $app = new SecurityApplication();
$app->register(new SecurityServiceProvider(), array( $app->register(new SecurityServiceProvider(), [
'security.firewalls' => array( 'security.firewalls' => [
'default' => array( 'default' => [
'http' => true, 'http' => true,
'users' => $users, 'users' => $users,
), ],
), ],
)); ]);
return $app; return $app;
} }
......
...@@ -42,7 +42,7 @@ class TwigTraitTest extends TestCase ...@@ -42,7 +42,7 @@ class TwigTraitTest extends TestCase
$app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$mailer->expects($this->once())->method('render')->will($this->returnValue('foo')); $mailer->expects($this->once())->method('render')->will($this->returnValue('foo'));
$response = $app->render('view', array(), new Response('', 404)); $response = $app->render('view', [], new Response('', 404));
$this->assertEquals(404, $response->getStatusCode()); $this->assertEquals(404, $response->getStatusCode());
} }
...@@ -53,7 +53,7 @@ class TwigTraitTest extends TestCase ...@@ -53,7 +53,7 @@ class TwigTraitTest extends TestCase
$app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$mailer->expects($this->once())->method('display')->will($this->returnCallback(function () { echo 'foo'; })); $mailer->expects($this->once())->method('display')->will($this->returnCallback(function () { echo 'foo'; }));
$response = $app->render('view', array(), new StreamedResponse()); $response = $app->render('view', [], new StreamedResponse());
$this->assertEquals('Symfony\Component\HttpFoundation\StreamedResponse', get_class($response)); $this->assertEquals('Symfony\Component\HttpFoundation\StreamedResponse', get_class($response));
ob_start(); ob_start();
......
...@@ -25,7 +25,7 @@ class UrlGeneratorTraitTest extends TestCase ...@@ -25,7 +25,7 @@ class UrlGeneratorTraitTest extends TestCase
{ {
$app = new UrlGeneratorApplication(); $app = new UrlGeneratorApplication();
$app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock(); $app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock();
$app['url_generator']->expects($this->once())->method('generate')->with('foo', array(), UrlGeneratorInterface::ABSOLUTE_URL); $app['url_generator']->expects($this->once())->method('generate')->with('foo', [], UrlGeneratorInterface::ABSOLUTE_URL);
$app->url('foo'); $app->url('foo');
} }
...@@ -33,7 +33,7 @@ class UrlGeneratorTraitTest extends TestCase ...@@ -33,7 +33,7 @@ class UrlGeneratorTraitTest extends TestCase
{ {
$app = new UrlGeneratorApplication(); $app = new UrlGeneratorApplication();
$app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock(); $app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock();
$app['url_generator']->expects($this->once())->method('generate')->with('foo', array(), UrlGeneratorInterface::ABSOLUTE_PATH); $app['url_generator']->expects($this->once())->method('generate')->with('foo', [], UrlGeneratorInterface::ABSOLUTE_PATH);
$app->path('foo'); $app->path('foo');
} }
} }
...@@ -60,12 +60,12 @@ class ApplicationTest extends TestCase ...@@ -60,12 +60,12 @@ class ApplicationTest extends TestCase
public function testConstructorInjection() public function testConstructorInjection()
{ {
// inject a custom parameter // inject a custom parameter
$params = array('param' => 'value'); $params = ['param' => 'value'];
$app = new Application($params); $app = new Application($params);
$this->assertSame($params['param'], $app['param']); $this->assertSame($params['param'], $app['param']);
// inject an existing parameter // inject an existing parameter
$params = array('locale' => 'value'); $params = ['locale' => 'value'];
$app = new Application($params); $app = new Application($params);
$this->assertSame($params['locale'], $app['locale']); $this->assertSame($params['locale'], $app['locale']);
} }
...@@ -116,14 +116,14 @@ class ApplicationTest extends TestCase ...@@ -116,14 +116,14 @@ class ApplicationTest extends TestCase
$app->get('/foo/{foo}', function (\ArrayObject $foo) { $app->get('/foo/{foo}', function (\ArrayObject $foo) {
return $foo['foo']; return $foo['foo'];
})->convert('foo', function ($foo) { return new \ArrayObject(array('foo' => $foo)); }); })->convert('foo', function ($foo) { return new \ArrayObject(['foo' => $foo]); });
$response = $app->handle(Request::create('/foo/bar')); $response = $app->handle(Request::create('/foo/bar'));
$this->assertEquals('bar', $response->getContent()); $this->assertEquals('bar', $response->getContent());
$app->get('/foo/{foo}/{bar}', function (\ArrayObject $foo) { $app->get('/foo/{foo}/{bar}', function (\ArrayObject $foo) {
return $foo['foo']; return $foo['foo'];
})->convert('foo', function ($foo, Request $request) { return new \ArrayObject(array('foo' => $foo.$request->attributes->get('bar'))); }); })->convert('foo', function ($foo, Request $request) { return new \ArrayObject(['foo' => $foo.$request->attributes->get('bar')]); });
$response = $app->handle(Request::create('/foo/foo/bar')); $response = $app->handle(Request::create('/foo/foo/bar'));
$this->assertEquals('foobar', $response->getContent()); $this->assertEquals('foobar', $response->getContent());
...@@ -167,13 +167,13 @@ class ApplicationTest extends TestCase ...@@ -167,13 +167,13 @@ class ApplicationTest extends TestCase
public function escapeProvider() public function escapeProvider()
{ {
return array( return [
array('&lt;', '<'), ['&lt;', '<'],
array('&gt;', '>'), ['&gt;', '>'],
array('&quot;', '"'), ['&quot;', '"'],
array("'", "'"), ["'", "'"],
array('abc', 'abc'), ['abc', 'abc'],
); ];
} }
public function testControllersAsMethods() public function testControllersAsMethods()
...@@ -234,7 +234,7 @@ class ApplicationTest extends TestCase ...@@ -234,7 +234,7 @@ class ApplicationTest extends TestCase
$test = $this; $test = $this;
$middlewareTarget = array(); $middlewareTarget = [];
$beforeMiddleware1 = function (Request $request) use (&$middlewareTarget, $test) { $beforeMiddleware1 = function (Request $request) use (&$middlewareTarget, $test) {
$test->assertEquals('/reached', $request->getRequestUri()); $test->assertEquals('/reached', $request->getRequestUri());
$middlewareTarget[] = 'before_middleware1_triggered'; $middlewareTarget[] = 'before_middleware1_triggered';
...@@ -277,7 +277,7 @@ class ApplicationTest extends TestCase ...@@ -277,7 +277,7 @@ class ApplicationTest extends TestCase
$result = $app->handle(Request::create('/reached')); $result = $app->handle(Request::create('/reached'));
$this->assertSame(array('before_middleware1_triggered', 'before_middleware2_triggered', 'route_triggered', 'after_middleware1_triggered', 'after_middleware2_triggered'), $middlewareTarget); $this->assertSame(['before_middleware1_triggered', 'before_middleware2_triggered', 'route_triggered', 'after_middleware1_triggered', 'after_middleware2_triggered'], $middlewareTarget);
$this->assertEquals('hello', $result->getContent()); $this->assertEquals('hello', $result->getContent());
} }
...@@ -337,7 +337,7 @@ class ApplicationTest extends TestCase ...@@ -337,7 +337,7 @@ class ApplicationTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$middlewareTarget = array(); $middlewareTarget = [];
$middleware = function (Request $request) use (&$middlewareTarget) { $middleware = function (Request $request) use (&$middlewareTarget) {
$middlewareTarget[] = 'middleware_triggered'; $middlewareTarget[] = 'middleware_triggered';
}; };
...@@ -353,14 +353,14 @@ class ApplicationTest extends TestCase ...@@ -353,14 +353,14 @@ class ApplicationTest extends TestCase
$app->handle(Request::create('/foo')); $app->handle(Request::create('/foo'));
$this->assertSame(array('before_triggered', 'middleware_triggered', 'route_triggered'), $middlewareTarget); $this->assertSame(['before_triggered', 'middleware_triggered', 'route_triggered'], $middlewareTarget);
} }
public function testRoutesAfterMiddlewaresTriggeredBeforeSilexAfterFilters() public function testRoutesAfterMiddlewaresTriggeredBeforeSilexAfterFilters()
{ {
$app = new Application(); $app = new Application();
$middlewareTarget = array(); $middlewareTarget = [];
$middleware = function (Request $request) use (&$middlewareTarget) { $middleware = function (Request $request) use (&$middlewareTarget) {
$middlewareTarget[] = 'middleware_triggered'; $middlewareTarget[] = 'middleware_triggered';
}; };
...@@ -376,12 +376,12 @@ class ApplicationTest extends TestCase ...@@ -376,12 +376,12 @@ class ApplicationTest extends TestCase
$app->handle(Request::create('/foo')); $app->handle(Request::create('/foo'));
$this->assertSame(array('route_triggered', 'middleware_triggered', 'after_triggered'), $middlewareTarget); $this->assertSame(['route_triggered', 'middleware_triggered', 'after_triggered'], $middlewareTarget);
} }
public function testFinishFilter() public function testFinishFilter()
{ {
$containerTarget = array(); $containerTarget = [];
$app = new Application(); $app = new Application();
...@@ -403,7 +403,7 @@ class ApplicationTest extends TestCase ...@@ -403,7 +403,7 @@ class ApplicationTest extends TestCase
$app->run(Request::create('/foo')); $app->run(Request::create('/foo'));
$this->assertSame(array('1_routeTriggered', '2_filterAfter', '3_responseSent', '4_filterFinish'), $containerTarget); $this->assertSame(['1_routeTriggered', '2_filterAfter', '3_responseSent', '4_filterFinish'], $containerTarget);
} }
/** /**
...@@ -485,7 +485,7 @@ class ApplicationTest extends TestCase ...@@ -485,7 +485,7 @@ class ApplicationTest extends TestCase
$app->get('/after')->bind('third'); $app->get('/after')->bind('third');
$app->flush(); $app->flush();
$this->assertEquals(array('first', 'second', 'third'), array_keys(iterator_to_array($app['routes']))); $this->assertEquals(['first', 'second', 'third'], array_keys(iterator_to_array($app['routes'])));
} }
/** /**
...@@ -524,7 +524,7 @@ class ApplicationTest extends TestCase ...@@ -524,7 +524,7 @@ class ApplicationTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$response = $app->sendFile(__FILE__, 200, array('Content-Type: application/php')); $response = $app->sendFile(__FILE__, 200, ['Content-Type: application/php']);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\BinaryFileResponse', $response); $this->assertInstanceOf('Symfony\Component\HttpFoundation\BinaryFileResponse', $response);
$this->assertEquals(__FILE__, (string) $response->getFile()); $this->assertEquals(__FILE__, (string) $response->getFile());
} }
...@@ -569,7 +569,7 @@ class ApplicationTest extends TestCase ...@@ -569,7 +569,7 @@ class ApplicationTest extends TestCase
public function testViewListenerWithArrayTypeHint() public function testViewListenerWithArrayTypeHint()
{ {
$app = new Application(); $app = new Application();
$app->get('/foo', function () { return array('ok'); }); $app->get('/foo', function () { return ['ok']; });
$app->view(function (array $view) { $app->view(function (array $view) {
return new Response($view[0]); return new Response($view[0]);
}); });
...@@ -582,7 +582,7 @@ class ApplicationTest extends TestCase ...@@ -582,7 +582,7 @@ class ApplicationTest extends TestCase
public function testViewListenerWithObjectTypeHint() public function testViewListenerWithObjectTypeHint()
{ {
$app = new Application(); $app = new Application();
$app->get('/foo', function () { return (object) array('name' => 'world'); }); $app->get('/foo', function () { return (object) ['name' => 'world']; });
$app->view(function (\stdClass $view) { $app->view(function (\stdClass $view) {
return new Response('Hello '.$view->name); return new Response('Hello '.$view->name);
}); });
...@@ -608,10 +608,10 @@ class ApplicationTest extends TestCase ...@@ -608,10 +608,10 @@ class ApplicationTest extends TestCase
public function testViewListenersCanBeChained() public function testViewListenersCanBeChained()
{ {
$app = new Application(); $app = new Application();
$app->get('/foo', function () { return (object) array('name' => 'world'); }); $app->get('/foo', function () { return (object) ['name' => 'world']; });
$app->view(function (\stdClass $view) { $app->view(function (\stdClass $view) {
return array('msg' => 'Hello '.$view->name); return ['msg' => 'Hello '.$view->name];
}); });
$app->view(function (array $view) { $app->view(function (array $view) {
......
...@@ -37,7 +37,7 @@ class CallbackResolverTest extends Testcase ...@@ -37,7 +37,7 @@ class CallbackResolverTest extends Testcase
$this->assertTrue($this->resolver->isValid('some_service:methodName')); $this->assertTrue($this->resolver->isValid('some_service:methodName'));
$this->assertTrue($this->resolver->isValid('callable_service')); $this->assertTrue($this->resolver->isValid('callable_service'));
$this->assertEquals( $this->assertEquals(
array($this->app['some_service'], 'append'), [$this->app['some_service'], 'append'],
$this->resolver->convertCallback('some_service:append') $this->resolver->convertCallback('some_service:append')
); );
$this->assertSame($callable, $this->resolver->convertCallback('callable_service')); $this->assertSame($callable, $this->resolver->convertCallback('callable_service'));
...@@ -53,11 +53,11 @@ class CallbackResolverTest extends Testcase ...@@ -53,11 +53,11 @@ class CallbackResolverTest extends Testcase
public function nonStringsAreNotValidProvider() public function nonStringsAreNotValidProvider()
{ {
return array( return [
array(null), [null],
array('some_service::methodName'), ['some_service::methodName'],
array('missing_service'), ['missing_service'],
); ];
} }
/** /**
...@@ -68,15 +68,15 @@ class CallbackResolverTest extends Testcase ...@@ -68,15 +68,15 @@ class CallbackResolverTest extends Testcase
public function testShouldThrowAnExceptionIfServiceIsNotCallable($name) public function testShouldThrowAnExceptionIfServiceIsNotCallable($name)
{ {
$this->app['non_callable_obj'] = function () { return new \stdClass(); }; $this->app['non_callable_obj'] = function () { return new \stdClass(); };
$this->app['non_callable'] = function () { return array(); }; $this->app['non_callable'] = function () { return []; };
$this->resolver->convertCallback($name); $this->resolver->convertCallback($name);
} }
public function shouldThrowAnExceptionIfServiceIsNotCallableProvider() public function shouldThrowAnExceptionIfServiceIsNotCallableProvider()
{ {
return array( return [
array('non_callable_obj:methodA'), ['non_callable_obj:methodA'],
array('non_callable'), ['non_callable'],
); ];
} }
} }
...@@ -23,7 +23,7 @@ use Silex\Provider\ServiceControllerServiceProvider; ...@@ -23,7 +23,7 @@ use Silex\Provider\ServiceControllerServiceProvider;
*/ */
class CallbackServicesTest extends TestCase class CallbackServicesTest extends TestCase
{ {
public $called = array(); public $called = [];
public function testCallbacksAsServices() public function testCallbacksAsServices()
{ {
...@@ -51,7 +51,7 @@ class CallbackServicesTest extends TestCase ...@@ -51,7 +51,7 @@ class CallbackServicesTest extends TestCase
$response = $app->handle($request); $response = $app->handle($request);
$app->terminate($request, $response); $app->terminate($request, $response);
$this->assertEquals(array( $this->assertEquals([
'BEFORE APP', 'BEFORE APP',
'ON REQUEST', 'ON REQUEST',
'BEFORE', 'BEFORE',
...@@ -60,7 +60,7 @@ class CallbackServicesTest extends TestCase ...@@ -60,7 +60,7 @@ class CallbackServicesTest extends TestCase
'AFTER', 'AFTER',
'AFTER APP', 'AFTER APP',
'FINISH APP', 'FINISH APP',
), $app['service']->called); ], $app['service']->called);
} }
public function controller(Application $app) public function controller(Application $app)
......
...@@ -94,7 +94,7 @@ class ControllerCollectionTest extends TestCase ...@@ -94,7 +94,7 @@ class ControllerCollectionTest extends TestCase
$routes = $controllers->flush(); $routes = $controllers->flush();
$this->assertCount(3, $routes->all()); $this->assertCount(3, $routes->all());
$this->assertEquals(array('_a_a', '_a_a_1', '_a_a_2'), array_keys($routes->all())); $this->assertEquals(['_a_a', '_a_a_1', '_a_a_2'], array_keys($routes->all()));
} }
public function testUniqueGeneratedRouteNamesAmongMounts() public function testUniqueGeneratedRouteNamesAmongMounts()
...@@ -110,7 +110,7 @@ class ControllerCollectionTest extends TestCase ...@@ -110,7 +110,7 @@ class ControllerCollectionTest extends TestCase
$routes = $controllers->flush(); $routes = $controllers->flush();
$this->assertCount(2, $routes->all()); $this->assertCount(2, $routes->all());
$this->assertEquals(array('_root_a_leaf', '_root_a_leaf_1'), array_keys($routes->all())); $this->assertEquals(['_root_a_leaf', '_root_a_leaf_1'], array_keys($routes->all()));
} }
public function testUniqueGeneratedRouteNamesAmongNestedMounts() public function testUniqueGeneratedRouteNamesAmongNestedMounts()
...@@ -129,7 +129,7 @@ class ControllerCollectionTest extends TestCase ...@@ -129,7 +129,7 @@ class ControllerCollectionTest extends TestCase
$routes = $controllers->flush(); $routes = $controllers->flush();
$this->assertCount(2, $routes->all()); $this->assertCount(2, $routes->all());
$this->assertEquals(array('_root_a_tree_leaf', '_root_a_tree_leaf_1'), array_keys($routes->all())); $this->assertEquals(['_root_a_tree_leaf', '_root_a_tree_leaf_1'], array_keys($routes->all()));
} }
public function testMountCallable() public function testMountCallable()
...@@ -158,7 +158,7 @@ class ControllerCollectionTest extends TestCase ...@@ -158,7 +158,7 @@ class ControllerCollectionTest extends TestCase
$routes = $controllers->flush(); $routes = $controllers->flush();
$subRoutes = $subControllers->flush(); $subRoutes = $subControllers->flush();
$this->assertTrue($routes->count() == 2 && $subRoutes->count() == 0); $this->assertTrue(2 == $routes->count() && 0 == $subRoutes->count());
} }
public function testMountControllersFactory() public function testMountControllersFactory()
...@@ -231,7 +231,7 @@ class ControllerCollectionTest extends TestCase ...@@ -231,7 +231,7 @@ class ControllerCollectionTest extends TestCase
$controller = $controllers->match('/{id}/{name}/{extra}', function () {})->convert('name', 'Fabien')->convert('extra', 'Symfony'); $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->convert('name', 'Fabien')->convert('extra', 'Symfony');
$controllers->convert('extra', 'Twig'); $controllers->convert('extra', 'Twig');
$this->assertEquals(array('id' => '1', 'name' => 'Fabien', 'extra' => 'Twig'), $controller->getRoute()->getOption('_converters')); $this->assertEquals(['id' => '1', 'name' => 'Fabien', 'extra' => 'Twig'], $controller->getRoute()->getOption('_converters'));
} }
public function testRequireHttp() public function testRequireHttp()
...@@ -240,11 +240,11 @@ class ControllerCollectionTest extends TestCase ...@@ -240,11 +240,11 @@ class ControllerCollectionTest extends TestCase
$controllers->requireHttp(); $controllers->requireHttp();
$controller = $controllers->match('/{id}/{name}/{extra}', function () {})->requireHttps(); $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->requireHttps();
$this->assertEquals(array('https'), $controller->getRoute()->getSchemes()); $this->assertEquals(['https'], $controller->getRoute()->getSchemes());
$controllers->requireHttp(); $controllers->requireHttp();
$this->assertEquals(array('http'), $controller->getRoute()->getSchemes()); $this->assertEquals(['http'], $controller->getRoute()->getSchemes());
} }
public function testBefore() public function testBefore()
...@@ -254,7 +254,7 @@ class ControllerCollectionTest extends TestCase ...@@ -254,7 +254,7 @@ class ControllerCollectionTest extends TestCase
$controller = $controllers->match('/{id}/{name}/{extra}', function () {})->before('mid2'); $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->before('mid2');
$controllers->before('mid3'); $controllers->before('mid3');
$this->assertEquals(array('mid1', 'mid2', 'mid3'), $controller->getRoute()->getOption('_before_middlewares')); $this->assertEquals(['mid1', 'mid2', 'mid3'], $controller->getRoute()->getOption('_before_middlewares'));
} }
public function testAfter() public function testAfter()
...@@ -264,7 +264,7 @@ class ControllerCollectionTest extends TestCase ...@@ -264,7 +264,7 @@ class ControllerCollectionTest extends TestCase
$controller = $controllers->match('/{id}/{name}/{extra}', function () {})->after('mid2'); $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->after('mid2');
$controllers->after('mid3'); $controllers->after('mid3');
$this->assertEquals(array('mid1', 'mid2', 'mid3'), $controller->getRoute()->getOption('_after_middlewares')); $this->assertEquals(['mid1', 'mid2', 'mid3'], $controller->getRoute()->getOption('_after_middlewares'));
} }
public function testWhen() public function testWhen()
...@@ -309,9 +309,9 @@ class ControllerCollectionTest extends TestCase ...@@ -309,9 +309,9 @@ class ControllerCollectionTest extends TestCase
$cl1->flush(); $cl1->flush();
$this->assertEquals(array('before'), $c1->getRoute()->getOption('_before_middlewares')); $this->assertEquals(['before'], $c1->getRoute()->getOption('_before_middlewares'));
$this->assertEquals(array('before'), $c2->getRoute()->getOption('_before_middlewares')); $this->assertEquals(['before'], $c2->getRoute()->getOption('_before_middlewares'));
$this->assertEquals(array('before'), $c3->getRoute()->getOption('_before_middlewares')); $this->assertEquals(['before'], $c3->getRoute()->getOption('_before_middlewares'));
} }
public function testRoutesFactoryOmitted() public function testRoutesFactoryOmitted()
......
...@@ -48,7 +48,7 @@ class ControllerTest extends TestCase ...@@ -48,7 +48,7 @@ class ControllerTest extends TestCase
$ret = $controller->assert('bar', '\d+'); $ret = $controller->assert('bar', '\d+');
$this->assertSame($ret, $controller); $this->assertSame($ret, $controller);
$this->assertEquals(array('bar' => '\d+'), $controller->getRoute()->getRequirements()); $this->assertEquals(['bar' => '\d+'], $controller->getRoute()->getRequirements());
} }
public function testValue() public function testValue()
...@@ -57,7 +57,7 @@ class ControllerTest extends TestCase ...@@ -57,7 +57,7 @@ class ControllerTest extends TestCase
$ret = $controller->value('bar', 'foo'); $ret = $controller->value('bar', 'foo');
$this->assertSame($ret, $controller); $this->assertSame($ret, $controller);
$this->assertEquals(array('bar' => 'foo'), $controller->getRoute()->getDefaults()); $this->assertEquals(['bar' => 'foo'], $controller->getRoute()->getDefaults());
} }
public function testConvert() public function testConvert()
...@@ -66,7 +66,7 @@ class ControllerTest extends TestCase ...@@ -66,7 +66,7 @@ class ControllerTest extends TestCase
$ret = $controller->convert('bar', $func = function ($bar) { return $bar; }); $ret = $controller->convert('bar', $func = function ($bar) { return $bar; });
$this->assertSame($ret, $controller); $this->assertSame($ret, $controller);
$this->assertEquals(array('bar' => $func), $controller->getRoute()->getOption('_converters')); $this->assertEquals(['bar' => $func], $controller->getRoute()->getOption('_converters'));
} }
public function testRun() public function testRun()
...@@ -91,13 +91,13 @@ class ControllerTest extends TestCase ...@@ -91,13 +91,13 @@ class ControllerTest extends TestCase
public function provideRouteAndExpectedRouteName() public function provideRouteAndExpectedRouteName()
{ {
return array( return [
array(new Route('/Invalid%Symbols#Stripped', array(), array(), array(), '', array(), array('POST')), '', 'POST_InvalidSymbolsStripped'), [new Route('/Invalid%Symbols#Stripped', [], [], [], '', [], ['POST']), '', 'POST_InvalidSymbolsStripped'],
array(new Route('/post/{id}', array(), array(), array(), '', array(), array('GET')), '', 'GET_post_id'), [new Route('/post/{id}', [], [], [], '', [], ['GET']), '', 'GET_post_id'],
array(new Route('/colon:pipe|dashes-escaped'), '', '_colon_pipe_dashes_escaped'), [new Route('/colon:pipe|dashes-escaped'), '', '_colon_pipe_dashes_escaped'],
array(new Route('/underscores_and.periods'), '', '_underscores_and.periods'), [new Route('/underscores_and.periods'), '', '_underscores_and.periods'],
array(new Route('/post/{id}', array(), array(), array(), '', array(), array('GET')), 'prefix', 'GET_prefix_post_id'), [new Route('/post/{id}', [], [], [], '', [], ['GET']), 'prefix', 'GET_prefix_post_id'],
); ];
} }
public function testRouteExtension() public function testRouteExtension()
......
...@@ -381,7 +381,7 @@ class ExceptionHandlerTest extends TestCase ...@@ -381,7 +381,7 @@ class ExceptionHandlerTest extends TestCase
}); });
// Array style callback for error handler // Array style callback for error handler
$app->error(array($this, 'exceptionHandler')); $app->error([$this, 'exceptionHandler']);
$request = Request::create('/foo'); $request = Request::create('/foo');
$response = $app->handle($request); $response = $app->handle($request);
......
...@@ -28,14 +28,14 @@ class JsonTest extends TestCase ...@@ -28,14 +28,14 @@ class JsonTest extends TestCase
$response = $app->json(); $response = $app->json();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
$response = json_decode($response->getContent(), true); $response = json_decode($response->getContent(), true);
$this->assertSame(array(), $response); $this->assertSame([], $response);
} }
public function testJsonUsesData() public function testJsonUsesData()
{ {
$app = new Application(); $app = new Application();
$response = $app->json(array('foo' => 'bar')); $response = $app->json(['foo' => 'bar']);
$this->assertSame('{"foo":"bar"}', $response->getContent()); $this->assertSame('{"foo":"bar"}', $response->getContent());
} }
...@@ -43,7 +43,7 @@ class JsonTest extends TestCase ...@@ -43,7 +43,7 @@ class JsonTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$response = $app->json(array(), 202); $response = $app->json([], 202);
$this->assertSame(202, $response->getStatusCode()); $this->assertSame(202, $response->getStatusCode());
} }
...@@ -51,7 +51,7 @@ class JsonTest extends TestCase ...@@ -51,7 +51,7 @@ class JsonTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$response = $app->json(array(), 200, array('ETag' => 'foo')); $response = $app->json([], 200, ['ETag' => 'foo']);
$this->assertSame('foo', $response->headers->get('ETag')); $this->assertSame('foo', $response->headers->get('ETag'));
} }
} }
...@@ -255,7 +255,7 @@ class MiddlewareTest extends TestCase ...@@ -255,7 +255,7 @@ class MiddlewareTest extends TestCase
$test = $this; $test = $this;
$middlewareTarget = array(); $middlewareTarget = [];
$applicationBeforeMiddleware = function ($request, $app) use (&$middlewareTarget, $test) { $applicationBeforeMiddleware = function ($request, $app) use (&$middlewareTarget, $test) {
$test->assertInstanceOf('\Symfony\Component\HttpFoundation\Request', $request); $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Request', $request);
$test->assertInstanceOf('\Silex\Application', $app); $test->assertInstanceOf('\Silex\Application', $app);
...@@ -303,6 +303,6 @@ class MiddlewareTest extends TestCase ...@@ -303,6 +303,6 @@ class MiddlewareTest extends TestCase
$response = $app->handle($request); $response = $app->handle($request);
$app->terminate($request, $response); $app->terminate($request, $response);
$this->assertSame(array('application_before_middleware_triggered', 'route_before_middleware_triggered', 'route_after_middleware_triggered', 'application_after_middleware_triggered', 'application_finish_middleware_triggered'), $middlewareTarget); $this->assertSame(['application_before_middleware_triggered', 'route_before_middleware_triggered', 'route_after_middleware_triggered', 'application_after_middleware_triggered', 'application_finish_middleware_triggered'], $middlewareTarget);
} }
} }
...@@ -20,14 +20,14 @@ class AssetServiceProviderTest extends TestCase ...@@ -20,14 +20,14 @@ class AssetServiceProviderTest extends TestCase
public function testGenerateAssetUrl() public function testGenerateAssetUrl()
{ {
$app = new Application(); $app = new Application();
$app->register(new AssetServiceProvider(), array( $app->register(new AssetServiceProvider(), [
'assets.version' => 'v1', 'assets.version' => 'v1',
'assets.version_format' => '%s?version=%s', 'assets.version_format' => '%s?version=%s',
'assets.named_packages' => array( 'assets.named_packages' => [
'css' => array('version' => 'css2', 'base_path' => '/whatever-makes-sense'), 'css' => ['version' => 'css2', 'base_path' => '/whatever-makes-sense'],
'images' => array('base_urls' => array('https://img.example.com')), 'images' => ['base_urls' => ['https://img.example.com']],
), ],
)); ]);
$this->assertEquals('/foo.png?version=v1', $app['assets.packages']->getUrl('/foo.png')); $this->assertEquals('/foo.png?version=v1', $app['assets.packages']->getUrl('/foo.png'));
$this->assertEquals('/whatever-makes-sense/foo.css?css2', $app['assets.packages']->getUrl('foo.css', 'css')); $this->assertEquals('/whatever-makes-sense/foo.css?css2', $app['assets.packages']->getUrl('foo.css', 'css'));
...@@ -43,9 +43,9 @@ class AssetServiceProviderTest extends TestCase ...@@ -43,9 +43,9 @@ class AssetServiceProviderTest extends TestCase
} }
$app = new Application(); $app = new Application();
$app->register(new AssetServiceProvider(), array( $app->register(new AssetServiceProvider(), [
'assets.json_manifest_path' => __DIR__.'/../Fixtures/manifest.json', 'assets.json_manifest_path' => __DIR__.'/../Fixtures/manifest.json',
)); ]);
$this->assertEquals('/some-random-hash.js', $app['assets.packages']->getUrl('app.js')); $this->assertEquals('/some-random-hash.js', $app['assets.packages']->getUrl('app.js'));
} }
......
...@@ -38,9 +38,9 @@ class DoctrineServiceProviderTest extends TestCase ...@@ -38,9 +38,9 @@ class DoctrineServiceProviderTest extends TestCase
} }
$app = new Application(); $app = new Application();
$app->register(new DoctrineServiceProvider(), array( $app->register(new DoctrineServiceProvider(), [
'db.options' => array('driver' => 'pdo_sqlite', 'memory' => true), 'db.options' => ['driver' => 'pdo_sqlite', 'memory' => true],
)); ]);
$db = $app['db']; $db = $app['db'];
$params = $db->getParams(); $params = $db->getParams();
...@@ -59,12 +59,12 @@ class DoctrineServiceProviderTest extends TestCase ...@@ -59,12 +59,12 @@ class DoctrineServiceProviderTest extends TestCase
} }
$app = new Application(); $app = new Application();
$app->register(new DoctrineServiceProvider(), array( $app->register(new DoctrineServiceProvider(), [
'dbs.options' => array( 'dbs.options' => [
'sqlite1' => array('driver' => 'pdo_sqlite', 'memory' => true), 'sqlite1' => ['driver' => 'pdo_sqlite', 'memory' => true],
'sqlite2' => array('driver' => 'pdo_sqlite', 'path' => sys_get_temp_dir().'/silex'), 'sqlite2' => ['driver' => 'pdo_sqlite', 'path' => sys_get_temp_dir().'/silex'],
), ],
)); ]);
$db = $app['db']; $db = $app['db'];
$params = $db->getParams(); $params = $db->getParams();
...@@ -90,11 +90,11 @@ class DoctrineServiceProviderTest extends TestCase ...@@ -90,11 +90,11 @@ class DoctrineServiceProviderTest extends TestCase
$app = new Application(); $app = new Application();
$this->assertArrayHasKey('logger', $app); $this->assertArrayHasKey('logger', $app);
$this->assertNull($app['logger']); $this->assertNull($app['logger']);
$app->register(new DoctrineServiceProvider(), array( $app->register(new DoctrineServiceProvider(), [
'dbs.options' => array( 'dbs.options' => [
'sqlite1' => array('driver' => 'pdo_sqlite', 'memory' => true), 'sqlite1' => ['driver' => 'pdo_sqlite', 'memory' => true],
), ],
)); ]);
$this->assertEquals(22, $app['db']->fetchColumn('SELECT 22')); $this->assertEquals(22, $app['db']->fetchColumn('SELECT 22'));
$this->assertNull($app['db']->getConfiguration()->getSQLLogger()); $this->assertNull($app['db']->getConfiguration()->getSQLLogger());
} }
...@@ -106,11 +106,11 @@ class DoctrineServiceProviderTest extends TestCase ...@@ -106,11 +106,11 @@ class DoctrineServiceProviderTest extends TestCase
} }
$app = new Container(); $app = new Container();
$app->register(new DoctrineServiceProvider(), array( $app->register(new DoctrineServiceProvider(), [
'dbs.options' => array( 'dbs.options' => [
'sqlite1' => array('driver' => 'pdo_sqlite', 'memory' => true), 'sqlite1' => ['driver' => 'pdo_sqlite', 'memory' => true],
), ],
)); ]);
$this->assertEquals(22, $app['db']->fetchColumn('SELECT 22')); $this->assertEquals(22, $app['db']->fetchColumn('SELECT 22'));
$this->assertNull($app['db']->getConfiguration()->getSQLLogger()); $this->assertNull($app['db']->getConfiguration()->getSQLLogger());
} }
......
...@@ -54,7 +54,7 @@ class FormServiceProviderTest extends TestCase ...@@ -54,7 +54,7 @@ class FormServiceProviderTest extends TestCase
return $extensions; return $extensions;
}); });
$form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])
->add('dummy', 'Silex\Tests\Provider\DummyFormType') ->add('dummy', 'Silex\Tests\Provider\DummyFormType')
->getForm(); ->getForm();
...@@ -77,7 +77,7 @@ class FormServiceProviderTest extends TestCase ...@@ -77,7 +77,7 @@ class FormServiceProviderTest extends TestCase
}); });
$form = $app['form.factory'] $form = $app['form.factory']
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])
->add('dummy', 'dummy') ->add('dummy', 'dummy')
->getForm(); ->getForm();
...@@ -101,7 +101,7 @@ class FormServiceProviderTest extends TestCase ...@@ -101,7 +101,7 @@ class FormServiceProviderTest extends TestCase
}); });
$app['form.factory'] $app['form.factory']
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])
->add('dummy', 'dummy') ->add('dummy', 'dummy')
->getForm(); ->getForm();
} }
...@@ -118,8 +118,8 @@ class FormServiceProviderTest extends TestCase ...@@ -118,8 +118,8 @@ class FormServiceProviderTest extends TestCase
return $extensions; return $extensions;
}); });
$form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])
->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', array('image_path' => 'webPath')) ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', ['image_path' => 'webPath'])
->getForm(); ->getForm();
$this->assertInstanceOf('Symfony\Component\Form\Form', $form); $this->assertInstanceOf('Symfony\Component\Form\Form', $form);
...@@ -141,8 +141,8 @@ class FormServiceProviderTest extends TestCase ...@@ -141,8 +141,8 @@ class FormServiceProviderTest extends TestCase
}); });
$form = $app['form.factory'] $form = $app['form.factory']
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])
->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', array('image_path' => 'webPath')) ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', ['image_path' => 'webPath'])
->getForm(); ->getForm();
$this->assertInstanceOf('Symfony\Component\Form\Form', $form); $this->assertInstanceOf('Symfony\Component\Form\Form', $form);
...@@ -165,7 +165,7 @@ class FormServiceProviderTest extends TestCase ...@@ -165,7 +165,7 @@ class FormServiceProviderTest extends TestCase
}); });
$app['form.factory'] $app['form.factory']
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])
->add('dummy', 'dummy.form.type') ->add('dummy', 'dummy.form.type')
->getForm(); ->getForm();
} }
...@@ -177,7 +177,7 @@ class FormServiceProviderTest extends TestCase ...@@ -177,7 +177,7 @@ class FormServiceProviderTest extends TestCase
$app->register(new FormServiceProvider()); $app->register(new FormServiceProvider());
$app->extend('form.type.guessers', function ($guessers) { $app->extend('form.type.guessers', function ($guessers) {
$guessers[] = new FormTypeGuesserChain(array()); $guessers[] = new FormTypeGuesserChain([]);
return $guessers; return $guessers;
}); });
...@@ -192,7 +192,7 @@ class FormServiceProviderTest extends TestCase ...@@ -192,7 +192,7 @@ class FormServiceProviderTest extends TestCase
$app->register(new FormServiceProvider()); $app->register(new FormServiceProvider());
$app['dummy.form.type.guesser'] = function () { $app['dummy.form.type.guesser'] = function () {
return new FormTypeGuesserChain(array()); return new FormTypeGuesserChain([]);
}; };
$app->extend('form.type.guessers', function ($guessers) { $app->extend('form.type.guessers', function ($guessers) {
$guessers[] = 'dummy.form.type.guesser'; $guessers[] = 'dummy.form.type.guesser';
...@@ -228,25 +228,25 @@ class FormServiceProviderTest extends TestCase ...@@ -228,25 +228,25 @@ class FormServiceProviderTest extends TestCase
$app->register(new FormServiceProvider()); $app->register(new FormServiceProvider());
$app->register(new TranslationServiceProvider()); $app->register(new TranslationServiceProvider());
$app['translator.domains'] = array( $app['translator.domains'] = [
'messages' => array( 'messages' => [
'de' => array( 'de' => [
'The CSRF token is invalid. Please try to resubmit the form.' => 'German translation', 'The CSRF token is invalid. Please try to resubmit the form.' => 'German translation',
), ],
), ],
); ];
$app['locale'] = 'de'; $app['locale'] = 'de';
$app['csrf.token_manager'] = function () { $app['csrf.token_manager'] = function () {
return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
}; };
$form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])
->getForm(); ->getForm();
$form->handleRequest($req = Request::create('/', 'POST', array('form' => array( $form->handleRequest($req = Request::create('/', 'POST', ['form' => [
'_token' => 'the wrong token', '_token' => 'the wrong token',
)))); ]]));
$this->assertFalse($form->isValid()); $this->assertFalse($form->isValid());
$r = new \ReflectionMethod($form, 'getErrors'); $r = new \ReflectionMethod($form, 'getErrors');
...@@ -260,15 +260,15 @@ class FormServiceProviderTest extends TestCase ...@@ -260,15 +260,15 @@ class FormServiceProviderTest extends TestCase
public function testFormServiceProviderWillNotAddNonexistentTranslationFiles() public function testFormServiceProviderWillNotAddNonexistentTranslationFiles()
{ {
$app = new Application(array( $app = new Application([
'locale' => 'nonexistent', 'locale' => 'nonexistent',
)); ]);
$app->register(new FormServiceProvider()); $app->register(new FormServiceProvider());
$app->register(new ValidatorServiceProvider()); $app->register(new ValidatorServiceProvider());
$app->register(new TranslationServiceProvider(), array( $app->register(new TranslationServiceProvider(), [
'locale_fallbacks' => array(), 'locale_fallbacks' => [],
)); ]);
$app['form.factory']; $app['form.factory'];
$translator = $app['translator']; $translator = $app['translator'];
...@@ -289,7 +289,7 @@ class FormServiceProviderTest extends TestCase ...@@ -289,7 +289,7 @@ class FormServiceProviderTest extends TestCase
$app->register(new CsrfServiceProvider()); $app->register(new CsrfServiceProvider());
$app['session.test'] = true; $app['session.test'] = true;
$form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())->getForm(); $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])->getForm();
$this->assertTrue(isset($form->createView()['_token'])); $this->assertTrue(isset($form->createView()['_token']));
} }
...@@ -307,7 +307,7 @@ class FormServiceProviderTest extends TestCase ...@@ -307,7 +307,7 @@ class FormServiceProviderTest extends TestCase
return $extensions; return $extensions;
}); });
$form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())->getForm(); $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [])->getForm();
$this->assertFalse($form->getConfig()->getOption('csrf_protection')); $this->assertFalse($form->getConfig()->getOption('csrf_protection'));
} }
...@@ -341,7 +341,7 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) { ...@@ -341,7 +341,7 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) {
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefined(array('image_path')); $resolver->setDefined(['image_path']);
} }
} }
} else { } else {
...@@ -355,9 +355,9 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) { ...@@ -355,9 +355,9 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) {
public function setDefaultOptions(OptionsResolverInterface $resolver) public function setDefaultOptions(OptionsResolverInterface $resolver)
{ {
if (!method_exists($resolver, 'setDefined')) { if (!method_exists($resolver, 'setDefined')) {
$resolver->setOptional(array('image_path')); $resolver->setOptional(['image_path']);
} else { } else {
$resolver->setDefined(array('image_path')); $resolver->setDefined(['image_path']);
} }
} }
} }
......
...@@ -10,9 +10,9 @@ class DisableCsrfExtension extends AbstractTypeExtension ...@@ -10,9 +10,9 @@ class DisableCsrfExtension extends AbstractTypeExtension
{ {
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults([
'csrf_protection' => false, 'csrf_protection' => false,
)); ]);
} }
public function getExtendedType() public function getExtendedType()
......
...@@ -28,9 +28,9 @@ class HttpCacheServiceProviderTest extends TestCase ...@@ -28,9 +28,9 @@ class HttpCacheServiceProviderTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new HttpCacheServiceProvider(), array( $app->register(new HttpCacheServiceProvider(), [
'http_cache.cache_dir' => sys_get_temp_dir().'/silex_http_cache_'.uniqid(), 'http_cache.cache_dir' => sys_get_temp_dir().'/silex_http_cache_'.uniqid(),
)); ]);
$this->assertInstanceOf('Silex\Provider\HttpCache\HttpCache', $app['http_cache']); $this->assertInstanceOf('Silex\Provider\HttpCache\HttpCache', $app['http_cache']);
...@@ -62,9 +62,9 @@ class HttpCacheServiceProviderTest extends TestCase ...@@ -62,9 +62,9 @@ class HttpCacheServiceProviderTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new HttpCacheServiceProvider(), array( $app->register(new HttpCacheServiceProvider(), [
'http_cache.cache_dir' => sys_get_temp_dir().'/silex_http_cache_'.uniqid(), 'http_cache.cache_dir' => sys_get_temp_dir().'/silex_http_cache_'.uniqid(),
)); ]);
$app['debug'] = true; $app['debug'] = true;
$app['http_cache']; $app['http_cache'];
......
...@@ -26,13 +26,13 @@ class HttpFragmentServiceProviderTest extends TestCase ...@@ -26,13 +26,13 @@ class HttpFragmentServiceProviderTest extends TestCase
unset($app['exception_handler']); unset($app['exception_handler']);
$app->register(new HttpFragmentServiceProvider()); $app->register(new HttpFragmentServiceProvider());
$app->register(new HttpCacheServiceProvider(), array('http_cache.cache_dir' => sys_get_temp_dir())); $app->register(new HttpCacheServiceProvider(), ['http_cache.cache_dir' => sys_get_temp_dir()]);
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.templates' => array( 'twig.templates' => [
'hello' => '{{ render("/foo") }}{{ render_esi("/foo") }}{{ render_hinclude("/foo") }}', 'hello' => '{{ render("/foo") }}{{ render_esi("/foo") }}{{ render_hinclude("/foo") }}',
'foo' => 'foo', 'foo' => 'foo',
), ],
)); ]);
$app->get('/hello', function () use ($app) { $app->get('/hello', function () use ($app) {
return $app['twig']->render('hello'); return $app['twig']->render('hello');
......
...@@ -87,10 +87,10 @@ class MonologServiceProviderTest extends TestCase ...@@ -87,10 +87,10 @@ class MonologServiceProviderTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new MonologServiceProvider(), array( $app->register(new MonologServiceProvider(), [
'monolog.formatter' => new JsonFormatter(), 'monolog.formatter' => new JsonFormatter(),
'monolog.logfile' => 'php://memory', 'monolog.logfile' => 'php://memory',
)); ]);
$this->assertInstanceOf('Monolog\Formatter\JsonFormatter', $app['monolog.handler']->getFormatter()); $this->assertInstanceOf('Monolog\Formatter\JsonFormatter', $app['monolog.handler']->getFormatter());
} }
...@@ -151,15 +151,15 @@ class MonologServiceProviderTest extends TestCase ...@@ -151,15 +151,15 @@ class MonologServiceProviderTest extends TestCase
$app = $this->getApplication(); $app = $this->getApplication();
$app['monolog.level'] = Logger::ERROR; $app['monolog.level'] = Logger::ERROR;
$app->register(new \Silex\Provider\SecurityServiceProvider(), array( $app->register(new \Silex\Provider\SecurityServiceProvider(), [
'security.firewalls' => array( 'security.firewalls' => [
'admin' => array( 'admin' => [
'pattern' => '^/admin', 'pattern' => '^/admin',
'http' => true, 'http' => true,
'users' => array(), 'users' => [],
), ],
), ],
)); ]);
$app->get('/admin', function () { $app->get('/admin', function () {
return 'SECURE!'; return 'SECURE!';
...@@ -209,7 +209,7 @@ class MonologServiceProviderTest extends TestCase ...@@ -209,7 +209,7 @@ class MonologServiceProviderTest extends TestCase
}); });
$level = Logger::ERROR; $level = Logger::ERROR;
$app->register(new MonologServiceProvider(), array( $app->register(new MonologServiceProvider(), [
'monolog.exception.logger_filter' => $app->protect(function () { 'monolog.exception.logger_filter' => $app->protect(function () {
return Logger::DEBUG; return Logger::DEBUG;
}), }),
...@@ -218,7 +218,7 @@ class MonologServiceProviderTest extends TestCase ...@@ -218,7 +218,7 @@ class MonologServiceProviderTest extends TestCase
}, },
'monolog.level' => $level, 'monolog.level' => $level,
'monolog.logfile' => 'php://memory', 'monolog.logfile' => 'php://memory',
)); ]);
$request = Request::create('/foo'); $request = Request::create('/foo');
$app->handle($request); $app->handle($request);
...@@ -243,14 +243,14 @@ class MonologServiceProviderTest extends TestCase ...@@ -243,14 +243,14 @@ class MonologServiceProviderTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new MonologServiceProvider(), array( $app->register(new MonologServiceProvider(), [
'monolog.handler' => function () use ($app) { 'monolog.handler' => function () use ($app) {
$level = MonologServiceProvider::translateLevel($app['monolog.level']); $level = MonologServiceProvider::translateLevel($app['monolog.level']);
return new TestHandler($level); return new TestHandler($level);
}, },
'monolog.logfile' => 'php://memory', 'monolog.logfile' => 'php://memory',
)); ]);
return $app; return $app;
} }
......
...@@ -31,13 +31,13 @@ class RememberMeServiceProviderTest extends WebTestCase ...@@ -31,13 +31,13 @@ class RememberMeServiceProviderTest extends WebTestCase
$app = $this->createApplication(); $app = $this->createApplication();
$interactiveLogin = new InteractiveLoginTriggered(); $interactiveLogin = new InteractiveLoginTriggered();
$app->on(SecurityEvents::INTERACTIVE_LOGIN, array($interactiveLogin, 'onInteractiveLogin')); $app->on(SecurityEvents::INTERACTIVE_LOGIN, [$interactiveLogin, 'onInteractiveLogin']);
$client = new Client($app); $client = new Client($app);
$client->request('get', '/'); $client->request('get', '/');
$this->assertFalse($interactiveLogin->triggered, 'The interactive login has not been triggered yet'); $this->assertFalse($interactiveLogin->triggered, 'The interactive login has not been triggered yet');
$client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'foo', '_remember_me' => 'true')); $client->request('post', '/login_check', ['_username' => 'fabien', '_password' => 'foo', '_remember_me' => 'true']);
$client->followRedirect(); $client->followRedirect();
$this->assertEquals('AUTHENTICATED_FULLY', $client->getResponse()->getContent()); $this->assertEquals('AUTHENTICATED_FULLY', $client->getResponse()->getContent());
$this->assertTrue($interactiveLogin->triggered, 'The interactive login has been triggered'); $this->assertTrue($interactiveLogin->triggered, 'The interactive login has been triggered');
...@@ -64,23 +64,23 @@ class RememberMeServiceProviderTest extends WebTestCase ...@@ -64,23 +64,23 @@ class RememberMeServiceProviderTest extends WebTestCase
$app['debug'] = true; $app['debug'] = true;
unset($app['exception_handler']); unset($app['exception_handler']);
$app->register(new SessionServiceProvider(), array( $app->register(new SessionServiceProvider(), [
'session.test' => true, 'session.test' => true,
)); ]);
$app->register(new SecurityServiceProvider()); $app->register(new SecurityServiceProvider());
$app->register(new RememberMeServiceProvider()); $app->register(new RememberMeServiceProvider());
$app['security.firewalls'] = array( $app['security.firewalls'] = [
'http-auth' => array( 'http-auth' => [
'pattern' => '^.*$', 'pattern' => '^.*$',
'form' => true, 'form' => true,
'remember_me' => array(), 'remember_me' => [],
'logout' => true, 'logout' => true,
'users' => array( 'users' => [
'fabien' => array('ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), 'fabien' => ['ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'],
), ],
), ],
); ];
$app->get('/', function () use ($app) { $app->get('/', function () use ($app) {
if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) { if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) {
......
...@@ -48,7 +48,7 @@ class RoutingServiceProviderTest extends TestCase ...@@ -48,7 +48,7 @@ class RoutingServiceProviderTest extends TestCase
->bind('hello'); ->bind('hello');
$app->get('/', function () use ($app) { $app->get('/', function () use ($app) {
return $app['url_generator']->generate('hello', array('name' => 'john')); return $app['url_generator']->generate('hello', ['name' => 'john']);
}); });
$request = Request::create('/'); $request = Request::create('/');
...@@ -65,7 +65,7 @@ class RoutingServiceProviderTest extends TestCase ...@@ -65,7 +65,7 @@ class RoutingServiceProviderTest extends TestCase
->bind('hello'); ->bind('hello');
$app->get('/', function () use ($app) { $app->get('/', function () use ($app) {
return $app['url_generator']->generate('hello', array('name' => 'john'), UrlGeneratorInterface::ABSOLUTE_URL); return $app['url_generator']->generate('hello', ['name' => 'john'], UrlGeneratorInterface::ABSOLUTE_URL);
}); });
$request = Request::create('https://localhost:81/'); $request = Request::create('https://localhost:81/');
......
...@@ -32,10 +32,10 @@ class TokenAuthenticator extends AbstractGuardAuthenticator ...@@ -32,10 +32,10 @@ class TokenAuthenticator extends AbstractGuardAuthenticator
list($username, $secret) = explode(':', $token); list($username, $secret) = explode(':', $token);
return array( return [
'username' => $username, 'username' => $username,
'secret' => $secret, 'secret' => $secret,
); ];
} }
public function getUser($credentials, UserProviderInterface $userProvider) public function getUser($credentials, UserProviderInterface $userProvider)
...@@ -56,18 +56,18 @@ class TokenAuthenticator extends AbstractGuardAuthenticator ...@@ -56,18 +56,18 @@ class TokenAuthenticator extends AbstractGuardAuthenticator
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{ {
$data = array( $data = [
'message' => strtr($exception->getMessageKey(), $exception->getMessageData()), 'message' => strtr($exception->getMessageKey(), $exception->getMessageData()),
); ];
return new JsonResponse($data, 403); return new JsonResponse($data, 403);
} }
public function start(Request $request, AuthenticationException $authException = null) public function start(Request $request, AuthenticationException $authException = null)
{ {
$data = array( $data = [
'message' => 'Authentication Required', 'message' => 'Authentication Required',
); ];
return new JsonResponse($data, 401); return new JsonResponse($data, 401);
} }
......
...@@ -51,9 +51,9 @@ class SessionServiceProviderTest extends WebTestCase ...@@ -51,9 +51,9 @@ class SessionServiceProviderTest extends WebTestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new SessionServiceProvider(), array( $app->register(new SessionServiceProvider(), [
'session.test' => true, 'session.test' => true,
)); ]);
$app->get('/login', function () use ($app) { $app->get('/login', function () use ($app) {
$app['session']->set('logged_in', true); $app['session']->set('logged_in', true);
...@@ -82,9 +82,9 @@ class SessionServiceProviderTest extends WebTestCase ...@@ -82,9 +82,9 @@ class SessionServiceProviderTest extends WebTestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new SessionServiceProvider(), array( $app->register(new SessionServiceProvider(), [
'session.test' => true, 'session.test' => true,
)); ]);
$app->get('/', function () { $app->get('/', function () {
return 'A welcome page.'; return 'A welcome page.';
...@@ -112,11 +112,11 @@ class SessionServiceProviderTest extends WebTestCase ...@@ -112,11 +112,11 @@ class SessionServiceProviderTest extends WebTestCase
$attrs = new Session\Attribute\AttributeBag(); $attrs = new Session\Attribute\AttributeBag();
$flash = new Session\Flash\FlashBag(); $flash = new Session\Flash\FlashBag();
$app->register(new SessionServiceProvider(), array( $app->register(new SessionServiceProvider(), [
'session.attribute_bag' => $attrs, 'session.attribute_bag' => $attrs,
'session.flash_bag' => $flash, 'session.flash_bag' => $flash,
'session.test' => true, 'session.test' => true,
)); ]);
$session = $app['session']; $session = $app['session'];
......
...@@ -13,7 +13,7 @@ namespace Silex\Tests\Provider; ...@@ -13,7 +13,7 @@ namespace Silex\Tests\Provider;
class SpoolStub implements \Swift_Spool class SpoolStub implements \Swift_Spool
{ {
private $messages = array(); private $messages = [];
public $hasFlushed = false; public $hasFlushed = false;
public function getMessages() public function getMessages()
...@@ -42,6 +42,6 @@ class SpoolStub implements \Swift_Spool ...@@ -42,6 +42,6 @@ class SpoolStub implements \Swift_Spool
public function flushQueue(\Swift_Transport $transport, &$failedRecipients = null) public function flushQueue(\Swift_Transport $transport, &$failedRecipients = null)
{ {
$this->hasFlushed = true; $this->hasFlushed = true;
$this->messages = array(); $this->messages = [];
} }
} }
...@@ -124,7 +124,7 @@ class SwiftmailerServiceProviderTest extends TestCase ...@@ -124,7 +124,7 @@ class SwiftmailerServiceProviderTest extends TestCase
$app->register(new SwiftmailerServiceProvider()); $app->register(new SwiftmailerServiceProvider());
$app['swiftmailer.plugins'] = function ($app) use ($plugin) { $app['swiftmailer.plugins'] = function ($app) use ($plugin) {
return array($plugin); return [$plugin];
}; };
$dispatcher = $app['swiftmailer.transport.eventdispatcher']; $dispatcher = $app['swiftmailer.transport.eventdispatcher'];
......
...@@ -34,54 +34,54 @@ class TranslationServiceProviderTest extends TestCase ...@@ -34,54 +34,54 @@ class TranslationServiceProviderTest extends TestCase
$app->register(new LocaleServiceProvider()); $app->register(new LocaleServiceProvider());
$app->register(new TranslationServiceProvider()); $app->register(new TranslationServiceProvider());
$app['translator.domains'] = array( $app['translator.domains'] = [
'messages' => array( 'messages' => [
'en' => array( 'en' => [
'key1' => 'The translation', 'key1' => 'The translation',
'key_only_english' => 'Foo', 'key_only_english' => 'Foo',
'key2' => 'One apple|%count% apples', 'key2' => 'One apple|%count% apples',
'test' => array( 'test' => [
'key' => 'It works', 'key' => 'It works',
), ],
), ],
'de' => array( 'de' => [
'key1' => 'The german translation', 'key1' => 'The german translation',
'key2' => 'One german apple|%count% german apples', 'key2' => 'One german apple|%count% german apples',
'test' => array( 'test' => [
'key' => 'It works in german', 'key' => 'It works in german',
), ],
), ],
), ],
); ];
return $app; return $app;
} }
public function transChoiceProvider() public function transChoiceProvider()
{ {
return array( return [
array('key2', 0, null, '0 apples'), ['key2', 0, null, '0 apples'],
array('key2', 1, null, 'One apple'), ['key2', 1, null, 'One apple'],
array('key2', 2, null, '2 apples'), ['key2', 2, null, '2 apples'],
array('key2', 0, 'de', '0 german apples'), ['key2', 0, 'de', '0 german apples'],
array('key2', 1, 'de', 'One german apple'), ['key2', 1, 'de', 'One german apple'],
array('key2', 2, 'de', '2 german apples'), ['key2', 2, 'de', '2 german apples'],
array('key2', 0, 'ru', '0 apples'), // fallback ['key2', 0, 'ru', '0 apples'], // fallback
array('key2', 1, 'ru', 'One apple'), // fallback ['key2', 1, 'ru', 'One apple'], // fallback
array('key2', 2, 'ru', '2 apples'), // fallback ['key2', 2, 'ru', '2 apples'], // fallback
); ];
} }
public function transProvider() public function transProvider()
{ {
return array( return [
array('key1', null, 'The translation'), ['key1', null, 'The translation'],
array('key1', 'de', 'The german translation'), ['key1', 'de', 'The german translation'],
array('key1', 'ru', 'The translation'), // fallback ['key1', 'ru', 'The translation'], // fallback
array('test.key', null, 'It works'), ['test.key', null, 'It works'],
array('test.key', 'de', 'It works in german'), ['test.key', 'de', 'It works in german'],
array('test.key', 'ru', 'It works'), // fallback ['test.key', 'ru', 'It works'], // fallback
); ];
} }
/** /**
...@@ -91,7 +91,7 @@ class TranslationServiceProviderTest extends TestCase ...@@ -91,7 +91,7 @@ class TranslationServiceProviderTest extends TestCase
{ {
$app = $this->getPreparedApp(); $app = $this->getPreparedApp();
$result = $app['translator']->trans($key, array(), null, $locale); $result = $app['translator']->trans($key, [], null, $locale);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
...@@ -103,21 +103,21 @@ class TranslationServiceProviderTest extends TestCase ...@@ -103,21 +103,21 @@ class TranslationServiceProviderTest extends TestCase
{ {
$app = $this->getPreparedApp(); $app = $this->getPreparedApp();
$result = $app['translator']->transChoice($key, $number, array('%count%' => $number), null, $locale); $result = $app['translator']->transChoice($key, $number, ['%count%' => $number], null, $locale);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
public function testFallbacks() public function testFallbacks()
{ {
$app = $this->getPreparedApp(); $app = $this->getPreparedApp();
$app['locale_fallbacks'] = array('de', 'en'); $app['locale_fallbacks'] = ['de', 'en'];
// fallback to english // fallback to english
$result = $app['translator']->trans('key_only_english', array(), null, 'ru'); $result = $app['translator']->trans('key_only_english', [], null, 'ru');
$this->assertEquals('Foo', $result); $this->assertEquals('Foo', $result);
// fallback to german // fallback to german
$result = $app['translator']->trans('key1', array(), null, 'ru'); $result = $app['translator']->trans('key1', [], null, 'ru');
$this->assertEquals('The german translation', $result); $this->assertEquals('The german translation', $result);
} }
......
...@@ -33,12 +33,12 @@ class TwigServiceProviderTest extends TestCase ...@@ -33,12 +33,12 @@ class TwigServiceProviderTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.templates' => array('hello' => 'Hello {{ name }}!'), 'twig.templates' => ['hello' => 'Hello {{ name }}!'],
)); ]);
$app->get('/hello/{name}', function ($name) use ($app) { $app->get('/hello/{name}', function ($name) use ($app) {
return $app['twig']->render('hello', array('name' => $name)); return $app['twig']->render('hello', ['name' => $name]);
}); });
$request = Request::create('/hello/john'); $request = Request::create('/hello/john');
...@@ -49,9 +49,9 @@ class TwigServiceProviderTest extends TestCase ...@@ -49,9 +49,9 @@ class TwigServiceProviderTest extends TestCase
public function testLoaderPriority() public function testLoaderPriority()
{ {
$app = new Application(); $app = new Application();
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.templates' => array('foo' => 'foo'), 'twig.templates' => ['foo' => 'foo'],
)); ]);
$loader = $this->getMockBuilder('\Twig_LoaderInterface')->getMock(); $loader = $this->getMockBuilder('\Twig_LoaderInterface')->getMock();
$loader->expects($this->never())->method('getSourceContext'); $loader->expects($this->never())->method('getSourceContext');
$app['twig.loader.filesystem'] = function ($app) use ($loader) { $app['twig.loader.filesystem'] = function ($app) use ($loader) {
...@@ -64,12 +64,12 @@ class TwigServiceProviderTest extends TestCase ...@@ -64,12 +64,12 @@ class TwigServiceProviderTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$app['request_stack']->push(Request::create('/dir1/dir2/file')); $app['request_stack']->push(Request::create('/dir1/dir2/file'));
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.templates' => array( 'twig.templates' => [
'absolute' => '{{ absolute_url("foo.css") }}', 'absolute' => '{{ absolute_url("foo.css") }}',
'relative' => '{{ relative_path("/dir1/foo.css") }}', 'relative' => '{{ relative_path("/dir1/foo.css") }}',
), ],
)); ]);
$this->assertEquals('http://localhost/dir1/dir2/foo.css', $app['twig']->render('absolute')); $this->assertEquals('http://localhost/dir1/dir2/foo.css', $app['twig']->render('absolute'));
$this->assertEquals('../foo.css', $app['twig']->render('relative')); $this->assertEquals('../foo.css', $app['twig']->render('relative'));
...@@ -78,12 +78,12 @@ class TwigServiceProviderTest extends TestCase ...@@ -78,12 +78,12 @@ class TwigServiceProviderTest extends TestCase
public function testAssetIntegration() public function testAssetIntegration()
{ {
$app = new Application(); $app = new Application();
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.templates' => array('hello' => '{{ asset("/foo.css") }}'), 'twig.templates' => ['hello' => '{{ asset("/foo.css") }}'],
)); ]);
$app->register(new AssetServiceProvider(), array( $app->register(new AssetServiceProvider(), [
'assets.version' => 1, 'assets.version' => 1,
)); ]);
$this->assertEquals('/foo.css?1', $app['twig']->render('hello')); $this->assertEquals('/foo.css?1', $app['twig']->render('hello'));
} }
...@@ -93,9 +93,9 @@ class TwigServiceProviderTest extends TestCase ...@@ -93,9 +93,9 @@ class TwigServiceProviderTest extends TestCase
$app = new Application(); $app = new Application();
$app['request_stack']->push(Request::create('/?name=Fabien')); $app['request_stack']->push(Request::create('/?name=Fabien'));
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.templates' => array('hello' => '{{ global.request.get("name") }}'), 'twig.templates' => ['hello' => '{{ global.request.get("name") }}'],
)); ]);
$this->assertEquals('Fabien', $app['twig']->render('hello')); $this->assertEquals('Fabien', $app['twig']->render('hello'));
} }
...@@ -127,20 +127,20 @@ class TwigServiceProviderTest extends TestCase ...@@ -127,20 +127,20 @@ class TwigServiceProviderTest extends TestCase
$timezone = new \DateTimeZone('Europe/Paris'); $timezone = new \DateTimeZone('Europe/Paris');
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.date.format' => 'Y-m-d', 'twig.date.format' => 'Y-m-d',
'twig.date.interval_format' => '%h hours', 'twig.date.interval_format' => '%h hours',
'twig.date.timezone' => $timezone, 'twig.date.timezone' => $timezone,
'twig.number_format.decimals' => 2, 'twig.number_format.decimals' => 2,
'twig.number_format.decimal_point' => ',', 'twig.number_format.decimal_point' => ',',
'twig.number_format.thousands_separator' => ' ', 'twig.number_format.thousands_separator' => ' ',
)); ]);
$twig = $app['twig']; $twig = $app['twig'];
$this->assertSame(array('Y-m-d', '%h hours'), $twig->getExtension('Twig_Extension_Core')->getDateFormat()); $this->assertSame(['Y-m-d', '%h hours'], $twig->getExtension('Twig_Extension_Core')->getDateFormat());
$this->assertSame($timezone, $twig->getExtension('Twig_Extension_Core')->getTimezone()); $this->assertSame($timezone, $twig->getExtension('Twig_Extension_Core')->getTimezone());
$this->assertSame(array(2, ',', ' '), $twig->getExtension('Twig_Extension_Core')->getNumberFormat()); $this->assertSame([2, ',', ' '], $twig->getExtension('Twig_Extension_Core')->getNumberFormat());
} }
public function testWebLinkIntegration() public function testWebLinkIntegration()
...@@ -151,15 +151,15 @@ class TwigServiceProviderTest extends TestCase ...@@ -151,15 +151,15 @@ class TwigServiceProviderTest extends TestCase
$app = new Application(); $app = new Application();
$app['request_stack']->push($request = Request::create('/')); $app['request_stack']->push($request = Request::create('/'));
$app->register(new TwigServiceProvider(), array( $app->register(new TwigServiceProvider(), [
'twig.templates' => array( 'twig.templates' => [
'preload' => '{{ preload("/foo.css") }}', 'preload' => '{{ preload("/foo.css") }}',
), ],
)); ]);
$this->assertEquals('/foo.css', $app['twig']->render('preload')); $this->assertEquals('/foo.css', $app['twig']->render('preload'));
$link = new Link('preload', '/foo.css'); $link = new Link('preload', '/foo.css');
$this->assertEquals(array($link), array_values($request->attributes->get('_links')->getLinks())); $this->assertEquals([$link], array_values($request->attributes->get('_links')->getLinks()));
} }
} }
...@@ -49,11 +49,11 @@ class ValidatorServiceProviderTest extends TestCase ...@@ -49,11 +49,11 @@ class ValidatorServiceProviderTest extends TestCase
return new CustomValidator(); return new CustomValidator();
}; };
$app->register(new ValidatorServiceProvider(), array( $app->register(new ValidatorServiceProvider(), [
'validator.validator_service_ids' => array( 'validator.validator_service_ids' => [
'test.custom.validator' => 'custom.validator', 'test.custom.validator' => 'custom.validator',
), ],
)); ]);
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $app['validator']); $this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $app['validator']);
...@@ -95,23 +95,23 @@ class ValidatorServiceProviderTest extends TestCase ...@@ -95,23 +95,23 @@ class ValidatorServiceProviderTest extends TestCase
*/ */
public function testValidatorConstraint($email, $isValid, $nbGlobalError, $nbEmailError, $app) public function testValidatorConstraint($email, $isValid, $nbGlobalError, $nbEmailError, $app)
{ {
$constraints = new Assert\Collection(array( $constraints = new Assert\Collection([
'email' => array( 'email' => [
new Assert\NotBlank(), new Assert\NotBlank(),
new Assert\Email(), new Assert\Email(),
), ],
)); ]);
$builder = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array(), array( $builder = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', [], [
'constraints' => $constraints, 'constraints' => $constraints,
)); ]);
$form = $builder $form = $builder
->add('email', 'Symfony\Component\Form\Extension\Core\Type\EmailType', array('label' => 'Email')) ->add('email', 'Symfony\Component\Form\Extension\Core\Type\EmailType', ['label' => 'Email'])
->getForm() ->getForm()
; ;
$form->submit(array('email' => $email)); $form->submit(['email' => $email]);
$this->assertEquals($isValid, $form->isValid()); $this->assertEquals($isValid, $form->isValid());
$this->assertCount($nbGlobalError, $form->getErrors()); $this->assertCount($nbGlobalError, $form->getErrors());
...@@ -120,14 +120,14 @@ class ValidatorServiceProviderTest extends TestCase ...@@ -120,14 +120,14 @@ class ValidatorServiceProviderTest extends TestCase
public function testValidatorWillNotAddNonexistentTranslationFiles() public function testValidatorWillNotAddNonexistentTranslationFiles()
{ {
$app = new Application(array( $app = new Application([
'locale' => 'nonexistent', 'locale' => 'nonexistent',
)); ]);
$app->register(new ValidatorServiceProvider()); $app->register(new ValidatorServiceProvider());
$app->register(new TranslationServiceProvider(), array( $app->register(new TranslationServiceProvider(), [
'locale_fallbacks' => array(), 'locale_fallbacks' => [],
)); ]);
$app['validator']; $app['validator'];
$translator = $app['translator']; $translator = $app['translator'];
...@@ -143,11 +143,11 @@ class ValidatorServiceProviderTest extends TestCase ...@@ -143,11 +143,11 @@ class ValidatorServiceProviderTest extends TestCase
public function getTestValidatorConstraintProvider() public function getTestValidatorConstraintProvider()
{ {
// Email, form is valid, nb global error, nb email error // Email, form is valid, nb global error, nb email error
return array( return [
array('', false, 0, 1), ['', false, 0, 1],
array('not an email', false, 0, 1), ['not an email', false, 0, 1],
array('email@sample.com', true, 0, 0), ['email@sample.com', true, 0, 0],
); ];
} }
/** /**
...@@ -161,7 +161,7 @@ class ValidatorServiceProviderTest extends TestCase ...@@ -161,7 +161,7 @@ class ValidatorServiceProviderTest extends TestCase
$app->register(new ValidatorServiceProvider()); $app->register(new ValidatorServiceProvider());
$app->register(new TranslationServiceProvider()); $app->register(new TranslationServiceProvider());
$app['translator'] = $app->extend('translator', function ($translator, $app) { $app['translator'] = $app->extend('translator', function ($translator, $app) {
$translator->addResource('array', array('This value should not be blank.' => 'Pas vide'), 'fr', 'validators'); $translator->addResource('array', ['This value should not be blank.' => 'Pas vide'], 'fr', 'validators');
return $translator; return $translator;
}); });
...@@ -170,12 +170,12 @@ class ValidatorServiceProviderTest extends TestCase ...@@ -170,12 +170,12 @@ class ValidatorServiceProviderTest extends TestCase
$app['validator']; $app['validator'];
} }
$this->assertEquals('Pas vide', $app['translator']->trans('This value should not be blank.', array(), 'validators', 'fr')); $this->assertEquals('Pas vide', $app['translator']->trans('This value should not be blank.', [], 'validators', 'fr'));
} }
public function getAddResourceData() public function getAddResourceData()
{ {
return array(array(false), array(true)); return [[false], [true]];
} }
public function testAddResourceAlternate() public function testAddResourceAlternate()
...@@ -186,16 +186,16 @@ class ValidatorServiceProviderTest extends TestCase ...@@ -186,16 +186,16 @@ class ValidatorServiceProviderTest extends TestCase
$app->register(new ValidatorServiceProvider()); $app->register(new ValidatorServiceProvider());
$app->register(new TranslationServiceProvider()); $app->register(new TranslationServiceProvider());
$app->factory($app->extend('translator.resources', function ($resources, $app) { $app->factory($app->extend('translator.resources', function ($resources, $app) {
$resources = array_merge($resources, array( $resources = array_merge($resources, [
array('array', array('This value should not be blank.' => 'Pas vide'), 'fr', 'validators'), ['array', ['This value should not be blank.' => 'Pas vide'], 'fr', 'validators'],
)); ]);
return $resources; return $resources;
})); }));
$app['validator']; $app['validator'];
$this->assertEquals('Pas vide', $app['translator']->trans('This value should not be blank.', array(), 'validators', 'fr')); $this->assertEquals('Pas vide', $app['translator']->trans('This value should not be blank.', [], 'validators', 'fr'));
} }
public function testTranslatorResourcesIsArray() public function testTranslatorResourcesIsArray()
......
...@@ -70,16 +70,16 @@ class SecurityTraitTest extends TestCase ...@@ -70,16 +70,16 @@ class SecurityTraitTest extends TestCase
{ {
$app = new Application(); $app = new Application();
$app['route_class'] = 'Silex\Tests\Route\SecurityRoute'; $app['route_class'] = 'Silex\Tests\Route\SecurityRoute';
$app->register(new SecurityServiceProvider(), array( $app->register(new SecurityServiceProvider(), [
'security.firewalls' => array( 'security.firewalls' => [
'default' => array( 'default' => [
'http' => true, 'http' => true,
'users' => array( 'users' => [
'fabien' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), 'fabien' => ['ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'],
), ],
), ],
), ],
)); ]);
return $app; return $app;
} }
......
...@@ -161,7 +161,7 @@ class RouterTest extends TestCase ...@@ -161,7 +161,7 @@ class RouterTest extends TestCase
return new Response($request->getRequestUri()); return new Response($request->getRequestUri());
}); });
foreach (array('/foo', '/bar') as $path) { foreach (['/foo', '/bar'] as $path) {
$request = Request::create($path); $request = Request::create($path);
$response = $app->handle($request); $response = $app->handle($request);
$this->assertContains($path, $response->getContent()); $this->assertContains($path, $response->getContent());
......
...@@ -50,14 +50,14 @@ class ServiceControllerResolverTest extends Testcase ...@@ -50,14 +50,14 @@ class ServiceControllerResolverTest extends Testcase
$this->mockCallbackResolver->expects($this->once()) $this->mockCallbackResolver->expects($this->once())
->method('convertCallback') ->method('convertCallback')
->with('some_service:methodName') ->with('some_service:methodName')
->will($this->returnValue(array('callback'))); ->will($this->returnValue(['callback']));
$this->app['some_service'] = function () { return new \stdClass(); }; $this->app['some_service'] = function () { return new \stdClass(); };
$req = Request::create('/'); $req = Request::create('/');
$req->attributes->set('_controller', 'some_service:methodName'); $req->attributes->set('_controller', 'some_service:methodName');
$this->assertEquals(array('callback'), $this->resolver->getController($req)); $this->assertEquals(['callback'], $this->resolver->getController($req));
} }
public function testShouldUnresolvedControllerNames() public function testShouldUnresolvedControllerNames()
......
...@@ -67,10 +67,10 @@ class WebTestCaseTest extends WebTestCase ...@@ -67,10 +67,10 @@ class WebTestCaseTest extends WebTestCase
$user = 'klaus'; $user = 'klaus';
$pass = '123456'; $pass = '123456';
$client = $this->createClient(array( $client = $this->createClient([
'PHP_AUTH_USER' => $user, 'PHP_AUTH_USER' => $user,
'PHP_AUTH_PW' => $pass, 'PHP_AUTH_PW' => $pass,
)); ]);
$crawler = $client->request('GET', '/server'); $crawler = $client->request('GET', '/server');
$this->assertEquals("$user:$pass", $crawler->filter('h1')->text()); $this->assertEquals("$user:$pass", $crawler->filter('h1')->text());
......
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