Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 682b76f

Browse files
minor #42615 Add missing return types to tests/internal/final methods (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- Add missing return types to tests/internal/final methods | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Thanks to #42149 again Commits ------- 0f39a0f Add missing return types to tests/internal/final methods
2 parents cf90b8b + 0f39a0f commit 682b76f

File tree

66 files changed

+125
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+125
-139
lines changed

.github/patch-types.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
3232
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
3333
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
34-
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php'):
35-
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php'):
34+
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/'):
3635
case false !== strpos($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'):
36+
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Fixtures/'):
3737
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'):
3838
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
3939
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'):

src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ public function registerContainerConfiguration(LoaderInterface $loader)
165165

166166
/**
167167
* @internal
168-
*
169-
* @return RouteCollection
170168
*/
171-
public function loadRoutes(LoaderInterface $loader)
169+
public function loadRoutes(LoaderInterface $loader): RouteCollection
172170
{
173171
$file = (new \ReflectionObject($this))->getFileName();
174172
/* @var RoutingPhpFileLoader $kernelLoader */

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ protected function tearDown(): void
145145
$this->fs->remove($this->translationDir);
146146
}
147147

148-
/**
149-
* @return CommandTester
150-
*/
151-
private function createCommandTester($extractedMessages = [], $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $codePaths = [])
148+
private function createCommandTester($extractedMessages = [], $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []): CommandTester
152149
{
153150
$translator = $this->createMock(Translator::class);
154151
$translator

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function getKernelParameters(): array
106106
return $parameters;
107107
}
108108

109-
public function getConfigTreeBuilder()
109+
public function getConfigTreeBuilder(): TreeBuilder
110110
{
111111
$treeBuilder = new TreeBuilder('foo');
112112
$rootNode = $treeBuilder->getRootNode();
@@ -119,7 +119,7 @@ public function load(array $configs, ContainerBuilder $container)
119119
{
120120
}
121121

122-
public function getNamespace()
122+
public function getNamespace(): string
123123
{
124124
return '';
125125
}
@@ -129,7 +129,7 @@ public function getXsdValidationBasePath()
129129
return false;
130130
}
131131

132-
public function getAlias()
132+
public function getAlias(): string
133133
{
134134
return 'foo';
135135
}

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterEntryPointsPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
9393
], JsonResponse::HTTP_FORBIDDEN);
9494
}
9595

96-
public function start(Request $request, AuthenticationException $authException = null)
96+
public function start(Request $request, AuthenticationException $authException = null): Response
9797
{
9898
}
9999
}

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use Symfony\Component\Security\Core\User\UserInterface;
3737
use Symfony\Component\Security\Core\User\UserProviderInterface;
3838
use Symfony\Component\Security\Guard\AuthenticatorInterface as GuardAuthenticatorInterface;
39+
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
3940
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
4041
use Symfony\Component\Security\Http\Authenticator\HttpBasicAuthenticator;
4142
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
@@ -865,39 +866,39 @@ public function createToken(Passport $passport, string $firewallName): TokenInte
865866

866867
class NullAuthenticator implements GuardAuthenticatorInterface
867868
{
868-
public function start(Request $request, AuthenticationException $authException = null)
869+
public function start(Request $request, AuthenticationException $authException = null): Response
869870
{
870871
}
871872

872-
public function supports(Request $request)
873+
public function supports(Request $request): bool
873874
{
874875
}
875876

876877
public function getCredentials(Request $request)
877878
{
878879
}
879880

880-
public function getUser($credentials, UserProviderInterface $userProvider)
881+
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
881882
{
882883
}
883884

884-
public function checkCredentials($credentials, UserInterface $user)
885+
public function checkCredentials($credentials, UserInterface $user): bool
885886
{
886887
}
887888

888-
public function createAuthenticatedToken(UserInterface $user, string $providerKey)
889+
public function createAuthenticatedToken(UserInterface $user, string $providerKey): GuardTokenInterface
889890
{
890891
}
891892

892-
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
893+
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
893894
{
894895
}
895896

896-
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey)
897+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey): ?Response
897898
{
898899
}
899900

900-
public function supportsRememberMe()
901+
public function supportsRememberMe(): bool
901902
{
902903
}
903904
}
@@ -922,20 +923,20 @@ public function createListeners(ContainerBuilder $container, string $firewallNam
922923
return ['custom_firewall_listener_id'];
923924
}
924925

925-
public function create(ContainerBuilder $container, string $id, array $config, string $userProvider, ?string $defaultEntryPoint)
926+
public function create(ContainerBuilder $container, string $id, array $config, string $userProvider, ?string $defaultEntryPoint): array
926927
{
927928
$container->register('provider_id', \stdClass::class);
928929
$container->register('listener_id', \stdClass::class);
929930

930931
return ['provider_id', 'listener_id', $defaultEntryPoint];
931932
}
932933

933-
public function getPosition()
934+
public function getPosition(): string
934935
{
935936
return 'form';
936937
}
937938

938-
public function getKey()
939+
public function getKey(): string
939940
{
940941
return 'custom_listener';
941942
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class AppCustomAuthenticator extends AbstractGuardAuthenticator
2323
{
24-
public function supports(Request $request)
24+
public function supports(Request $request): bool
2525
{
2626
return false;
2727
}
@@ -30,28 +30,28 @@ public function getCredentials(Request $request)
3030
{
3131
}
3232

33-
public function getUser($credentials, UserProviderInterface $userProvider)
33+
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
3434
{
3535
}
3636

37-
public function checkCredentials($credentials, UserInterface $user)
37+
public function checkCredentials($credentials, UserInterface $user): bool
3838
{
3939
}
4040

41-
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
41+
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
4242
{
4343
}
4444

45-
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
45+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response
4646
{
4747
}
4848

49-
public function start(Request $request, AuthenticationException $authException = null)
49+
public function start(Request $request, AuthenticationException $authException = null): Response
5050
{
5151
return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED);
5252
}
5353

54-
public function supportsRememberMe()
54+
public function supportsRememberMe(): bool
5555
{
5656
}
5757
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function secureAction()
5454
/**
5555
* {@inheritdoc}
5656
*/
57-
public static function getSubscribedServices()
57+
public static function getSubscribedServices(): array
5858
{
5959
return [
6060
'form.factory' => FormFactoryInterface::class,

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function homepageAction()
7171
/**
7272
* {@inheritdoc}
7373
*/
74-
public static function getSubscribedServices()
74+
public static function getSubscribedServices(): array
7575
{
7676
return [
7777
'twig' => Environment::class,

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function secureAction()
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
public static function getSubscribedServices()
66+
public static function getSubscribedServices(): array
6767
{
6868
return [
6969
'twig' => Environment::class,

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class AppCustomAuthenticator extends AbstractGuardAuthenticator
2323
{
24-
public function supports(Request $request)
24+
public function supports(Request $request): bool
2525
{
2626
return '/manual_login' !== $request->getPathInfo() && '/profile' !== $request->getPathInfo();
2727
}
@@ -31,29 +31,29 @@ public function getCredentials(Request $request)
3131
throw new AuthenticationException('This should be hit');
3232
}
3333

34-
public function getUser($credentials, UserProviderInterface $userProvider)
34+
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
3535
{
3636
}
3737

38-
public function checkCredentials($credentials, UserInterface $user)
38+
public function checkCredentials($credentials, UserInterface $user): bool
3939
{
4040
}
4141

42-
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
42+
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
4343
{
4444
return new Response('', 418);
4545
}
4646

47-
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
47+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response
4848
{
4949
}
5050

51-
public function start(Request $request, AuthenticationException $authException = null)
51+
public function start(Request $request, AuthenticationException $authException = null): Response
5252
{
5353
return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED);
5454
}
5555

56-
public function supportsRememberMe()
56+
public function supportsRememberMe(): bool
5757
{
5858
}
5959
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/LoginLink/TestCustomLoginLinkSuccessHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
use Symfony\Component\HttpFoundation\JsonResponse;
66
use Symfony\Component\HttpFoundation\Request;
7+
use Symfony\Component\HttpFoundation\Response;
78
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
89
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
910

1011
class TestCustomLoginLinkSuccessHandler implements AuthenticationSuccessHandlerInterface
1112
{
12-
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
13+
public function onAuthenticationSuccess(Request $request, TokenInterface $token): Response
1314
{
1415
return new JsonResponse(['message' => sprintf('Welcome %s!', $token->getUserIdentifier())]);
1516
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/RememberMeBundle/Security/StaticTokenProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct($kernel)
2929
}
3030
}
3131

32-
public function loadTokenBySeries(string $series)
32+
public function loadTokenBySeries(string $series): PersistentTokenInterface
3333
{
3434
$token = self::$db[$series] ?? false;
3535
if (!$token) {

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/RememberMeBundle/Security/UserChangingUserProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(InMemoryUserProvider $inner)
2626
$this->inner = $inner;
2727
}
2828

29-
public function loadUserByUsername($username)
29+
public function loadUserByUsername($username): UserInterface
3030
{
3131
return $this->inner->loadUserByUsername($username);
3232
}
@@ -36,7 +36,7 @@ public function loadUserByIdentifier(string $userIdentifier): UserInterface
3636
return $this->inner->loadUserByIdentifier($userIdentifier);
3737
}
3838

39-
public function refreshUser(UserInterface $user)
39+
public function refreshUser(UserInterface $user): UserInterface
4040
{
4141
$user = $this->inner->refreshUser($user);
4242

@@ -46,7 +46,7 @@ public function refreshUser(UserInterface $user)
4646
return $user;
4747
}
4848

49-
public function supportsClass($class)
49+
public function supportsClass($class): bool
5050
{
5151
return $this->inner->supportsClass($class);
5252
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getUser($username)
2929
return $this->users[$username];
3030
}
3131

32-
public function loadUserByUsername($username)
32+
public function loadUserByUsername($username): UserInterface
3333
{
3434
return $this->loadUserByIdentifier($username);
3535
}
@@ -48,7 +48,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
4848
return $user;
4949
}
5050

51-
public function refreshUser(UserInterface $user)
51+
public function refreshUser(UserInterface $user): UserInterface
5252
{
5353
if (!$user instanceof UserInterface) {
5454
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
@@ -60,7 +60,7 @@ public function refreshUser(UserInterface $user)
6060
return new $class($storedUser->getUserIdentifier(), $storedUser->getPassword(), $storedUser->getRoles(), $storedUser->isEnabled());
6161
}
6262

63-
public function supportsClass($class)
63+
public function supportsClass($class): bool
6464
{
6565
return InMemoryUser::class === $class || UserWithoutEquatable::class === $class;
6666
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function __toString()
161161
/**
162162
* {@inheritdoc}
163163
*/
164-
public function getRoles()
164+
public function getRoles(): array
165165
{
166166
return $this->roles;
167167
}

src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
parent::__construct('test', false);
2424
}
2525

26-
public function registerBundles()
26+
public function registerBundles(): iterable
2727
{
2828
return [
2929
new FrameworkBundle(),
@@ -59,7 +59,7 @@ public function getCacheDir(): string
5959
return sys_get_temp_dir().'/cache-'.spl_object_hash($this);
6060
}
6161

62-
public function getLogDir()
62+
public function getLogDir(): string
6363
{
6464
return sys_get_temp_dir().'/log-'.spl_object_hash($this);
6565
}

src/Symfony/Component/Config/Tests/Fixtures/Configuration/CustomNodeDefinition.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
namespace Symfony\Component\Config\Tests\Fixtures\Configuration;
55

6+
use Symfony\Component\Config\Definition\NodeInterface;
67
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
78

89
class CustomNodeDefinition extends NodeDefinition
910
{
10-
protected function createNode()
11+
protected function createNode(): NodeInterface
1112
{
1213
return new CustomNode();
1314
}

src/Symfony/Component/Console/Terminal.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ public function getHeight()
5757

5858
/**
5959
* @internal
60-
*
61-
* @return bool
6260
*/
63-
public static function hasSttyAvailable()
61+
public static function hasSttyAvailable(): bool
6462
{
6563
if (null !== self::$stty) {
6664
return self::$stty;

0 commit comments

Comments
 (0)