Skip to content
Permalink
Browse files

minor #33255 Add return types to internal|final|private methods (nico…

…las-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

Add return types to internal|final|private methods

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Related to #33228
This adds return-type declarations to internal, final and private methods.
Found by using a patched DebugClassLoader + manual edits.

Commits
-------

3211618 Add return types to internal|final|private methods
  • Loading branch information...
nicolas-grekas committed Aug 20, 2019
2 parents b253f25 + 3211618 commit 31b668b8c4622419f15894ab3dcba5bd2a43c64c
Showing with 256 additions and 519 deletions.
  1. +8 −13 src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
  2. +1 −5 src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
  3. +1 −3 src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php
  4. +3 −3 src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
  5. +1 −1 src/Symfony/Bridge/Twig/Extension/RoutingExtension.php
  6. +2 −2 src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php
  7. +1 −3 src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
  8. +5 −22 src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
  9. +1 −4 src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
  10. +1 −1 src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableCompiledUrlMatcher.php
  11. +8 −7 src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php
  12. +1 −1 src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php
  13. +2 −4 src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php
  14. +1 −4 src/Symfony/Component/Cache/Traits/PdoTrait.php
  15. +3 −10 src/Symfony/Component/Console/Descriptor/ApplicationDescription.php
  16. +3 −14 src/Symfony/Component/Console/Descriptor/XmlDescriptor.php
  17. +5 −11 src/Symfony/Component/Console/Formatter/OutputFormatter.php
  18. +1 −5 src/Symfony/Component/Console/Input/InputDefinition.php
  19. +2 −6 src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php
  20. +2 −8 src/Symfony/Component/CssSelector/Node/ElementNode.php
  21. +1 −1 src/Symfony/Component/CssSelector/Node/FunctionNode.php
  22. +2 −8 src/Symfony/Component/CssSelector/Node/NegationNode.php
  23. +5 −9 src/Symfony/Component/CssSelector/Parser/TokenStream.php
  24. +1 −3 src/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php
  25. +5 −5 src/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php
  26. +2 −2 src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php
  27. +4 −13 src/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php
  28. +2 −2 src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php
  29. +12 −38 src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php
  30. +2 −2 src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php
  31. +10 −31 src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php
  32. +1 −1 src/Symfony/Component/CssSelector/XPath/Translator.php
  33. +4 −12 src/Symfony/Component/DependencyInjection/ContainerBuilder.php
  34. +3 −3 src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php
  35. +1 −1 src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php
  36. +1 −3 src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php
  37. +1 −1 src/Symfony/Component/DependencyInjection/Tests/Compiler/CustomExpressionLanguageFunctionTest.php
  38. +1 −1 src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php
  39. +1 −1 src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
  40. +8 −16 src/Symfony/Component/DomCrawler/FormFieldRegistry.php
  41. +1 −1 src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
  42. +1 −3 src/Symfony/Component/ExpressionLanguage/TokenStream.php
  43. +2 −3 src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php
  44. +1 −1 src/Symfony/Component/Form/Util/OptionsResolverWrapper.php
  45. +1 −1 src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php
  46. +1 −3 src/Symfony/Component/HttpFoundation/Session/Session.php
  47. +4 −10 src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php
  48. +1 −3 src/Symfony/Component/HttpKernel/Bundle/Bundle.php
  49. +1 −1 src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php
  50. +2 −1 src/Symfony/Component/HttpKernel/EventListener/SessionListener.php
  51. +2 −1 src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php
  52. +1 −1 src/Symfony/Component/HttpKernel/HttpClientKernel.php
  53. +1 −9 src/Symfony/Component/HttpKernel/HttpKernel.php
  54. +5 −27 src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php
  55. +4 −4 src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php
  56. +4 −6 src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php
  57. +4 −4 src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php
  58. +4 −4 src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php
  59. +4 −4 src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php
  60. +4 −4 src/Symfony/Component/Intl/Data/Generator/ScriptDataGenerator.php
  61. +4 −4 src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php
  62. +2 −6 src/Symfony/Component/Intl/Data/Util/LocaleScanner.php
  63. +2 −2 src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
  64. +1 −1 src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php
  65. +4 −10 src/Symfony/Component/Intl/Globals/IntlGlobals.php
  66. +1 −1 src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php
  67. +3 −3 src/Symfony/Component/Ldap/Security/LdapUser.php
  68. +1 −3 src/Symfony/Component/Lock/Store/SemaphoreStore.php
  69. +1 −1 src/Symfony/Component/Messenger/MessageBus.php
  70. +2 −4 src/Symfony/Component/Process/Pipes/AbstractPipes.php
  71. +5 −5 src/Symfony/Component/Process/Pipes/UnixPipes.php
  72. +5 −5 src/Symfony/Component/Process/Pipes/WindowsPipes.php
  73. +3 −3 src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
  74. +4 −4 src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
  75. +1 −1 src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php
  76. +6 −6 src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php
  77. +6 −6 src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php
  78. +1 −3 src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php
  79. +2 −8 src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php
  80. +3 −3 src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
  81. +5 −5 src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php
  82. +1 −1 src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php
  83. +4 −4 src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php
  84. +2 −7 src/Symfony/Component/Security/Core/Security.php
  85. +3 −3 src/Symfony/Component/Security/Core/User/MissingUserProvider.php
  86. +1 −4 src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php
  87. +1 −1 src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
  88. +2 −6 src/Symfony/Component/Serializer/Encoder/ChainEncoder.php
  89. +1 −1 src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php
  90. +1 −1 src/Symfony/Component/Serializer/Serializer.php
  91. +2 −2 src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
  92. +1 −4 src/Symfony/Component/Translation/Command/XliffLintCommand.php
  93. +1 −3 src/Symfony/Component/Validator/Constraint.php
  94. +1 −7 src/Symfony/Component/Validator/Constraints/DateValidator.php
  95. +1 −7 src/Symfony/Component/Validator/Constraints/TimeValidator.php
  96. +2 −2 src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php
  97. +1 −1 src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php
  98. +1 −4 src/Symfony/Component/Yaml/Command/LintCommand.php
  99. +1 −6 src/Symfony/Component/Yaml/Inline.php
@@ -14,6 +14,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
@@ -51,12 +52,10 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
*
* @param object $choice The object
*
* @return string The string representation of the object
*
* @internal This method is public to be usable as callback. It should not
* be used in user code.
*/
public static function createChoiceLabel($choice)
public static function createChoiceLabel($choice): string
{
return (string) $choice;
}
@@ -73,12 +72,10 @@ public static function createChoiceLabel($choice)
* @param string $value The choice value. Corresponds to the object's
* ID here.
*
* @return string The field name
*
* @internal This method is public to be usable as callback. It should not
* be used in user code.
*/
public static function createChoiceName($choice, $key, $value)
public static function createChoiceName($choice, $key, $value): string
{
return str_replace('-', '_', (string) $value);
}
@@ -88,17 +85,15 @@ public static function createChoiceName($choice, $key, $value)
* For instance in ORM two query builders with an equal SQL string and
* equal parameters are considered to be equal.
*
* @param object $queryBuilder
*
* @return array|false Array with important QueryBuilder parts or false if
* they can't be determined
* @return array|null Array with important QueryBuilder parts or null if
* they can't be determined
*
* @internal This method is public to be usable as callback. It should not
* be used in user code.
*/
public function getQueryBuilderPartsForCachingHash($queryBuilder)
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
{
return false;
return null;
}
public function __construct(ManagerRegistry $registry)
@@ -127,7 +122,7 @@ public function configureOptions(OptionsResolver $resolver)
// If there is no QueryBuilder we can safely cache DoctrineChoiceLoader,
// also if concrete Type can return important QueryBuilder parts to generate
// hash key we go for it as well
if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) {
if (!$options['query_builder'] || null !== $qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder'])) {
$hash = CachingFactoryDecorator::generateHash([
$options['em'],
$options['class'],
@@ -68,14 +68,10 @@ public function getBlockPrefix()
* We consider two query builders with an equal SQL string and
* equal parameters to be equal.
*
* @param QueryBuilder $queryBuilder
*
* @return array
*
* @internal This method is public to be usable as callback. It should not
* be used in user code.
*/
public function getQueryBuilderPartsForCachingHash($queryBuilder)
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
{
return [
$queryBuilder->getQuery()->getSQL(),
@@ -29,10 +29,8 @@ public function setFluentSafe(bool $fluentSafe)
/**
* {@inheritdoc}
*
* @return void
*/
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator)
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator): void
{
parent::generate($originalClass, $classGenerator);
@@ -40,15 +40,15 @@ public function __construct(string $salt = '')
/**
* {@inheritdoc}
*/
public function isProxyCandidate(Definition $definition)
public function isProxyCandidate(Definition $definition): bool
{
return ($definition->isLazy() || $definition->hasTag('proxy')) && $this->proxyGenerator->getProxifiedClass($definition);
}
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null)
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string
{
$instantiation = 'return';
@@ -82,7 +82,7 @@ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode =
/**
* {@inheritdoc}
*/
public function getProxyCode(Definition $definition)
public function getProxyCode(Definition $definition): string
{
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
@@ -93,7 +93,7 @@ public function getUrl($name, $parameters = [], $schemeRelative = false)
*
* @final
*/
public function isUrlGenerationSafe(Node $argsNode)
public function isUrlGenerationSafe(Node $argsNode): array
{
// support named arguments
$paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : (
@@ -57,15 +57,15 @@ public function warmUp($cacheDir)
*
* @return bool always true
*/
public function isOptional()
public function isOptional(): bool
{
return true;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
'router' => RouterInterface::class,
@@ -213,11 +213,9 @@ protected function validateInput(InputInterface $input)
/**
* Loads the ContainerBuilder from the cache.
*
* @return ContainerBuilder
*
* @throws \LogicException
*/
protected function getContainerBuilder()
protected function getContainerBuilder(): ContainerBuilder
{
if ($this->containerBuilder) {
return $this->containerBuilder;
@@ -84,23 +84,12 @@ public function describe(OutputInterface $output, $object, array $options = [])
}
}
/**
* Returns the output.
*
* @return OutputInterface The output
*/
protected function getOutput()
protected function getOutput(): OutputInterface
{
return $this->output;
}
/**
* Writes content to output.
*
* @param string $content
* @param bool $decorated
*/
protected function write($content, $decorated = false)
protected function write(string $content, bool $decorated = false)
{
$this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
}
@@ -182,10 +171,8 @@ protected function write($content, $decorated = false)
* Formats a value as string.
*
* @param mixed $value
*
* @return string
*/
protected function formatValue($value)
protected function formatValue($value): string
{
if (\is_object($value)) {
return sprintf('object(%s)', \get_class($value));
@@ -202,10 +189,8 @@ protected function formatValue($value)
* Formats a parameter.
*
* @param mixed $value
*
* @return string
*/
protected function formatParameter($value)
protected function formatParameter($value): string
{
if (\is_bool($value) || \is_array($value) || (null === $value)) {
$jsonString = json_encode($value);
@@ -246,10 +231,8 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, $serviceI
/**
* @param bool $showHidden
*
* @return array
*/
protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden)
protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden): array
{
$definitions = [];
$tags = $builder->findTags();
@@ -198,10 +198,7 @@ private function writeData(array $data, array $options)
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
}
/**
* @return array
*/
protected function getRouteData(Route $route)
protected function getRouteData(Route $route): array
{
$data = [
'path' => $route->getPath(),
@@ -24,7 +24,7 @@ class RedirectableCompiledUrlMatcher extends CompiledUrlMatcher implements Redir
/**
* {@inheritdoc}
*/
public function redirect($path, $route, $scheme = null)
public function redirect($path, $route, $scheme = null): array
{
return [
'_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction',
@@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Test;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpKernel\KernelInterface;
/**
@@ -41,15 +42,15 @@ public function compile()
/**
* {@inheritdoc}
*/
public function isCompiled()
public function isCompiled(): bool
{
return $this->getPublicContainer()->isCompiled();
}
/**
* {@inheritdoc}
*/
public function getParameterBag()
public function getParameterBag(): ParameterBagInterface
{
return $this->getPublicContainer()->getParameterBag();
}
@@ -65,7 +66,7 @@ public function getParameter($name)
/**
* {@inheritdoc}
*/
public function hasParameter($name)
public function hasParameter($name): bool
{
return $this->getPublicContainer()->hasParameter($name);
}
@@ -89,7 +90,7 @@ public function set($id, $service)
/**
* {@inheritdoc}
*/
public function has($id)
public function has($id): bool
{
return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id);
}
@@ -105,7 +106,7 @@ public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERE
/**
* {@inheritdoc}
*/
public function initialized($id)
public function initialized($id): bool
{
return $this->getPublicContainer()->initialized($id);
}
@@ -121,15 +122,15 @@ public function reset()
/**
* {@inheritdoc}
*/
public function getServiceIds()
public function getServiceIds(): array
{
return $this->getPublicContainer()->getServiceIds();
}
/**
* {@inheritdoc}
*/
public function getRemovedIds()
public function getRemovedIds(): array
{
return $this->getPublicContainer()->getRemovedIds();
}
@@ -39,7 +39,7 @@ public function onVoterVote(VoteEvent $event)
$this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote());
}
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return ['debug.security.authorization.vote' => 'onVoterVote'];
}
@@ -38,10 +38,8 @@ public function __construct(NonceGenerator $nonceGenerator)
* - The request - In case HTML content is fetched via AJAX and inserted in DOM, it must use the same nonce as origin
* - The response - A call to getNonces() has already been done previously. Same nonce are returned
* - They are otherwise randomly generated
*
* @return array
*/
public function getNonces(Request $request, Response $response)
public function getNonces(Request $request, Response $response): array
{
if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) {
return [
@@ -83,7 +81,7 @@ public function disableCsp()
*
* @return array Nonces used by the bundle in Content-Security-Policy header
*/
public function updateResponseHeaders(Request $request, Response $response)
public function updateResponseHeaders(Request $request, Response $response): array
{
if ($this->cspDisabled) {
$this->removeCspHeaders($response);
@@ -403,10 +403,7 @@ private function getConnection()
return $this->conn;
}
/**
* @return string
*/
private function getServerVersion()
private function getServerVersion(): string
{
if (null === $this->serverVersion) {
$conn = $this->conn instanceof \PDO ? $this->conn : $this->conn->getWrappedConnection();
@@ -50,10 +50,7 @@ public function __construct(Application $application, string $namespace = null,
$this->showHidden = $showHidden;
}
/**
* @return array
*/
public function getNamespaces()
public function getNamespaces(): array
{
if (null === $this->namespaces) {
$this->inspectApplication();
@@ -65,7 +62,7 @@ public function getNamespaces()
/**
* @return Command[]
*/
public function getCommands()
public function getCommands(): array
{
if (null === $this->commands) {
$this->inspectApplication();
@@ -75,13 +72,9 @@ public function getCommands()
}
/**
* @param string $name
*
* @return Command
*
* @throws CommandNotFoundException
*/
public function getCommand($name)
public function getCommand(string $name): Command
{
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));

0 comments on commit 31b668b

Please sign in to comment.
You can’t perform that action at this time.