Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bddd980

Browse filesBrowse files
minor #42500 Add return types to bundles (nicolas-grekas)
This PR was merged into the 6.0 branch. Discussion ---------- Add return types to bundles | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Bundles should be the safest to patch since their classes should be more rarely extended. Commits ------- 89e3927 Add return types to bundles
2 parents 9004e35 + 89e3927 commit bddd980
Copy full SHA for bddd980

28 files changed

+59
-84
lines changed

‎src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
public function getConfigTreeBuilder()
27+
public function getConfigTreeBuilder(): TreeBuilder
2828
{
2929
$treeBuilder = new TreeBuilder('debug');
3030

‎src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ public function load(array $configs, ContainerBuilder $container)
100100
/**
101101
* {@inheritdoc}
102102
*/
103-
public function getXsdValidationBasePath()
103+
public function getXsdValidationBasePath(): string|false
104104
{
105105
return __DIR__.'/../Resources/config/schema';
106106
}
107107

108108
/**
109109
* {@inheritdoc}
110110
*/
111-
public function getNamespace()
111+
public function getNamespace(): string
112112
{
113113
return 'http://symfony.com/schema/dic/debug';
114114
}

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(string $phpArrayFile)
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
public function isOptional()
35+
public function isOptional(): bool
3636
{
3737
return true;
3838
}
@@ -42,7 +42,7 @@ public function isOptional()
4242
*
4343
* @return string[] A list of classes to preload on PHP 7.4+
4444
*/
45-
public function warmUp(string $cacheDir)
45+
public function warmUp(string $cacheDir): array
4646
{
4747
$arrayAdapter = new ArrayAdapter();
4848

@@ -66,7 +66,7 @@ public function warmUp(string $cacheDir)
6666
/**
6767
* @return string[] A list of classes to preload on PHP 7.4+
6868
*/
69-
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values)
69+
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
7070
{
7171
return (array) $phpArrayAdapter->warmUp($values);
7272
}
@@ -85,5 +85,5 @@ final protected function ignoreAutoloadException(string $class, \Exception $exce
8585
/**
8686
* @return bool false if there is nothing to warm-up
8787
*/
88-
abstract protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter);
88+
abstract protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool;
8989
}

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(Reader $annotationReader, string $phpArrayFile, stri
4545
/**
4646
* {@inheritdoc}
4747
*/
48-
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
48+
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
4949
{
5050
$annotatedClassPatterns = $cacheDir.'/annotations.map';
5151

@@ -76,7 +76,7 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
7676
/**
7777
* @return string[] A list of classes to preload on PHP 7.4+
7878
*/
79-
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values)
79+
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
8080
{
8181
// make sure we don't cache null values
8282
$values = array_filter($values, function ($val) { return null !== $val; });

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(KernelInterface $kernel, LoggerInterface $logger = n
4242
*
4343
* @return string[]
4444
*/
45-
public function warmUp(string $cacheDir)
45+
public function warmUp(string $cacheDir): array
4646
{
4747
$generator = new ConfigBuilderGenerator($cacheDir);
4848

@@ -84,7 +84,7 @@ private function dumpExtension(ExtensionInterface $extension, ConfigBuilderGener
8484
/**
8585
* {@inheritdoc}
8686
*/
87-
public function isOptional()
87+
public function isOptional(): bool
8888
{
8989
return true;
9090
}

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(array $loaders, string $phpArrayFile)
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
45+
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
4646
{
4747
if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
4848
return false;

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(ContainerInterface $container)
3838
*
3939
* @return string[]
4040
*/
41-
public function warmUp(string $cacheDir)
41+
public function warmUp(string $cacheDir): array
4242
{
4343
if (null === $this->translator) {
4444
$this->translator = $this->container->get('translator');
@@ -54,7 +54,7 @@ public function warmUp(string $cacheDir)
5454
/**
5555
* {@inheritdoc}
5656
*/
57-
public function isOptional()
57+
public function isOptional(): bool
5858
{
5959
return true;
6060
}

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(ValidatorBuilder $validatorBuilder, string $phpArray
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
45+
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
4646
{
4747
if (!method_exists($this->validatorBuilder, 'getLoaders')) {
4848
return false;
@@ -71,7 +71,7 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
7171
/**
7272
* @return string[] A list of classes to preload on PHP 7.4+
7373
*/
74-
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values)
74+
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
7575
{
7676
// make sure we don't cache null values
7777
$values = array_filter($values, function ($val) { return null !== $val; });

‎src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ protected function listBundles(OutputInterface|StyleInterface $output)
5454
}
5555
}
5656

57-
/**
58-
* @return ExtensionInterface
59-
*/
60-
protected function findExtension(string $name)
57+
protected function findExtension(string $name): ExtensionInterface
6158
{
6259
$bundles = $this->initializeBundles();
6360
$minScore = \INF;

‎src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Application.php
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public function __construct(KernelInterface $kernel)
4646

4747
/**
4848
* Gets the Kernel associated with this Console.
49-
*
50-
* @return KernelInterface
5149
*/
52-
public function getKernel()
50+
public function getKernel(): KernelInterface
5351
{
5452
return $this->kernel;
5553
}
@@ -69,7 +67,7 @@ public function reset()
6967
*
7068
* @return int 0 if everything went fine, or an error code
7169
*/
72-
public function doRun(InputInterface $input, OutputInterface $output)
70+
public function doRun(InputInterface $input, OutputInterface $output): int
7371
{
7472
$this->registerCommands();
7573

@@ -85,7 +83,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
8583
/**
8684
* {@inheritdoc}
8785
*/
88-
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
86+
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
8987
{
9088
if (!$command instanceof ListCommand) {
9189
if ($this->registrationErrors) {
@@ -109,7 +107,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
109107
/**
110108
* {@inheritdoc}
111109
*/
112-
public function find(string $name)
110+
public function find(string $name): Command
113111
{
114112
$this->registerCommands();
115113

@@ -119,7 +117,7 @@ public function find(string $name)
119117
/**
120118
* {@inheritdoc}
121119
*/
122-
public function get(string $name)
120+
public function get(string $name): Command
123121
{
124122
$this->registerCommands();
125123

@@ -135,7 +133,7 @@ public function get(string $name)
135133
/**
136134
* {@inheritdoc}
137135
*/
138-
public function all(string $namespace = null)
136+
public function all(string $namespace = null): array
139137
{
140138
$this->registerCommands();
141139

@@ -145,12 +143,12 @@ public function all(string $namespace = null)
145143
/**
146144
* {@inheritdoc}
147145
*/
148-
public function getLongVersion()
146+
public function getLongVersion(): string
149147
{
150148
return parent::getLongVersion().sprintf(' (env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
151149
}
152150

153-
public function add(Command $command)
151+
public function add(Command $command): ?Command
154152
{
155153
$this->registerCommands();
156154

‎src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ protected function formatParameter(mixed $value): string
171171
return (string) $value;
172172
}
173173

174-
/**
175-
* @return mixed
176-
*/
177-
protected function resolveServiceDefinition(ContainerBuilder $builder, string $serviceId)
174+
protected function resolveServiceDefinition(ContainerBuilder $builder, string $serviceId): mixed
178175
{
179176
if ($builder->hasDefinition($serviceId)) {
180177
return $builder->getDefinition($serviceId);

‎src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
7777
*
7878
* @return array|bool|float|int|string|null
7979
*/
80-
protected function getParameter(string $name)
80+
protected function getParameter(string $name): array|bool|float|int|string|null
8181
{
8282
if (!$this->container->has('parameter_bag')) {
8383
throw new ServiceNotFoundException('parameter_bag.', null, null, [], sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', static::class));
@@ -399,7 +399,7 @@ protected function getDoctrine(): ManagerRegistry
399399
*
400400
* @see TokenInterface::getUser()
401401
*/
402-
protected function getUser()
402+
protected function getUser(): ?object
403403
{
404404
if (!$this->container->has('security.token_storage')) {
405405
throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".');

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(bool $debug)
6262
*
6363
* @return TreeBuilder The tree builder
6464
*/
65-
public function getConfigTreeBuilder()
65+
public function getConfigTreeBuilder(): TreeBuilder
6666
{
6767
$treeBuilder = new TreeBuilder('framework');
6868
$rootNode = $treeBuilder->getRootNode();

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
3838
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
3939
use Symfony\Component\Cache\ResettableInterface;
40+
use Symfony\Component\Config\Definition\ConfigurationInterface;
4041
use Symfony\Component\Config\FileLocator;
4142
use Symfony\Component\Config\Loader\LoaderInterface;
4243
use Symfony\Component\Config\Resource\DirectoryResource;
@@ -585,7 +586,7 @@ public function load(array $configs, ContainerBuilder $container)
585586
/**
586587
* {@inheritdoc}
587588
*/
588-
public function getConfiguration(array $config, ContainerBuilder $container)
589+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
589590
{
590591
return new Configuration($container->getParameter('kernel.debug'));
591592
}
@@ -2583,12 +2584,12 @@ private function resolveTrustedHeaders(array $headers): int
25832584
/**
25842585
* {@inheritdoc}
25852586
*/
2586-
public function getXsdValidationBasePath()
2587+
public function getXsdValidationBasePath(): string|false
25872588
{
25882589
return \dirname(__DIR__).'/Resources/config/schema';
25892590
}
25902591

2591-
public function getNamespace()
2592+
public function getNamespace(): string
25922593
{
25932594
return 'http://symfony.com/schema/dic/symfony';
25942595
}

‎src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __construct(KernelInterface $kernel, string|StoreInterface $cach
6565
/**
6666
* {@inheritdoc}
6767
*/
68-
protected function forward(Request $request, bool $catch = false, Response $entry = null)
68+
protected function forward(Request $request, bool $catch = false, Response $entry = null): Response
6969
{
7070
$this->getKernel()->boot();
7171
$this->getKernel()->getContainer()->set('cache', $this);
@@ -78,7 +78,7 @@ protected function forward(Request $request, bool $catch = false, Response $entr
7878
*
7979
* @return array An array of options
8080
*/
81-
protected function getOptions()
81+
protected function getOptions(): array
8282
{
8383
return [];
8484
}

‎src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php
+6-16Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ public function __construct(KernelInterface $kernel, array $server = [], History
4444

4545
/**
4646
* Returns the container.
47-
*
48-
* @return ContainerInterface
4947
*/
50-
public function getContainer()
48+
public function getContainer(): ContainerInterface
5149
{
5250
$container = $this->kernel->getContainer();
5351

@@ -56,10 +54,8 @@ public function getContainer()
5654

5755
/**
5856
* Returns the kernel.
59-
*
60-
* @return KernelInterface
6157
*/
62-
public function getKernel()
58+
public function getKernel(): KernelInterface
6359
{
6460
return $this->kernel;
6561
}
@@ -69,7 +65,7 @@ public function getKernel()
6965
*
7066
* @return HttpProfile|false|null
7167
*/
72-
public function getProfile()
68+
public function getProfile(): HttpProfile|false|null
7369
{
7470
if (null === $this->response || !$this->getContainer()->has('profiler')) {
7571
return false;
@@ -146,10 +142,8 @@ public function loginUser(object $user, string $firewallContext = 'main'): self
146142
* {@inheritdoc}
147143
*
148144
* @param Request $request
149-
*
150-
* @return Response
151145
*/
152-
protected function doRequest(object $request)
146+
protected function doRequest(object $request): Response
153147
{
154148
// avoid shutting down the Kernel if no request has been performed yet
155149
// WebTestCase::createClient() boots the Kernel but do not handle a request
@@ -173,10 +167,8 @@ protected function doRequest(object $request)
173167
* {@inheritdoc}
174168
*
175169
* @param Request $request
176-
*
177-
* @return Response
178170
*/
179-
protected function doRequestInProcess(object $request)
171+
protected function doRequestInProcess(object $request): Response
180172
{
181173
$response = parent::doRequestInProcess($request);
182174

@@ -194,10 +186,8 @@ protected function doRequestInProcess(object $request)
194186
* client and override this method.
195187
*
196188
* @param Request $request
197-
*
198-
* @return string
199189
*/
200-
protected function getScript(object $request)
190+
protected function getScript(object $request): string
201191
{
202192
$kernel = var_export(serialize($this->kernel), true);
203193
$request = var_export(serialize($request), true);

‎src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ protected function configureRoute(Route $route, \ReflectionClass $class, \Reflec
3636

3737
/**
3838
* Makes the default route name more sane by removing common keywords.
39-
*
40-
* @return string
4139
*/
42-
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
40+
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string
4341
{
4442
$name = preg_replace('/(bundle|controller)_/', '_', parent::getDefaultRouteName($class, $method));
4543

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.