Skip to content

Commit 3872e44

Browse files
committed
Turned return type annotations of private methods into php return types.
1 parent 3498259 commit 3872e44

File tree

107 files changed

+205
-537
lines changed

Some content is hidden

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

107 files changed

+205
-537
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,9 @@ abstract protected function getMappingResourceExtension();
443443
/**
444444
* Search for a manager that is declared as 'auto_mapping' = true.
445445
*
446-
* @return string|null The name of the manager. If no one manager is found, returns null
447-
*
448446
* @throws \LogicException
449447
*/
450-
private function validateAutoMapping(array $managerConfigs)
448+
private function validateAutoMapping(array $managerConfigs): ?string
451449
{
452450
$autoMappedManager = null;
453451
foreach ($managerConfigs as $name => $manager) {

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,8 @@ private function getEventManagerDef(ContainerBuilder $container, string $name)
127127
*
128128
* @see https://bugs.php.net/bug.php?id=53710
129129
* @see https://bugs.php.net/bug.php?id=60926
130-
*
131-
* @return array
132130
*/
133-
private function findAndSortTags(string $tagName, ContainerBuilder $container)
131+
private function findAndSortTags(string $tagName, ContainerBuilder $container): array
134132
{
135133
$sortedTags = [];
136134

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,10 @@ protected function getDriver(ContainerBuilder $container)
191191
/**
192192
* Get the service name from the pattern and the configured manager name.
193193
*
194-
* @return string a service definition name
195-
*
196194
* @throws InvalidArgumentException if none of the managerParameters has a
197195
* non-empty value
198196
*/
199-
private function getConfigurationServiceName(ContainerBuilder $container)
197+
private function getConfigurationServiceName(ContainerBuilder $container): string
200198
{
201199
return sprintf($this->configurationPattern, $this->getManagerName($container));
202200
}
@@ -207,11 +205,9 @@ private function getConfigurationServiceName(ContainerBuilder $container)
207205
* The default implementation loops over the managerParameters and returns
208206
* the first non-empty parameter.
209207
*
210-
* @return string The name of the active manager
211-
*
212208
* @throws InvalidArgumentException if none of the managerParameters is found in the container
213209
*/
214-
private function getManagerName(ContainerBuilder $container)
210+
private function getManagerName(ContainerBuilder $container): string
215211
{
216212
foreach ($this->managerParameters as $param) {
217213
if ($container->hasParameter($param)) {

src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder)
8686

8787
/**
8888
* Converts a query parameter to an array.
89-
*
90-
* @return array The array representation of the parameter
9189
*/
92-
private function parameterToArray(Parameter $parameter)
90+
private function parameterToArray(Parameter $parameter): array
9391
{
9492
return [$parameter->getName(), $parameter->getType(), $parameter->getValue()];
9593
}

src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ public function setRepository(EntityManagerInterface $entityManager, $entityName
4747
$this->repositoryList[$repositoryHash] = $repository;
4848
}
4949

50-
/**
51-
* @return ObjectRepository
52-
*/
53-
private function createRepository(EntityManagerInterface $entityManager, string $entityName)
50+
private function createRepository(EntityManagerInterface $entityManager, string $entityName): ObjectRepository
5451
{
5552
/* @var $metadata ClassMetadata */
5653
$metadata = $entityManager->getClassMetadata($entityName);

src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function getDefaultFormatter()
172172
*
173173
* @return bool Whether the handler is enabled and verbosity is not set to quiet
174174
*/
175-
private function updateLevel()
175+
private function updateLevel(): bool
176176
{
177177
if (null === $this->output) {
178178
return false;

src/Symfony/Bridge/Monolog/Logger.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ public function removeDebugLogger()
9797

9898
/**
9999
* Returns a DebugLoggerInterface instance if one is registered with this logger.
100-
*
101-
* @return DebugLoggerInterface|null A DebugLoggerInterface instance or null if none is registered
102100
*/
103-
private function getDebugLogger()
101+
private function getDebugLogger(): ?DebugLoggerInterface
104102
{
105103
foreach ($this->processors as $processor) {
106104
if ($processor instanceof DebugLoggerInterface) {
@@ -113,5 +111,7 @@ private function getDebugLogger()
113111
return $handler;
114112
}
115113
}
114+
115+
return null;
116116
}
117117
}

src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ public function getPriority()
113113
return -10;
114114
}
115115

116-
/**
117-
* @return bool
118-
*/
119-
private function isNamedArguments(Node $arguments)
116+
private function isNamedArguments(Node $arguments): bool
120117
{
121118
foreach ($arguments as $name => $node) {
122119
if (!\is_int($name)) {

src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ public function testLintFileCompileTimeException()
6666
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
6767
}
6868

69-
/**
70-
* @return CommandTester
71-
*/
72-
private function createCommandTester()
69+
private function createCommandTester(): CommandTester
7370
{
7471
$command = new LintCommand(new Environment(new FilesystemLoader()));
7572

@@ -80,10 +77,7 @@ private function createCommandTester()
8077
return new CommandTester($command);
8178
}
8279

83-
/**
84-
* @return string Path to the new file
85-
*/
86-
private function createFile($content)
80+
private function createFile($content): string
8781
{
8882
$filename = tempnam(sys_get_temp_dir(), 'sf-');
8983
file_put_contents($filename, $content);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
7474
*
7575
* @return XmlFileLoader[]|YamlFileLoader[]
7676
*/
77-
private function extractSupportedLoaders(array $loaders)
77+
private function extractSupportedLoaders(array $loaders): array
7878
{
7979
$supportedLoaders = [];
8080

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function findAllTemplates()
7272
*
7373
* @return TemplateReferenceInterface[]
7474
*/
75-
private function findTemplatesInFolder(string $dir)
75+
private function findTemplatesInFolder(string $dir): array
7676
{
7777
$templates = [];
7878

@@ -96,7 +96,7 @@ private function findTemplatesInFolder(string $dir)
9696
*
9797
* @return TemplateReferenceInterface[]
9898
*/
99-
private function findTemplatesInBundle(BundleInterface $bundle)
99+
private function findTemplatesInBundle(BundleInterface $bundle): array
100100
{
101101
$name = $bundle->getName();
102102
$templates = array_unique(array_merge(

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array
8989
*
9090
* @return XmlFileLoader[]|YamlFileLoader[]
9191
*/
92-
private function extractSupportedLoaders(array $loaders)
92+
private function extractSupportedLoaders(array $loaders): array
9393
{
9494
$supportedLoaders = [];
9595

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

-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ protected function describeContainerEnvVars(array $envs, array $options = [])
188188

189189
/**
190190
* Writes data as json.
191-
*
192-
* @return array|string
193191
*/
194192
private function writeData(array $data, array $options)
195193
{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ protected function describeCallable($callable, array $options = [])
395395
/**
396396
* @return string
397397
*/
398-
private function formatRouterConfig(array $array)
398+
private function formatRouterConfig(array $array): string
399399
{
400400
if (!$array) {
401401
return 'NONE';

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ protected function describeContainerEnvVars(array $envs, array $options = [])
142142

143143
/**
144144
* Writes DOM document.
145-
*
146-
* @return \DOMDocument|string
147145
*/
148146
private function writeDocument(\DOMDocument $dom)
149147
{
@@ -392,7 +390,7 @@ private function getContainerDefinitionDocument(Definition $definition, string $
392390
/**
393391
* @return \DOMNode[]
394392
*/
395-
private function getArgumentNodes(array $arguments, \DOMDocument $dom)
393+
private function getArgumentNodes(array $arguments, \DOMDocument $dom): array
396394
{
397395
$nodes = [];
398396

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ public function testWithNotMatchPath()
4141
$this->assertStringContainsString('None of the routes match the path "/test"', $tester->getDisplay());
4242
}
4343

44-
/**
45-
* @return CommandTester
46-
*/
47-
private function createCommandTester()
44+
private function createCommandTester(): CommandTester
4845
{
4946
$application = new Application($this->getKernel());
5047
$application->add(new RouterMatchCommand($this->getRouter()));

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ protected function tearDown()
140140
$this->fs->remove($this->translationDir);
141141
}
142142

143-
/**
144-
* @return CommandTester
145-
*/
146-
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = [])
143+
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
147144
{
148145
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
149146
->disableOriginalConstructor()

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ protected function tearDown()
118118
$this->fs->remove($this->translationDir);
119119
}
120120

121-
/**
122-
* @return CommandTester
123-
*/
124-
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = [])
121+
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
125122
{
126123
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
127124
->disableOriginalConstructor()

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ public function testLintFilesFromBundleDirectory()
7272
$this->assertContains('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
7373
}
7474

75-
/**
76-
* @return CommandTester
77-
*/
78-
private function createCommandTester($application = null)
75+
private function createCommandTester($application = null): CommandTester
7976
{
8077
if (!$application) {
8178
$application = new BaseApplication();

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

+2-8
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ public function testLintFilesFromBundleDirectory()
109109
$this->assertStringContainsString('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay()));
110110
}
111111

112-
/**
113-
* @return string Path to the new file
114-
*/
115-
private function createFile($content)
112+
private function createFile($content): string
116113
{
117114
$filename = tempnam(sys_get_temp_dir().'/yml-lint-test', 'sf-');
118115
file_put_contents($filename, $content);
@@ -122,10 +119,7 @@ private function createFile($content)
122119
return $filename;
123120
}
124121

125-
/**
126-
* @return CommandTester
127-
*/
128-
private function createCommandTester($application = null)
122+
private function createCommandTester($application = null): CommandTester
129123
{
130124
if (!$application) {
131125
$application = new BaseApplication();

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ public function testGetUserWithEmptyContainer()
9898
$controller->getUser();
9999
}
100100

101-
/**
102-
* @param $token
103-
*
104-
* @return Container
105-
*/
106-
private function getContainerWithTokenStorage($token = null)
101+
private function getContainerWithTokenStorage($token = null): Container
107102
{
108103
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock();
109104
$tokenStorage

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ public function testDumpWithPrefixedEnv()
7474
$this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
7575
}
7676

77-
/**
78-
* @return CommandTester
79-
*/
80-
private function createCommandTester()
77+
private function createCommandTester(): CommandTester
8178
{
8279
$command = $this->application->find('debug:config');
8380

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ public function testDumpAtPathXml()
7373
$this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
7474
}
7575

76-
/**
77-
* @return CommandTester
78-
*/
79-
private function createCommandTester()
76+
private function createCommandTester(): CommandTester
8077
{
8178
$command = $this->application->find('config:dump-reference');
8279

src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Bundle\FrameworkBundle\Routing\Router;
1717
use Symfony\Component\Config\Loader\LoaderInterface;
1818
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
19+
use Symfony\Component\DependencyInjection\Container;
1920
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2021
use Symfony\Component\Routing\Route;
2122
use Symfony\Component\Routing\RouteCollection;
@@ -501,10 +502,7 @@ public function getNonStringValues()
501502
return [[null], [false], [true], [new \stdClass()], [['foo', 'bar']], [[[]]]];
502503
}
503504

504-
/**
505-
* @return \Symfony\Component\DependencyInjection\Container
506-
*/
507-
private function getServiceContainer(RouteCollection $routes)
505+
private function getServiceContainer(RouteCollection $routes): Container
508506
{
509507
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
510508

0 commit comments

Comments
 (0)