Skip to content

Commit 7c0d7ca

Browse files
Use typed properties in tests as much as possible
1 parent 9eb649d commit 7c0d7ca

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed

Tests/Authentication/Token/AbstractTokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testSetUser($user)
9696

9797
class ConcreteToken extends AbstractToken
9898
{
99-
private $credentials = 'credentials_value';
99+
private string $credentials = 'credentials_value';
100100

101101
public function __construct(array $roles = [], UserInterface $user = null)
102102
{

Tests/Authorization/AccessDecisionManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ protected static function getVoters($grants, $denies, $abstains): array
255255
protected static function getVoter($vote)
256256
{
257257
return new class($vote) implements VoterInterface {
258-
private $vote;
258+
private int $vote;
259259

260260
public function __construct(int $vote)
261261
{

Tests/Authorization/AuthorizationCheckerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Tests\Authorization;
1313

14+
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
1617
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
@@ -21,9 +22,9 @@
2122

2223
class AuthorizationCheckerTest extends TestCase
2324
{
24-
private $accessDecisionManager;
25-
private $authorizationChecker;
26-
private $tokenStorage;
25+
private MockObject&AccessDecisionManagerInterface $accessDecisionManager;
26+
private AuthorizationChecker $authorizationChecker;
27+
private TokenStorage $tokenStorage;
2728

2829
protected function setUp(): void
2930
{

Tests/Authorization/Voter/VoterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class VoterTest extends TestCase
2020
{
21-
protected $token;
21+
protected TokenInterface $token;
2222

2323
protected function setUp(): void
2424
{

Tests/Validator/Constraints/UserPasswordValidatorTestCase.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,9 @@ abstract class UserPasswordValidatorTestCase extends ConstraintValidatorTestCase
2929
private const PASSWORD = 's3Cr3t';
3030
private const SALT = '^S4lt$';
3131

32-
/**
33-
* @var TokenStorageInterface
34-
*/
35-
protected $tokenStorage;
36-
37-
/**
38-
* @var PasswordHasherInterface
39-
*/
40-
protected $hasher;
41-
42-
/**
43-
* @var PasswordHasherFactoryInterface
44-
*/
45-
protected $hasherFactory;
32+
protected TokenStorageInterface $tokenStorage;
33+
protected PasswordHasherInterface $hasher;
34+
protected PasswordHasherFactoryInterface $hasherFactory;
4635

4736
protected function createValidator(): UserPasswordValidator
4837
{

0 commit comments

Comments
 (0)