Skip to content

Turned return type annotations of private methods into php return types #32993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,9 @@ abstract protected function getMappingResourceExtension();
/**
* Search for a manager that is declared as 'auto_mapping' = true.
*
* @return string|null The name of the manager. If no one manager is found, returns null
*
* @throws \LogicException
*/
private function validateAutoMapping(array $managerConfigs)
private function validateAutoMapping(array $managerConfigs): ?string
{
$autoMappedManager = null;
foreach ($managerConfigs as $name => $manager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ private function getEventManagerDef(ContainerBuilder $container, string $name)
*
* @see https://bugs.php.net/bug.php?id=53710
* @see https://bugs.php.net/bug.php?id=60926
*
* @return array
*/
private function findAndSortTags(string $tagName, ContainerBuilder $container)
private function findAndSortTags(string $tagName, ContainerBuilder $container): array
{
$sortedTags = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,10 @@ protected function getDriver(ContainerBuilder $container)
/**
* Get the service name from the pattern and the configured manager name.
*
* @return string a service definition name
*
* @throws InvalidArgumentException if none of the managerParameters has a
* non-empty value
*/
private function getConfigurationServiceName(ContainerBuilder $container)
private function getConfigurationServiceName(ContainerBuilder $container): string
{
return sprintf($this->configurationPattern, $this->getManagerName($container));
}
Expand All @@ -207,11 +205,9 @@ private function getConfigurationServiceName(ContainerBuilder $container)
* The default implementation loops over the managerParameters and returns
* the first non-empty parameter.
*
* @return string The name of the active manager
*
* @throws InvalidArgumentException if none of the managerParameters is found in the container
*/
private function getManagerName(ContainerBuilder $container)
private function getManagerName(ContainerBuilder $container): string
{
foreach ($this->managerParameters as $param) {
if ($container->hasParameter($param)) {
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder)

/**
* Converts a query parameter to an array.
*
* @return array The array representation of the parameter
*/
private function parameterToArray(Parameter $parameter)
private function parameterToArray(Parameter $parameter): array
{
return [$parameter->getName(), $parameter->getType(), $parameter->getValue()];
}
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ public function setRepository(EntityManagerInterface $entityManager, $entityName
$this->repositoryList[$repositoryHash] = $repository;
}

/**
* @return ObjectRepository
*/
private function createRepository(EntityManagerInterface $entityManager, string $entityName)
private function createRepository(EntityManagerInterface $entityManager, string $entityName): ObjectRepository
{
/* @var $metadata ClassMetadata */
$metadata = $entityManager->getClassMetadata($entityName);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected function getDefaultFormatter()
*
* @return bool Whether the handler is enabled and verbosity is not set to quiet
*/
private function updateLevel()
private function updateLevel(): bool
{
if (null === $this->output) {
return false;
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ public function removeDebugLogger()

/**
* Returns a DebugLoggerInterface instance if one is registered with this logger.
*
* @return DebugLoggerInterface|null A DebugLoggerInterface instance or null if none is registered
*/
private function getDebugLogger()
private function getDebugLogger(): ?DebugLoggerInterface
{
foreach ($this->processors as $processor) {
if ($processor instanceof DebugLoggerInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ public function getPriority()
return -10;
}

/**
* @return bool
*/
private function isNamedArguments(Node $arguments)
private function isNamedArguments(Node $arguments): bool
{
foreach ($arguments as $name => $node) {
if (!\is_int($name)) {
Expand Down
10 changes: 2 additions & 8 deletions src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ public function testLintFileCompileTimeException()
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
}

/**
* @return CommandTester
*/
private function createCommandTester()
private function createCommandTester(): CommandTester
{
$command = new LintCommand(new Environment(new FilesystemLoader()));

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

/**
* @return string Path to the new file
*/
private function createFile($content)
private function createFile($content): string
{
$filename = tempnam(sys_get_temp_dir(), 'sf-');
file_put_contents($filename, $content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
*
* @return XmlFileLoader[]|YamlFileLoader[]
*/
private function extractSupportedLoaders(array $loaders)
private function extractSupportedLoaders(array $loaders): array
{
$supportedLoaders = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function findAllTemplates()
*
* @return TemplateReferenceInterface[]
*/
private function findTemplatesInFolder(string $dir)
private function findTemplatesInFolder(string $dir): array
{
$templates = [];

Expand All @@ -96,7 +96,7 @@ private function findTemplatesInFolder(string $dir)
*
* @return TemplateReferenceInterface[]
*/
private function findTemplatesInBundle(BundleInterface $bundle)
private function findTemplatesInBundle(BundleInterface $bundle): array
{
$name = $bundle->getName();
$templates = array_unique(array_merge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array
*
* @return XmlFileLoader[]|YamlFileLoader[]
*/
private function extractSupportedLoaders(array $loaders)
private function extractSupportedLoaders(array $loaders): array
{
$supportedLoaders = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,7 @@ protected function describeCallable($callable, array $options = [])
throw new \InvalidArgumentException('Callable is not describable.');
}

/**
* @return string
*/
private function formatRouterConfig(array $array)
private function formatRouterConfig(array $array): string
{
if (!$array) {
return 'NONE';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private function getContainerDefinitionDocument(Definition $definition, string $
/**
* @return \DOMNode[]
*/
private function getArgumentNodes(array $arguments, \DOMDocument $dom)
private function getArgumentNodes(array $arguments, \DOMDocument $dom): array
{
$nodes = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public function testWithNotMatchPath()
$this->assertStringContainsString('None of the routes match the path "/test"', $tester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester()
private function createCommandTester(): CommandTester
{
$application = new Application($this->getKernel());
$application->add(new RouterMatchCommand($this->getRouter()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ protected function tearDown()
$this->fs->remove($this->translationDir);
}

/**
* @return CommandTester
*/
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = [])
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
{
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
->disableOriginalConstructor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ protected function tearDown()
$this->fs->remove($this->translationDir);
}

/**
* @return CommandTester
*/
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = [])
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
{
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
->disableOriginalConstructor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ public function testLintFilesFromBundleDirectory()
$this->assertStringContainsString('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
}

/**
* @return CommandTester
*/
private function createCommandTester($application = null)
private function createCommandTester($application = null): CommandTester
{
if (!$application) {
$application = new BaseApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ public function testLintFilesFromBundleDirectory()
$this->assertStringContainsString('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay()));
}

/**
* @return string Path to the new file
*/
private function createFile($content)
private function createFile($content): string
{
$filename = tempnam(sys_get_temp_dir().'/yml-lint-test', 'sf-');
file_put_contents($filename, $content);
Expand All @@ -122,10 +119,7 @@ private function createFile($content)
return $filename;
}

/**
* @return CommandTester
*/
private function createCommandTester($application = null)
private function createCommandTester($application = null): CommandTester
{
if (!$application) {
$application = new BaseApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ public function testGetUserWithEmptyContainer()
$controller->getUser();
}

/**
* @param $token
*
* @return Container
*/
private function getContainerWithTokenStorage($token = null)
private function getContainerWithTokenStorage($token = null): Container
{
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock();
$tokenStorage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ public function testDumpWithPrefixedEnv()
$this->assertStringContainsString("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester()
private function createCommandTester(): CommandTester
{
$command = $this->application->find('debug:config');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ public function testDumpAtPathXml()
$this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester()
private function createCommandTester(): CommandTester
{
$command = $this->application->find('config:dump-reference');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
Expand Down Expand Up @@ -501,10 +502,7 @@ public function getNonStringValues()
return [[null], [false], [true], [new \stdClass()], [['foo', 'bar']], [[[]]]];
}

/**
* @return \Symfony\Component\DependencyInjection\Container
*/
private function getServiceContainer(RouteCollection $routes)
private function getServiceContainer(RouteCollection $routes): Container
{
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();

Expand Down
Loading