Skip to content

Commit

Permalink
Fix some code style issues (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Jun 6, 2024
1 parent 3f341b7 commit 572776c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
5 changes: 3 additions & 2 deletions Controller/FormTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ public function __construct(CsrfTokenManagerInterface $csrfTokenManager)
public function tokenAction(Request $request): Response
{
$formName = $request->get('form');
$formName = \is_string($formName) ? $formName : '';
$csrfToken = $this->csrfTokenManager->getToken($formName)->getValue();

$content = $csrfToken;

if ($request->get('html')) {
$formName = htmlspecialchars($formName, ENT_QUOTES, 'UTF-8');
$csrfToken = htmlspecialchars($csrfToken, ENT_QUOTES, 'UTF-8');
$formName = \htmlspecialchars($formName, \ENT_QUOTES, 'UTF-8');
$csrfToken = \htmlspecialchars($csrfToken, \ENT_QUOTES, 'UTF-8');

$content = \sprintf(
'<input type="hidden" id="%s__token" name="%s[_token]" value="%s" />',
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Controller/FormTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
class FormTokenControllerTest extends SuluTestCase
{
/**
* @var FormTokenController
* @var FormTokenControllerTest
*/
private formTokenController $formTokenController;
private $formTokenController;

protected function setUp(): void
{
Expand Down
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,6 @@ parameters:
count: 1
path: Controller/FormController.php

-
message: "#^Parameter \\#1 \\$tokenId of method Symfony\\\\Component\\\\Security\\\\Csrf\\\\CsrfTokenManagerInterface\\:\\:getToken\\(\\) expects string, mixed given\\.$#"
count: 1
path: Controller/FormTokenController.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
path: Controller/FormTokenController.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
path: Controller/FormTokenController.php

-
message: "#^Cannot call method all\\(\\) on Symfony\\\\Component\\\\Form\\\\FormInterface\\|null\\.$#"
count: 1
Expand Down

0 comments on commit 572776c

Please sign in to comment.