8000 Add return types to internal|final|private methods · symfony/symfony@3211618 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3211618

Browse files
Add return types to internal|final|private methods
1 parent b253f25 commit 3211618

File tree

99 files changed

+256
-519
lines changed

Some content is hidden

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

99 files changed

+256
-519
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Common\Collections\Collection;
1515
use Doctrine\Common\Persistence\ManagerRegistry;
1616
use Doctrine\Common\Persistence\ObjectManager;
17+
use Doctrine\ORM\QueryBuilder;
1718
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
1819
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
1920
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
@@ -51,12 +52,10 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
5152
*
5253
* @param object $choice The object
5354
*
54-
* @return string The string representation of the object
55-
*
5655
* @internal This method is public to be usable as callback. It should not
5756
* be used in user code.
5857
*/
59-
public static function createChoiceLabel($choice)
58+
public static function createChoiceLabel($choice): string
6059
{
6160
return (string) $choice;
6261
}
@@ -73,12 +72,10 @@ public static function createChoiceLabel($choice)
7372
* @param string $value The choice value. Corresponds to the object's
7473
* ID here.
7574
*
76-
* @return string The field name
77-
*
7875
* @internal This method is public to be usable as callback. It should not
7976
* be used in user code.
8077
*/
81-
public static function createChoiceName($choice, $key, $value)
78+
public static function createChoiceName($choice, $key, $value): string
8279
{
8380
return str_replace('-', '_', (string) $value);
8481
}
@@ -88,17 +85,15 @@ public static function createChoiceName($choice, $key, $value)
8885
* For instance in ORM two query builders with an equal SQL string and
8986
* equal parameters are considered to be equal.
9087
*
91-
* @param object $queryBuilder
92-
*
93-
* @return array|false Array with important QueryBuilder parts or false if
94-
* they can't be determined
88+
* @return array|null Array with important QueryBuilder parts or null if
89+
* they can't be determined
9590
*
9691
* @internal This method is public to be usable as callback. It should not
9792
* be used in user code.
9893
*/
99-
public function getQueryBuilderPartsForCachingHash($queryBuilder)
94+
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
10095
{
101-
return false;
96+
return null;
10297
}
10398

10499
public function __construct(ManagerRegistry $registry)
@@ -127,7 +122,7 @@ public function configureOptions(OptionsResolver $resolver)
127122
// If there is no QueryBuilder we can safely cache DoctrineChoiceLoader,
128123
// also if concrete Type can return important QueryBuilder parts to generate
129124
// hash key we go for it as well
130-
if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) {
125+
if (!$options['query_builder'] || null !== $qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder'])) {
131126
$hash = CachingFactoryDecorator::generateHash([
132127
$options['em'],
133128
$options['class'],

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ public function getBlockPrefix()
6868
* We consider two query builders with an equal SQL string and
6969
* equal parameters to be equal.
7070
*
71-
* @param QueryBuilder $queryBuilder
72-
*
73-
* @return array
74-
*
7571
* @internal This method is public to be usable as callback. It should not
7672
* be used in user code.
7773
*/
78-
public function getQueryBuilderPartsForCachingHash($queryBuilder)
74+
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
7975
{
8076
return [
8177
$queryBuilder->getQuery()->getSQL(),

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ public function setFluentSafe(bool $fluentSafe)
2929

3030
/**
3131
* {@inheritdoc}
32-
*
33-
* @return void
3432
*/
35-
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator)
33+
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator): void
3634
{
3735
parent::generate($originalClass, $classGenerator);
3836

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public function __construct(string $salt = '')
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
public function isProxyCandidate(Definition $definition)
43+
public function isProxyCandidate(Definition $definition): bool
4444
{
4545
return ($definition->isLazy() || $definition->hasTag('proxy')) && $this->proxyGenerator->getProxifiedClass($definition);
4646
}
4747

4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null)
51+
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string
5252
{
5353
$instantiation = 'return';
5454

@@ -82,7 +82,7 @@ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode =
8282
/**
8383
* {@inheritdoc}
8484
*/
85-
public function getProxyCode(Definition $definition)
85+
public function getProxyCode(Definition $definition): string
8686
{
8787
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
8888

src/Symfony/Bridge/Twig/Extension/RoutingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getUrl($name, $parameters = [], $schemeRelative = false)
9393
*
9494
* @final
9595
*/
96-
public function isUrlGenerationSafe(Node $argsNode)
96+
public function isUrlGenerationSafe(Node $argsNode): array
9797
{
9898
// support named arguments
9999
$paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : (

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ public function warmUp($cacheDir)
5757
*
5858
* @return bool always true
5959
*/
60-
public function isOptional()
60+
public function isOptional(): bool
6161
{
6262
return true;
6363
}
6464

6565
/**
6666
* {@inheritdoc}
6767
*/
68-
public static function getSubscribedServices()
68+
public static function getSubscribedServices(): array
6969
{
7070
return [
7171
'router' => RouterInterface::class,

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,9 @@ protected function validateInput(InputInterface $input)
213213
/**
214214
* Loads the ContainerBuilder from the cache.
215215
*
216-
* @return ContainerBuilder
217-
*
218216
* @throws \LogicException
219217
*/
220-
protected function getContainerBuilder()
218+
protected function getContainerBuilder(): ContainerBuilder
221219
{
222220
if ($this->containerBuilder) {
223221
return $this->containerBuilder;

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,12 @@ public function describe(OutputInterface $output, $object, array $options = [])
8484
}
8585
}
8686

87-
/**
88-
* Returns the output.
89-
*
90-
* @return OutputInterface The output
91-
*/
92-
protected function getOutput()
87+
protected function getOutput(): OutputInterface
9388
{
9489
return $this->output;
9590
}
9691

97-
/**
98-
* Writes content to output.
99-
*
100-
* @param string $content
101-
* @param bool $decorated
102-
*/
103-
protected function write($content, $decorated = false)
92+
protected function write(string $content, bool $decorated = false)
10493
{
10594
$this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
10695
}
@@ -182,10 +171,8 @@ abstract protected function describeCallable($callable, array $options = []);
182171
* Formats a value as string.
183172
*
184173
* @param mixed $value
185-
*
186-
* @return string
187174
*/
188-
protected function formatValue($value)
175+
protected function formatValue($value): string
189176
{
190177
if (\is_object($value)) {
191178
return sprintf('object(%s)', \get_class($value));
@@ -202,10 +189,8 @@ protected function formatValue($value)
202189
* Formats a parameter.
203190
*
204191
* @param mixed $value
205-
*
206-
* @return string
207192
*/
208-
protected function formatParameter($value)
193+
protected function formatParameter($value): string
209194
{
210195
if (\is_bool($value) || \is_array($value) || (null === $value)) {
211196
$jsonString = json_encode($value);
@@ -246,10 +231,8 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, $serviceI
246231

247232
/**
248233
* @param bool $showHidden
249-
*
250-
* @return array
251234
*/
252-
protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden)
235+
protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden): array
253236
{
254237
$definitions = [];
255238
$tags = $builder->findTags();

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,7 @@ private function writeData(array $data, array $options)
198198
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
199199
}
200200

201-
/**
202-
* @return array
203-
*/
204-
protected function getRouteData(Route $route)
201+
protected function getRouteData(Route $route): array
205202
{
206203
$data = [
207204
'path' => $route->getPath(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class RedirectableCompiledUrlMatcher extends CompiledUrlMatcher implements Redir
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
public function redirect($path, $route, $scheme = null)
27+
public function redirect($path, $route, $scheme = null): array
2828
{
2929
return [
3030
'_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction',

src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Test;
1313

1414
use Symfony\Component\DependencyInjection\Container;
15+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
1516
use Symfony\Component\HttpKernel\KernelInterface;
1617

1718
/**
@@ -41,15 +42,15 @@ public function compile()
4142
/**
4243
* {@inheritdoc}
4344
*/
44-
public function isCompiled()
45+
public function isCompiled(): bool
4546
{
4647
return $this->getPublicContainer()->isCompiled();
4748
}
4849

4950
/**
5051
* {@inheritdoc}
5152
*/
52-
public function getParameterBag()
53+
public function getParameterBag(): ParameterBagInterface
5354
{
5455
return $this->getPublicContainer()->getParameterBag();
5556
}
@@ -65,7 +66,7 @@ public function getParameter($name)
6566
/**
6667
* {@inheritdoc}
6768
*/
68-
public function hasParameter($name)
69+
public function hasParameter($name): bool
6970
{
7071
return $this->getPublicContainer()->hasParameter($name);
7172
}
@@ -89,7 +90,7 @@ public function set($id, $service)
8990
/**
9091
* {@inheritdoc}
9192
*/
92-
public function has($id)
93+
public function has($id): bool
9394
{
9495
return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id);
9596
}
@@ -105,7 +106,7 @@ public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERE
105106
/**
106107
* {@inheritdoc}
107108
*/
108-
public function initialized($id)
109+
public function initialized($id): bool
109110
{
110111
return $this->getPublicContainer()->initialized($id);
111112
}
@@ -121,15 +122,15 @@ public function reset()
121122
/**
122123
* {@inheritdoc}
123124
*/
124-
public function getServiceIds()
125+
public function getServiceIds(): array
125126
{
126127
return $this->getPublicContainer()->getServiceIds();
127128
}
128129

129130
/**
130131
* {@inheritdoc}
131132
*/
132-
public function getRemovedIds()
133+
public function getRemovedIds(): array
133134
{
134135
return $this->getPublicContainer()->getRemovedIds();
135136
}

src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function onVoterVote(VoteEvent $event)
3939
$this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote());
4040
}
4141

42-
public static function getSubscribedEvents()
42+
public static function getSubscribedEvents(): array
4343
{
4444
return ['debug.security.authorization.vote' => 'onVoterVote'];
4545
}

src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ public function __construct(NonceGenerator $nonceGenerator)
3838
* - The request - In case HTML content is fetched via AJAX and inserted in DOM, it must use the same nonce as origin
3939
* - The response - A call to getNonces() has already been done previously. Same nonce are returned
4040
* - They are otherwise randomly generated
41-
*
42-
* @return array
4341
*/
44-
public function getNonces(Request $request, Response $response)
42+
public function getNonces(Request $request, Response $response): array
4543
{
4644
if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-S F438 ymfonyProfiler-Style-Nonce')) {
4745
return [
@@ -83,7 +81,7 @@ public function disableCsp()
8381
*
8482
* @return array Nonces used by the bundle in Content-Security-Policy header
8583
*/
86-
public function updateResponseHeaders(Request $request, Response $response)
84+
public function updateResponseHeaders(Request $request, Response $response): array
8785
{
8886
if ($this->cspDisabled) {
8987
$this->removeCspHeaders($response);

src/Symfony/Component/Cache/Traits/PdoTrait.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,7 @@ private function getConnection()
403403
return $this->conn;
404404
}
405405

406-
/**
407-
* @return string
408-
*/
409-
private function getServerVersion()
406+
private function getServerVersion(): string
410407
{
411408
if (null === $this->serverVersion) {
412409
$conn = $this->conn instanceof \PDO ? $this->conn : $this->conn->getWrappedConnection();

src/Symfony/Component/Console/Descriptor/ApplicationDescription.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ public function __construct(Application $application, string $namespace = null,
5050
$this->showHidden = $showHidden;
5151
}
5252

53-
/**
54-
* @return array
55-
*/
56-
public function getNamespaces()
53+
public function getNamespaces(): array
5754
{
5855
if (null === $this->namespaces) {
5956
$this->inspectApplication();
@@ -65,7 +62,7 @@ public function getNamespaces()
6562
/**
6663
* @return Command[]
6764
*/
68-
public function getCommands()
65+
public function getCommands(): array
6966
{
7067
if (null === $this->commands) {
7168
$this->inspectApplication();
@@ -75,13 +72,9 @@ public function getCommands()
7572
}
7673

7774
/**
78-
* @param string $name
79-
*
80-
* @return Command
81-
*
8275
* @throws CommandNotFoundException
8376
*/
84-
public function getCommand($name)
77+
public function getCommand(string $name): Command
8578
{
8679
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
8780
throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));

0 commit comments

Comments
 (0)
0