Skip to content

Commit e0d79f7

Browse files
derrabusnicolas-grekas
authored andcommitted
[Security] Fix return type declarations
1 parent c1b7118 commit e0d79f7

File tree

12 files changed

+33
-11
lines changed

12 files changed

+33
-11
lines changed

src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getName()
5858
*
5959
* The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
6060
*
61-
* @return string
61+
* @return string|null
6262
*/
6363
public function getType()
6464
{

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

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

1919
class DaoAuthenticationProviderTest extends TestCase
2020
{
21+
/**
22+
* @group legacy
23+
*/
2124
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
2225
{
2326
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
6262
$provider->authenticate($this->getSupportedToken());
6363
}
6464

65+
/**
66+
* @group legacy
67+
*/
6568
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
6669
{
6770
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');

src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
namespace Symfony\Component\Security\Guard\Tests\Provider;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1615
use Symfony\Component\Security\Core\User\UserInterface;
1716
use Symfony\Component\Security\Guard\AuthenticatorInterface;
1817
use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
18+
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
1919
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
2020
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
2121

@@ -68,7 +68,7 @@ public function testAuthenticate()
6868
->with($enteredCredentials, $mockedUser)
6969
// authentication works!
7070
->willReturn(true);
71-
$authedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
71+
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
7272
$authenticatorB->expects($this->once())
7373
->method('createAuthenticatedToken')
7474
->with($mockedUser, $providerKey)
@@ -130,7 +130,7 @@ public function testLegacyAuthenticate()
130130
->with($enteredCredentials, $mockedUser)
131131
// authentication works!
132132
->willReturn(true);
133-
$authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
133+
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
134134
$authenticatorB->expects($this->once())
135135
->method('createAuthenticatedToken')
136136
->with($mockedUser, $providerKey)

src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface AuthenticationSuccessHandlerInterface
3131
* is called by authentication listeners inheriting from
3232
* AbstractAuthenticationListener.
3333
*
34-
* @return Response never null
34+
* @return Response
3535
*/
3636
public function onAuthenticationSuccess(Request $request, TokenInterface $token);
3737
}

src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Http\Tests\Authentication;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\HttpKernel\HttpKernelInterface;
1718
use Symfony\Component\Security\Core\Security;
@@ -62,7 +63,7 @@ public function testForward()
6263

6364
public function testRedirect()
6465
{
65-
$response = new Response();
66+
$response = new RedirectResponse('/login');
6667
$this->httpUtils->expects($this->once())
6768
->method('createRedirectResponse')->with($this->request, '/login')
6869
->willReturn($response);

src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Http\Tests\EntryPoint;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\HttpKernel\HttpKernelInterface;
1718
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
@@ -21,7 +22,7 @@ class FormAuthenticationEntryPointTest extends TestCase
2122
public function testStart()
2223
{
2324
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
24-
$response = new Response();
25+
$response = new RedirectResponse('/the/login/path');
2526

2627
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
2728
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();

src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public function getAuthenticationExceptionProvider()
7272
];
7373
}
7474

75+
/**
76+
* @group legacy
77+
*/
7578
public function testExceptionWhenEntryPointReturnsBadValue()
7679
{
7780
$event = $this->createEvent(new AuthenticationException());

src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation()
122122
$listener->handle($event);
123123
}
124124

125+
/**
126+
* @group legacy
127+
*/
125128
public function testSuccessHandlerReturnsNonResponse()
126129
{
127130
$this->expectException('RuntimeException');

src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Tests\Http\Firewall;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\RedirectResponse;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -40,6 +41,10 @@ public function testHandleWhenUsernameLength($username, $ok)
4041
->method('checkRequestPath')
4142
->willReturn(true)
4243
;
44+
$httpUtils
45+
->method('createRedirectResponse')
46+
->willReturn(new RedirectResponse('/hello'))
47+
;
4348

4449
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
4550
$failureHandler
@@ -52,7 +57,7 @@ public function testHandleWhenUsernameLength($username, $ok)
5257
$authenticationManager
5358
->expects($ok ? $this->once() : $this->never())
5459
->method('authenticate')
55-
->willReturn(new Response())
60+
->willReturnArgument(0)
5661
;
5762

5863
$listener = new UsernamePasswordFormAuthenticationListener(
@@ -61,7 +66,7 @@ public function testHandleWhenUsernameLength($username, $ok)
6166
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
6267
$httpUtils,
6368
'TheProviderKey',
64-
$this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(),
69+
new DefaultAuthenticationSuccessHandler($httpUtils),
6570
$failureHandler,
6671
['require_previous_session' => false]
6772
);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy