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

Skip to content

Commit 51dff54

Browse files
Add return types to bundles
1 parent de2dd61 commit 51dff54

Some content is hidden

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

41 files changed

+90
-88
lines changed

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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function listBundles(OutputInterface|StyleInterface $output)
5757
/**
5858
* @return ExtensionInterface
5959
*/
60-
protected function findExtension(string $name)
60+
protected function findExtension(string $name): ExtensionInterface
6161
{
6262
$bundles = $this->initializeBundles();
6363
$minScore = \INF;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(KernelInterface $kernel)
4949
*
5050
* @return KernelInterface
5151
*/
52-
public function getKernel()
52+
public function getKernel(): KernelInterface
5353
{
5454
return $this->kernel;
5555
}
@@ -69,7 +69,7 @@ public function reset()
6969
*
7070
* @return int 0 if everything went fine, or an error code
7171
*/
72-
public function doRun(InputInterface $input, OutputInterface $output)
72+
public function doRun(InputInterface $input, OutputInterface $output): int
7373
{
7474
$this->registerCommands();
7575

@@ -85,7 +85,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
8585
/**
8686
* {@inheritdoc}
8787
*/
88-
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
88+
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
8989
{
9090
if (!$command instanceof ListCommand) {
9191
if ($this->registrationErrors) {
@@ -109,7 +109,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
109109
/**
110110
* {@inheritdoc}
111111
*/
112-
public function find(string $name)
112+
public function find(string $name): Command
113113
{
114114
$this->registerCommands();
115115

@@ -119,7 +119,7 @@ public function find(string $name)
119119
/**
120120
* {@inheritdoc}
121121
*/
122-
public function get(string $name)
122+
public function get(string $name): Command
123123
{
124124
$this->registerCommands();
125125

@@ -135,7 +135,7 @@ public function get(string $name)
135135
/**
136136
* {@inheritdoc}
137137
*/
138-
public function all(string $namespace = null)
138+
public function all(string $namespace = null): array
139139
{
140140
$this->registerCommands();
141141

@@ -145,12 +145,12 @@ public function all(string $namespace = null)
145145
/**
146146
* {@inheritdoc}
147147
*/
148-
public function getLongVersion()
148+
public function getLongVersion(): string
149149
{
150150
return parent::getLongVersion().sprintf(' (env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
151151
}
152152

153-
public function add(Command $command)
153+
public function add(Command $command): ?Command
154154
{
155155
$this->registerCommands();
156156

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ protected function formatParameter(mixed $value): string
174174
/**
175175
* @return mixed
176176
*/
177-
protected function resolveServiceDefinition(ContainerBuilder $builder, string $serviceId)
177+
protected function resolveServiceDefinition(ContainerBuilder $builder, string $serviceId): mixed
178178
{
179179
if ($builder->hasDefinition($serviceId)) {
180180
return $builder->getDefinition($serviceId);

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

Lines 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

Lines 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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

14+
use Symfony\Component\Config\Definition\ConfigurationInterface;
1415
use Doctrine\Common\Annotations\AnnotationRegistry;
1516
use Doctrine\Common\Annotations\Reader;
1617
use Http\Client\HttpClient;
@@ -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

Lines 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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(KernelInterface $kernel, array $server = [], History
4747
*
4848
* @return ContainerInterface
4949
*/
50-
public function getContainer()
50+
public function getContainer(): ContainerInterface
5151
{
5252
$container = $this->kernel->getContainer();
5353

@@ -59,7 +59,7 @@ public function getContainer()
5959
*
6060
* @return KernelInterface
6161
*/
62-
public function getKernel()
62+
public function getKernel(): KernelInterface
6363
{
6464
return $this->kernel;
6565
}
@@ -69,7 +69,7 @@ public function getKernel()
6969
*
7070
* @return HttpProfile|false|null
7171
*/
72-
public function getProfile()
72+
public function getProfile(): HttpProfile|false|null
7373
{
7474
if (null === $this->response || !$this->getContainer()->has('profiler')) {
7575
return false;
@@ -149,7 +149,7 @@ public function loginUser(object $user, string $firewallContext = 'main'): self
149149
*
150150
* @return Response
151151
*/
152-
protected function doRequest(object $request)
152+
protected function doRequest(object $request): Response
153153
{
154154
// avoid shutting down the Kernel if no request has been performed yet
155155
// WebTestCase::createClient() boots the Kernel but do not handle a request
@@ -176,7 +176,7 @@ protected function doRequest(object $request)
176176
*
177177
* @return Response
178178
*/
179-
protected function doRequestInProcess(object $request)
179+
protected function doRequestInProcess(object $request): Response
180180
{
181181
$response = parent::doRequestInProcess($request);
182182

@@ -197,7 +197,7 @@ protected function doRequestInProcess(object $request)
197197
*
198198
* @return string
199199
*/
200-
protected function getScript(object $request)
200+
protected function getScript(object $request): string
201201
{
202202
$kernel = var_export(serialize($this->kernel), true);
203203
$request = var_export(serialize($request), true);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function configureRoute(Route $route, \ReflectionClass $class, \Reflec
3939
*
4040
* @return string
4141
*/
42-
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
42+
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string
4343
{
4444
$name = preg_replace('/(bundle|controller)_/', '_', parent::getDefaultRouteName($class, $method));
4545

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(ContainerInterface $container, mixed $resource, arra
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function getRouteCollection()
65+
public function getRouteCollection(): RouteCollection
6666
{
6767
if (null === $this->collection) {
6868
$this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
@@ -88,7 +88,7 @@ public function getRouteCollection()
8888
*
8989
* @return string[] A list of classes to preload on PHP 7.4+
9090
*/
91-
public function warmUp(string $cacheDir)
91+
public function warmUp(string $cacheDir): array
9292
{
9393
$currentDir = $this->getOption('cache_dir');
9494

0 commit comments

Comments
 (0)