This commit is contained in:
Fabien Potencier 2019-03-22 07:07:54 +01:00
parent 4574f8543c
commit 7e30c971ab
15 changed files with 60 additions and 62 deletions

View File

@ -49,9 +49,9 @@ class ConsoleCommandProcessor implements EventSubscriberInterface, ResetInterfac
public function addCommandData(ConsoleEvent $event)
{
$this->commandData = array(
$this->commandData = [
'name' => $event->getCommand()->getName(),
);
];
if ($this->includeArguments) {
$this->commandData['arguments'] = $event->getInput()->getArguments();
}
@ -62,8 +62,8 @@ class ConsoleCommandProcessor implements EventSubscriberInterface, ResetInterfac
public static function getSubscribedEvents()
{
return array(
ConsoleEvents::COMMAND => array('addCommandData', 1),
);
return [
ConsoleEvents::COMMAND => ['addCommandData', 1],
];
}
}

View File

@ -44,7 +44,7 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface
public function reset()
{
$this->routeData = array();
$this->routeData = [];
}
public function addRouteData(GetResponseEvent $event)
@ -58,10 +58,10 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface
return;
}
$currentRequestData = array(
$currentRequestData = [
'controller' => $request->attributes->get('_controller'),
'route' => $request->attributes->get('_route'),
);
];
if ($this->includeParams) {
$currentRequestData['route_params'] = $request->attributes->get('_route_params');
@ -78,9 +78,9 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface
public static function getSubscribedEvents()
{
return array(
KernelEvents::REQUEST => array('addRouteData', 1),
KernelEvents::FINISH_REQUEST => array('removeRouteData', 1),
);
return [
KernelEvents::REQUEST => ['addRouteData', 1],
KernelEvents::FINISH_REQUEST => ['removeRouteData', 1],
];
}
}

View File

@ -19,8 +19,8 @@ use Symfony\Component\Console\Input\InputInterface;
class ConsoleCommandProcessorTest extends TestCase
{
private const TEST_ARGUMENTS = array('test' => 'argument');
private const TEST_OPTIONS = array('test' => 'option');
private const TEST_ARGUMENTS = ['test' => 'argument'];
private const TEST_OPTIONS = ['test' => 'option'];
private const TEST_NAME = 'some:test';
public function testProcessor()
@ -28,11 +28,11 @@ class ConsoleCommandProcessorTest extends TestCase
$processor = new ConsoleCommandProcessor();
$processor->addCommandData($this->getConsoleEvent());
$record = $processor(array('extra' => array()));
$record = $processor(['extra' => []]);
$this->assertArrayHasKey('command', $record['extra']);
$this->assertEquals(
array('name' => self::TEST_NAME, 'arguments' => self::TEST_ARGUMENTS),
['name' => self::TEST_NAME, 'arguments' => self::TEST_ARGUMENTS],
$record['extra']['command']
);
}
@ -42,11 +42,11 @@ class ConsoleCommandProcessorTest extends TestCase
$processor = new ConsoleCommandProcessor(true, true);
$processor->addCommandData($this->getConsoleEvent());
$record = $processor(array('extra' => array()));
$record = $processor(['extra' => []]);
$this->assertArrayHasKey('command', $record['extra']);
$this->assertEquals(
array('name' => self::TEST_NAME, 'arguments' => self::TEST_ARGUMENTS, 'options' => self::TEST_OPTIONS),
['name' => self::TEST_NAME, 'arguments' => self::TEST_ARGUMENTS, 'options' => self::TEST_OPTIONS],
$record['extra']['command']
);
}
@ -55,8 +55,8 @@ class ConsoleCommandProcessorTest extends TestCase
{
$processor = new ConsoleCommandProcessor(true, true);
$record = $processor(array('extra' => array()));
$this->assertEquals(array('extra' => array()), $record);
$record = $processor(['extra' => []]);
$this->assertEquals(['extra' => []], $record);
}
private function getConsoleEvent(): ConsoleEvent

View File

@ -22,7 +22,7 @@ class RouteProcessorTest extends TestCase
{
private const TEST_CONTROLLER = 'App\Controller\SomeController::someMethod';
private const TEST_ROUTE = 'someRouteName';
private const TEST_PARAMS = array('param1' => 'value1');
private const TEST_PARAMS = ['param1' => 'value1'];
public function testProcessor()
{
@ -30,12 +30,12 @@ class RouteProcessorTest extends TestCase
$processor = new RouteProcessor();
$processor->addRouteData($this->mockGetResponseEvent($request));
$record = $processor(array('extra' => array()));
$record = $processor(['extra' => []]);
$this->assertArrayHasKey('requests', $record['extra']);
$this->assertCount(1, $record['extra']['requests']);
$this->assertEquals(
array('controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE, 'route_params' => self::TEST_PARAMS),
['controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE, 'route_params' => self::TEST_PARAMS],
$record['extra']['requests'][0]
);
}
@ -46,12 +46,12 @@ class RouteProcessorTest extends TestCase
$processor = new RouteProcessor(false);
$processor->addRouteData($this->mockGetResponseEvent($request));
$record = $processor(array('extra' => array()));
$record = $processor(['extra' => []]);
$this->assertArrayHasKey('requests', $record['extra']);
$this->assertCount(1, $record['extra']['requests']);
$this->assertEquals(
array('controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE),
['controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE],
$record['extra']['requests'][0]
);
}
@ -66,16 +66,16 @@ class RouteProcessorTest extends TestCase
$processor->addRouteData($this->mockGetResponseEvent($mainRequest));
$processor->addRouteData($this->mockGetResponseEvent($subRequest));
$record = $processor(array('extra' => array()));
$record = $processor(['extra' => []]);
$this->assertArrayHasKey('requests', $record['extra']);
$this->assertCount(2, $record['extra']['requests']);
$this->assertEquals(
array('controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE),
['controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE],
$record['extra']['requests'][0]
);
$this->assertEquals(
array('controller' => $controllerFromSubRequest, 'route' => self::TEST_ROUTE),
['controller' => $controllerFromSubRequest, 'route' => self::TEST_ROUTE],
$record['extra']['requests'][1]
);
}
@ -89,17 +89,17 @@ class RouteProcessorTest extends TestCase
$processor->addRouteData($this->mockGetResponseEvent($mainRequest));
$processor->addRouteData($this->mockGetResponseEvent($subRequest));
$processor->removeRouteData($this->mockFinishRequestEvent($subRequest));
$record = $processor(array('extra' => array()));
$record = $processor(['extra' => []]);
$this->assertArrayHasKey('requests', $record['extra']);
$this->assertCount(1, $record['extra']['requests']);
$this->assertEquals(
array('controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE),
['controller' => self::TEST_CONTROLLER, 'route' => self::TEST_ROUTE],
$record['extra']['requests'][0]
);
$processor->removeRouteData($this->mockFinishRequestEvent($mainRequest));
$record = $processor(array('extra' => array()));
$record = $processor(['extra' => []]);
$this->assertArrayNotHasKey('requests', $record['extra']);
}
@ -110,16 +110,16 @@ class RouteProcessorTest extends TestCase
$processor = new RouteProcessor();
$processor->addRouteData($this->mockGetResponseEvent($request));
$record = $processor(array('extra' => array()));
$this->assertEquals(array('extra' => array()), $record);
$record = $processor(['extra' => []]);
$this->assertEquals(['extra' => []], $record);
}
public function testProcessorDoesNothingWhenNoRequest()
{
$processor = new RouteProcessor();
$record = $processor(array('extra' => array()));
$this->assertEquals(array('extra' => array()), $record);
$record = $processor(['extra' => []]);
$this->assertEquals(['extra' => []], $record);
}
private function mockGetResponseEvent(Request $request): GetResponseEvent
@ -140,16 +140,16 @@ class RouteProcessorTest extends TestCase
private function mockEmptyRequest(): Request
{
return $this->mockRequest(array());
return $this->mockRequest([]);
}
private function mockFilledRequest(string $controller = self::TEST_CONTROLLER): Request
{
return $this->mockRequest(array(
return $this->mockRequest([
'_controller' => $controller,
'_route' => self::TEST_ROUTE,
'_route_params' => self::TEST_PARAMS,
));
]);
}
private function mockRequest(array $attributes): Request

View File

@ -93,7 +93,7 @@ class TextDescriptor extends Descriptor
];
if ('' !== $route->getCondition()) {
$tableRows[] = array('Condition', $route->getCondition());
$tableRows[] = ['Condition', $route->getCondition()];
}
$table = new Table($this->getOutput());

View File

@ -1,14 +1,14 @@
<?php
$container->loadFromExtension('framework', array(
'templating' => array(
$container->loadFromExtension('framework', [
'templating' => [
'cache' => '/path/to/cache',
'engines' => array('php', 'twig'),
'loader' => array('loader.foo', 'loader.bar'),
'form' => array(
'resources' => array('theme1', 'theme2'),
),
'engines' => ['php', 'twig'],
'loader' => ['loader.foo', 'loader.bar'],
'form' => [
'resources' => ['theme1', 'theme2'],
],
'hinclude_default_template' => 'global_hinclude_template',
),
],
'assets' => null,
));
]);

View File

@ -42,7 +42,7 @@ class AutowiringTypesTest extends WebTestCase
*/
public function testTemplatingAutowiring()
{
static::bootKernel(array('root_config' => 'templating.yml', 'environment' => 'templating'));
static::bootKernel(['root_config' => 'templating.yml', 'environment' => 'templating']);
$autowiredServices = static::$container->get('test.autowiring_types.autowired_services');
$this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine());

View File

@ -11,7 +11,6 @@
namespace Symfony\Component\EventDispatcher\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;

View File

@ -11,7 +11,7 @@ class ControllerArgumentsEventTest extends TestCase
{
public function testControllerArgumentsEvent()
{
$filterController = new ControllerArgumentsEvent(new TestHttpKernel(), function () {}, array('test'), new Request(), 1);
$this->assertEquals($filterController->getArguments(), array('test'));
$filterController = new ControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1);
$this->assertEquals($filterController->getArguments(), ['test']);
}
}

View File

@ -16,8 +16,8 @@ use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\ProviderNotFoundException;

View File

@ -16,8 +16,8 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\ProviderNotFoundException;

View File

@ -21,8 +21,8 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Guard\AuthenticatorInterface;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
use Symfony\Component\Security\Http\Firewall\LegacyListenerTrait;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
/**

View File

@ -14,8 +14,8 @@ namespace Symfony\Component\Security\Http;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Http\Firewall\AccessListener;
use Symfony\Component\Security\Http\Firewall\LogoutListener;

View File

@ -14,9 +14,9 @@ namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;

View File

@ -13,13 +13,12 @@ namespace Symfony\Component\Workflow;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Symfony\Component\Workflow\Event\Event;
use Symfony\Component\Workflow\Event\GuardEvent;
use Symfony\Component\Workflow\Event\AnnounceEvent;
use Symfony\Component\Workflow\Event\EnterEvent;
use Symfony\Component\Workflow\Event\EnteredEvent;
use Symfony\Component\Workflow\Event\LeaveEvent;
use Symfony\Component\Workflow\Event\CompletedEvent;
use Symfony\Component\Workflow\Event\EnteredEvent;
use Symfony\Component\Workflow\Event\EnterEvent;
use Symfony\Component\Workflow\Event\GuardEvent;
use Symfony\Component\Workflow\Event\LeaveEvent;
use Symfony\Component\Workflow\Event\TransitionEvent;
use Symfony\Component\Workflow\Exception\LogicException;
use Symfony\Component\Workflow\Exception\NotEnabledTransitionException;