Skip to content

Commit 3198411

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

File tree

11 files changed

+85
-17
lines changed

11 files changed

+85
-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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ class User implements UserInterface
2525
* @ORM\Id
2626
* @ORM\Column(type="integer")
2727
* @ORM\GeneratedValue(strategy="AUTO")
28+
* @var ?int
2829
*/
2930
protected $id;
3031

3132
/**
3233
* @ORM\Column(type="string")
34+
* @var ?string
3335
*/
3436
protected $password;
3537

36-
public function getId()
38+
public function getId(): ?int
3739
{
3840
return $this->id;
3941
}
@@ -43,26 +45,27 @@ public function getRoles()
4345
return ['ROLE_USER'];
4446
}
4547

46-
public function getPassword()
48+
public function getPassword(): ?string
4749
{
4850
return $this->password;
4951
}
5052

51-
public function setPassword($password)
53+
public function setPassword(?string $password): void
5254
{
5355
$this->password = $password;
5456
}
5557

5658
public function getSalt()
5759
{
60+
return null;
5861
}
5962

6063
public function getUsername()
6164
{
6265
return $this->getId();
6366
}
6467

65-
public function eraseCredentials()
68+
public function eraseCredentials(): void
6669
{
6770
}
6871
}

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()

0 commit comments

Comments
 (0)