Skip to content

Commit cd3f538

Browse files
committed
Add type declarations to Tests/ for PHPStan
1 parent 9462735 commit cd3f538

File tree

11 files changed

+87
-17
lines changed

11 files changed

+87
-17
lines changed

Tests/DependencyInjection/FOSOAuthServerExtensionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
class FOSOAuthServerExtensionTest extends \PHPUnit\Framework\TestCase
2525
{
26+
/**
27+
* @var ContainerBuilder
28+
*/
2629
private $container;
2730

2831
public function setUp()

Tests/Form/Handler/AuthorizeFormHandlerTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,25 @@
2929
*/
3030
class AuthorizeFormHandlerTest extends \PHPUnit\Framework\TestCase
3131
{
32+
/**
33+
* @var FormInterface&\PHPUnit\Framework\MockObject\MockObject
34+
*/
3235
protected $form;
33-
36+
/**
37+
* @var Request&\PHPUnit\Framework\MockObject\MockObject
38+
*/
3439
protected $request;
35-
40+
/**
41+
* @var ParameterBag&\PHPUnit\Framework\MockObject\MockObject
42+
*/
3643
protected $requestQuery;
37-
44+
/**
45+
* @var ParameterBag&\PHPUnit\Framework\MockObject\MockObject
46+
*/
3847
protected $requestRequest;
39-
48+
/**
49+
* @var ContainerInterface&\PHPUnit\Framework\MockObject\MockObject
50+
*/
4051
protected $container;
4152

4253
/**

Tests/Form/Type/AuthorizeFormTypeTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public function testGetBlockPrefix()
100100
$this->assertSame('fos_oauth_server_authorize', $this->instance->getBlockPrefix());
101101
}
102102

103+
/**
104+
* @return array<object>
105+
*/
103106
protected function getTypes()
104107
{
105108
return [

Tests/Functional/AppKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function getCacheDir()
4141
return sys_get_temp_dir().'/FOSOAuthServerBundle/';
4242
}
4343

44-
public function registerContainerConfiguration(LoaderInterface $loader)
44+
public function registerContainerConfiguration(LoaderInterface $loader): void
4545
{
4646
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
4747
}

Tests/Functional/BootTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function testBoot($env)
3333
}
3434
}
3535

36+
/**
37+
* @return array<mixed>
38+
*/
3639
public function getTestBootData()
3740
{
3841
return [

Tests/Functional/TestBundle/Entity/User.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ class User implements UserInterface
2525
* @ORM\Id
2626
* @ORM\Column(type="integer")
2727
* @ORM\GeneratedValue(strategy="AUTO")
28+
*
29+
* @var ?int
2830
*/
2931
protected $id;
3032

3133
/**
3234
* @ORM\Column(type="string")
35+
*
36+
* @var ?string
3337
*/
3438
protected $password;
3539

36-
public function getId()
40+
public function getId(): ?int
3741
{
3842
return $this->id;
3943
}
@@ -43,26 +47,27 @@ public function getRoles()
4347
return ['ROLE_USER'];
4448
}
4549

46-
public function getPassword()
50+
public function getPassword(): ?string
4751
{
4852
return $this->password;
4953
}
5054

51-
public function setPassword($password)
55+
public function setPassword(?string $password): void
5256
{
5357
$this->password = $password;
5458
}
5559

5660
public function getSalt()
5761
{
62+
return null;
5863
}
5964

6065
public function getUsername()
6166
{
6267
return $this->getId();
6368
}
6469

65-
public function eraseCredentials()
70+
public function eraseCredentials(): void
6671
{
6772
}
6873
}

Tests/Functional/TestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ protected function tearDown(): void
3535
static::$kernel = null;
3636
}
3737

38+
/**
39+
* @param array<mixed> $options
40+
*/
3841
protected static function createKernel(array $options = [])
3942
{
4043
$env = @$options['env'] ?: 'test';

Tests/Model/TokenTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function testHasExpired($expiresAt, $expect)
3838
$this->assertSame($expect, $token->hasExpired());
3939
}
4040

41+
/**
42+
* @return array<mixed>
43+
*/
4144
public static function getTestHasExpiredData()
4245
{
4346
return [

Tests/Security/Authentification/Token/OAuthTokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testSetTokenWillSetToken()
3838
;
3939

4040
$this->assertNull($this->instance->setToken($token));
41-
$this->assertAttributeSame($token, 'token', $this->instance);
41+
$this->assertSame($token, $this->instance->getToken());
4242
}
4343

4444
public function testGetTokenWillReturnToken()

Tests/Security/Firewall/OAuthListenerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,24 @@
2323

2424
class OAuthListenerTest extends TestCase
2525
{
26+
/**
27+
* @var OAuth2&\PHPUnit\Framework\MockObject\MockObject
28+
*/
2629
protected $serverService;
2730

31+
/**
32+
* @var AuthenticationManagerInterface&\PHPUnit\Framework\MockObject\MockObject
33+
*/
2834
protected $authManager;
2935

36+
/**
37+
* @var mixed&\PHPUnit\Framework\MockObject\MockObject
38+
*/
3039
protected $securityContext;
3140

41+
/**
42+
* @var RequestEvent&\PHPUnit\Framework\MockObject\MockObject
43+
*/
3244
protected $event;
3345

3446
public function setUp()

Tests/Storage/OAuthStorageTest.php

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,33 @@
2929

3030
class OAuthStorageTest extends \PHPUnit\Framework\TestCase
3131
{
32+
/**
33+
* @var ClientManagerInterface&\PHPUnit\Framework\MockObject\MockObject
34+
*/
3235
protected $clientManager;
33-
36+
/**
37+
* @var AccessTokenManagerInterface&\PHPUnit\Framework\MockObject\MockObject
38+
*/
3439
protected $accessTokenManager;
35-
40+
/**
41+
* @var RefreshTokenManagerInterface&\PHPUnit\Framework\MockObject\MockObject
42+
*/
3643
protected $refreshTokenManager;
37-
44+
/**
45+
* @var AuthCodeManagerInterface&\PHPUnit\Framework\MockObject\MockObject
46+
*/
3847
protected $authCodeManager;
39-
48+
/**
49+
* @var UserProviderInterface&\PHPUnit\Framework\MockObject\MockObject
50+
*/
4051
protected $userProvider;
41-
52+
/**
53+
* @var EncoderFactoryInterface&\PHPUnit\Framework\MockObject\MockObject
54+
*/
4255
protected $encoderFactory;
43-
56+
/**
57+
* @var OAuthStorage
58+
*/
4459
protected $storage;
4560

4661
public function setUp()
@@ -605,31 +620,43 @@ public function testMarkAuthCodeAsUsedIfAuthCodeNotFound()
605620

606621
class User implements UserInterface
607622
{
623+
/**
624+
* @var string|int
625+
*/
608626
private $username;
609627

628+
/**
629+
* @param string|int $username
630+
*/
610631
public function __construct($username)
611632
{
612633
$this->username = $username;
613634
}
614635

615636
public function getRoles()
616637
{
638+
return [];
617639
}
618640

619641
public function getPassword()
620642
{
643+
return null;
621644
}
622645

623646
public function getSalt()
624647
{
648+
return null;
625649
}
626650

651+
/**
652+
* @return string|int
653+
*/
627654
public function getUsername()
628655
{
629656
return $this->username;
630657
}
631658

632-
public function eraseCredentials()
659+
public function eraseCredentials(): void
633660
{
634661
}
635662
}

0 commit comments

Comments
 (0)