Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
umpirsky committed Jan 15, 2019
1 parent ad6f0dc commit a905812
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -35,9 +35,9 @@ class CsrfValidationListener implements EventSubscriberInterface

public static function getSubscribedEvents()
{
return array(
return [
FormEvents::PRE_SUBMIT => 'preSubmit',
);
];
}

public function __construct($fieldName, CsrfTokenManagerInterface $tokenManager, $tokenId, $errorMessage, TranslatorInterface $translator = null, $translationDomain = null, ServerParams $serverParams = null)
Expand All @@ -59,11 +59,11 @@ public function preSubmit(FormEvent $event)
if ($form->isRoot() && $form->getConfig()->getOption('compound') && !$postRequestSizeExceeded) {
$data = $event->getData();

if (!isset($data[$this->fieldName]) || !is_string($data[$this->fieldName]) || !$this->tokenManager->isTokenValid(new CsrfToken($this->tokenId, $data[$this->fieldName]))) {
if (!isset($data[$this->fieldName]) || !\is_string($data[$this->fieldName]) || !$this->tokenManager->isTokenValid(new CsrfToken($this->tokenId, $data[$this->fieldName]))) {
$errorMessage = $this->errorMessage;

if (null !== $this->translator) {
$errorMessage = $this->translator->trans($errorMessage, array(), $this->translationDomain);
$errorMessage = $this->translator->trans($errorMessage, [], $this->translationDomain);
}

$form->addError(new FormError($errorMessage));
Expand Down
Expand Up @@ -43,7 +43,7 @@ protected function tearDown()

protected function getBuilder($name = 'name')
{
return new FormBuilder($name, null, $this->dispatcher, $this->factory, array('compound' => true));
return new FormBuilder($name, null, $this->dispatcher, $this->factory, ['compound' => true]);
}

protected function getForm($name = 'name')
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testMaxPostSizeExceeded()
->willReturn(true)
;

$event = new FormEvent($this->form, array('csrf' => 'token'));
$event = new FormEvent($this->form, ['csrf' => 'token']);
$validation = new CsrfValidationListener('csrf', $this->tokenManager, 'unknown', 'Error message', null, null, $serverParams);

$validation->preSubmit($event);
Expand Down

0 comments on commit a905812

Please sign in to comment.