Skip to content

Commit 2a1647a

Browse files
committed
minor #33198 Add types to private and final methods (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- Add types to private and final methods | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32179 | License | MIT | Doc PR | N/A Backports from #33154. Commits ------- 1b88067 Add types to private and final methods.
2 parents 3596948 + 1b88067 commit 2a1647a

File tree

16 files changed

+34
-27
lines changed

16 files changed

+34
-27
lines changed

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function getName()
119119
return 'db';
120120
}
121121

122-
private function sanitizeQueries(string $connectionName, array $queries)
122+
private function sanitizeQueries(string $connectionName, array $queries): array
123123
{
124124
foreach ($queries as $i => $query) {
125125
$queries[$i] = $this->sanitizeQuery($connectionName, $query);
@@ -128,7 +128,7 @@ private function sanitizeQueries(string $connectionName, array $queries)
128128
return $queries;
129129
}
130130

131-
private function sanitizeQuery(string $connectionName, $query)
131+
private function sanitizeQuery(string $connectionName, array $query): array
132132
{
133133
$query['explainable'] = true;
134134
if (null === $query['params']) {

src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private function replacePlaceHolder(array $record)
180180
return $record;
181181
}
182182

183-
private function dumpData($data, $colors = null)
183+
private function dumpData($data, bool $colors = null): string
184184
{
185185
if (null === $this->dumper) {
186186
return '';

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ protected function findFiles($filename)
118118
throw new RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
119119
}
120120

121-
private function validate(string $template, $file)
121+
private function validate(string $template, string $file): array
122122
{
123123
$realLoader = $this->twig->getLoader();
124124
try {
125-
$temporaryLoader = new ArrayLoader([(string) $file => $template]);
125+
$temporaryLoader = new ArrayLoader([$file => $template]);
126126
$this->twig->setLoader($temporaryLoader);
127-
$nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file)));
127+
$nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, $file)));
128128
$this->twig->compile($nodeTree);
129129
$this->twig->setLoader($realLoader);
130130
} catch (Error $e) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array
7272
/**
7373
* @internal
7474
*/
75-
final protected function ignoreAutoloadException($class, \Exception $exception)
75+
final protected function ignoreAutoloadException(string $class, \Exception $exception): void
7676
{
7777
try {
7878
ClassExistenceResource::throwOnRequiredClass($class, $exception);

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
10691069
/**
10701070
* Returns a definition for an asset package.
10711071
*/
1072-
private function createPackageDefinition(?string $basePath, array $baseUrls, Reference $version)
1072+
private function createPackageDefinition(?string $basePath, array $baseUrls, Reference $version): Definition
10731073
{
10741074
if ($basePath && $baseUrls) {
10751075
throw new \LogicException('An asset package cannot have base URLs and base paths.');
@@ -1085,7 +1085,7 @@ private function createPackageDefinition(?string $basePath, array $baseUrls, Ref
10851085
return $package;
10861086
}
10871087

1088-
private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPath, string $name)
1088+
private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPath, string $name): Reference
10891089
{
10901090
// Configuration prevents $version and $jsonManifestPath from being set
10911091
if (null !== $version) {

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public static function fromString($cookie, $url = null)
199199
);
200200
}
201201

202-
private static function parseDate($dateValue)
202+
private static function parseDate(string $dateValue): ?string
203203
{
204204
// trim single quotes around date if present
205205
if (($length = \strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) {
@@ -216,6 +216,8 @@ private static function parseDate($dateValue)
216216
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
217217
return $date->format('U');
218218
}
219+
220+
return null;
219221
}
220222

221223
/**

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,10 @@ private function getSchemeAndHierarchy(string $filename): array
740740
return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
741741
}
742742

743-
private static function box($func)
743+
/**
744+
* @return mixed
745+
*/
746+
private static function box(callable $func)
744747
{
745748
self::$lastError = null;
746749
set_error_handler(__CLASS__.'::handleError');

src/Symfony/Component/Form/Extension/Core/Type/FileType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ private function factorizeSizes(int $size, int $limit)
246246
/**
247247
* This method should be kept in sync with Symfony\Component\Validator\Constraints\FileValidator::moreDecimalsThan().
248248
*/
249-
private static function moreDecimalsThan($double, $numberOfDecimals)
249+
private static function moreDecimalsThan(string $double, int $numberOfDecimals): bool
250250
{
251-
return \strlen((string) $double) > \strlen(round($double, $numberOfDecimals));
251+
return \strlen($double) > \strlen(round($double, $numberOfDecimals));
252252
}
253253
}

src/Symfony/Component/Form/FormFactoryBuilder.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface
4747
*/
4848
private $typeGuessers = [];
4949

50-
/**
51-
* @param bool $forceCoreExtension
52-
*/
53-
public function __construct($forceCoreExtension = false)
50+
public function __construct(bool $forceCoreExtension = false)
5451
{
5552
$this->forceCoreExtension = $forceCoreExtension;
5653
}

src/Symfony/Component/Messenger/MessageBus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(iterable $middlewareHandlers = [])
3939
private $middlewareHandlers;
4040
private $cachedIterator;
4141

42-
public function __construct($middlewareHandlers)
42+
public function __construct(\Traversable $middlewareHandlers)
4343
{
4444
$this->middlewareHandlers = $middlewareHandlers;
4545
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy