Skip to content

Commit f92f6da

Browse files
Add return types to bundles
1 parent de2dd61 commit f92f6da

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
-118
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 & 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

Lines 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

0 commit comments

Comments
 (0)