8000 Add types to constructors and private/final/internal methods (Batch II) · symfony/symfony@9378eb4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9378eb4

Browse files
derrabusTobion
authored andcommitted
Add types to constructors and private/final/internal methods (Batch II)
1 parent 2b71c6f commit 9378eb4

File tree

79 files changed

+127
-129
lines changed

Some content is hidden

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

79 files changed

+127
-129
lines changed

src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function initializeCatalogue($locale)
126126
/**
127127
* @internal
128128
*/
129-
protected function doLoadCatalogue($locale): void
129+
protected function doLoadCatalogue(string $locale): void
130130
{
131131
parent::doLoadCatalogue($locale);
132132

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"symfony/security-http": "^3.4|^4.0|^5.0",
5151
"symfony/serializer": "^4.3|^5.0",
5252
"symfony/stopwatch": "^3.4|^4.0|^5.0",
53-
"symfony/translation": "^4.3|^5.0",
53+
"symfony/translation": "^4.4|^5.0",
5454
"symfony/templating": "^3.4|^4.0|^5.0",
5555
"symfony/twig-bundle": "^4.4|^5.0",
5656
"symfony/validator": "^4.4|^5.0",
@@ -80,7 +80,7 @@
8080
"symfony/property-info": "<3.4",
8181
"symfony/serializer": "<4.2",
8282
"symfony/stopwatch": "<3.4",
83-
"symfony/translation": "<4.3",
83+
"symfony/translation": "<4.4",
8484
"symfony/twig-bridge": "<4.1.1",
8585
"symfony/twig-bundle": "<4.4",
8686
"symfony/validator": "<4.4",

src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function getValuesForChoices(array $choices)
182182
*
183183
* @internal
184184
*/
185-
protected function flatten(array $choices, $value, &$choicesByValues, &$keysByValues, &$structuredValues)
185+
protected function flatten(array $choices, callable $value, ?array &$choicesByValues, ?array &$keysByValues, ?array &$structuredValues)
186186
{
187187
if (null === $choicesByValues) {
188188
$choicesByValues = [];

src/Symfony/Component/Form/Command/DebugCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
154154
$helper->describe($io, $object, $options);
155155
}
156156

157-
private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, string $shortClassName)
157+
private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, string $shortClassName): string
158158
{
159159
$classes = [];
160160
sort($this->namespaces);
@@ -195,7 +195,7 @@ private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, strin
195195
return $io->choice(sprintf("The type \"%s\" is ambiguous.\n\nSelect one of the following form types to display its information:", $shortClassName), $classes, $classes[0]);
196196
}
197197

198-
private function getCoreTypes()
198+
private function getCoreTypes(): array
199199
{
200200
$coreExtension = new CoreExtension();
201201
$loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes');
@@ -223,7 +223,7 @@ private function filterTypesByDeprecated(array $types): array
223223
return $typesWithDeprecatedOptions;
224224
}
225225

226-
private function findAlternatives(string $name, array $collection)
226+
private function findAlternatives(string $name, array $collection): array
227227
{
228228
$alternatives = [];
229229
foreach ($collection as $item) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected function filterOptionsByDeprecated(ResolvedFormTypeInterface $type)
167167
$this->extensionOptions = $filterByDeprecated($this->extensionOptions);
168168
}
169169

170-
private function getParentOptionsResolver(ResolvedFormTypeInterface $type)
170+
private function getParentOptionsResolver(ResolvedFormTypeInterface $type): OptionsResolver
171171
{
172172
$this->parents[$class = \get_class($type->getInnerType())] = [];
173173

src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private function buildTableRows(array $headers, array $options): array
155155
return $tableRows;
156156
}
157157

158-
private function normalizeAndSortOptionsColumns(array $options)
158+
private function normalizeAndSortOptionsColumns(array $options): array
159159
{
160160
foreach ($options as $group => $opts) {
161161
$sorted = false;

src/Symfony/Component/Form/DependencyInjection/FormPass.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\DependencyInjection;
1313

14+
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1415
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1516
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1617
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
@@ -60,7 +61,7 @@ public function process(ContainerBuilder $container)
6061
$definition->replaceArgument(2, $this->processFormTypeGuessers($container));
6162
}
6263

63-
private function processFormTypes(ContainerBuilder $container)
64+
private function processFormTypes(ContainerBuilder $container): Reference
6465
{
6566
// Get service locator argument
6667
$servicesMap = [];
@@ -83,7 +84,7 @@ private function processFormTypes(ContainerBuilder $container)
8384
return ServiceLocatorTagPass::register($container, $servicesMap);
8485
}
8586

86-
private function processFormTypeExtensions(ContainerBuilder $container)
87+
private function processFormTypeExtensions(ContainerBuilder $container): array
8788
{
8889
$typeExtensions = [];
8990
$typeExtensionsClasses = [];
@@ -130,7 +131,7 @@ private function processFormTypeExtensions(ContainerBuilder $container)
130131
return $typeExtensions;
131132
}
132133

133-
private function processFormTypeGuessers(ContainerBuilder $container)
134+
private function processFormTypeGuessers(ContainerBuilder $container): ArgumentInterface
134135
{
135136
$guessers = [];
136137
$guessersClasses = [];

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function reverseTransform($value)
9494
return $dateInterval;
9595
}
9696

97-
private function isISO8601(string $string)
97+
private function isISO8601(string $string): bool
9898
{
9999
return preg_match('/^P(?=\w*(?:\d|%\w))(?:\d+Y|%[yY]Y)?(?:\d+M|%[mM]M)?(?:(?:\d+D|%[dD]D)|(?:\d+W|%[wW]W))?(?:T(?:\d+H|[hH]H)?(?:\d+M|[iI]M)?(?:\d+S|[sS]S)?)?$/', $string);
100100
}

src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private static function getValidationGroups(FormInterface $form)
188188
*
189189
* @param string|GroupSequence|(string|GroupSequence)[]|callable $groups The validation groups
190190
*
191-
* @return (string|GroupSequence)[] The validation groups
191+
* @return GroupSequence|(string|GroupSequence)[] The validation groups
192192
*/
193193
private static function resolveValidationGroups($groups, FormInterface $form)
194194
{

src/Symfony/Component/Form/FormRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function humanize($text)
290290
/**
291291
* @internal
292292
*/
293-
public function encodeCurrency(Environment $environment, $text, $widget = '')
293+
public function encodeCurrency(Environment $environment, string $text, string $widget = ''): string
294294
{
295295
if ('UTF-8' === $charset = $environment->getCharset()) {
296296
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');

src/Symfony/Component/HttpClient/Tests/DataCollector/HttpClientDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function testItIsEmptyAfterReset()
164164
$this->assertEquals(0, $sut->getRequestCount());
165165
}
166166

167-
private function httpClientThatHasTracedRequests($tracedRequests)
167+
private function httpClientThatHasTracedRequests($tracedRequests): TraceableHttpClient
168168
{
169169
$httpClient = new TraceableHttpClient(new NativeHttpClient());
170170

src/Symfony/Component/HttpClient/Tests/Exception/HttpExceptionTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class HttpExceptionTraitTest extends TestCase
2222
{
23-
public function provideParseError()
23+
public function provideParseError(): iterable
2424
{
2525
yield ['application/ld+json', '{"hydra:title": "An error occurred", "hydra:description": "Some details"}'];
2626
yield ['application/problem+json', '{"title": "An error occurred", "detail": "Some details"}'];

src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HttpClientTraitTest extends TestCase
2424
/**
2525
* @dataProvider providePrepareRequestUrl
2626
*/
27-
public function testPrepareRequestUrl($expected, $url, $query = [])
27+
public function testPrepareRequestUrl(string $expected, string $url, array $query = [])
2828
{
2929
$defaults = [
3030
'base_uri' => 'http://example.com?c=c',
@@ -36,7 +36,7 @@ public function testPrepareRequestUrl($expected, $url, $query = [])
3636
$this->assertSame($expected, implode('', $url));
3737
}
3838

39-
public function providePrepareRequestUrl()
39+
public function providePrepareRequestUrl(): iterable
4040
{
4141
yield ['http://example.com/', 'http://example.com/'];
4242
yield ['http://example.com/?a=1&b=b', '.'];
@@ -48,15 +48,15 @@ public function providePrepareRequestUrl()
4848
/**
4949
* @dataProvider provideResolveUrl
5050
*/
51-
public function testResolveUrl($base, $url, $expected)
51+
public function testResolveUrl(string $base, string $url, string $expected)
5252
{
5353
$this->assertSame($expected, implode('', self::resolveUrl(self::parseUrl($url), self::parseUrl($base))));
5454
}
5555

5656
/**
5757
* From https://github.com/guzzle/psr7/blob/master/tests/UriResoverTest.php.
5858
*/
59-
public function provideResolveUrl()
59+
public function provideResolveUrl(): array
6060
{
6161
return [
6262
[self::RFC3986_BASE, 'http:h', 'http:h'],
@@ -123,14 +123,14 @@ public function provideResolveUrl()
123123
/**
124124
* @dataProvider provideParseUrl
125125
*/
126-
public function testParseUrl($expected, $url, $query = [])
126+
public function testParseUrl(array $expected, string $url, array $query = [])
127127
{
128128
$expected = array_combine(['scheme', 'authority', 'path', 'query', 'fragment'], $expected);
129129

130130
$this->assertSame($expected, self::parseUrl($url, $query));
131131
}
132132

133-
public function provideParseUrl()
133+
public function provideParseUrl(): iterable
134134
{
135135
yield [['http:', '//example.com', null, null, null], 'http://Example.coM:80'];
136136
yield [['https:', '//xn--dj-kia8a.example.com:8000', '/', null, null], 'https://DÉjà.Example.com:8000/'];

src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
class HttpOptionsTest extends TestCase
2121
{
22-
public function provideSetAuthBasic()
22+
public function provideSetAuthBasic(): iterable
2323
{
2424
yield ['user:password', 'user', 'password'];
2525
yield ['user:password', 'user:password'];

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected function instantiateController($class)
151151
return new $class();
152152
}
153153

154-
private function getControllerError($callable)
154+
private function getControllerError($callable): string
155155
{
156156
if (\is_string($callable)) {
157157
if (false !== strpos($callable, '::')) {
@@ -213,7 +213,7 @@ private function getControllerError($callable)
213213
return $message;
214214
}
215215

216-
private function getClassMethodsWithoutMagicMethods($classOrObject)
216+
private function getClassMethodsWithoutMagicMethods($classOrObject): array
217217
{
218218
$methods = get_class_methods($classOrObject);
219219

src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function getName()
118118
return 'logger';
119119
}
120120

121-
private function getContainerDeprecationLogs()
121+
private function getContainerDeprecationLogs(): array
122122
{
123123
if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Deprecations.log')) {
124124
return [];
@@ -212,7 +212,7 @@ private function sanitizeLogs(array $logs)
212212
return array_values($sanitizedLogs);
213213
}
214214

215-
private function isSilencedOrDeprecationErrorLog(array $log)
215+
private function isSilencedOrDeprecationErrorLog(array $log): bool
216216
{
217217
if (!isset($log['context']['exception'])) {
218218
return false;
@@ -231,7 +231,7 @@ private function isSilencedOrDeprecationErrorLog(array $log)
231231
return false;
232232
}
233233

234-
private function computeErrorsCount(array $containerDeprecationLogs)
234+
private function computeErrorsCount(array $containerDeprecationLogs): array
235235
{
236236
$silencedLogs = [];
237237
$count = [

src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getName()
8989
return 'memory';
9090
}
9191

92-
private function convertToBytes(string $memoryLimit)
92+
private function convertToBytes(string $memoryLimit): int
9393
{
9494
if ('-1' === $memoryLimit) {
9595
return -1;

src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function expandClasses(array $patterns, array $classes): array
8282
return array_unique($expanded);
8383
}
8484

85-
private function getClassesInComposerClassMaps()
85+
private function getClassesInComposerClassMaps(): array
8686
{
8787
$classes = [];
8888

@@ -103,7 +103,7 @@ private function getClassesInComposerClassMaps()
103103
return array_keys($classes);
104104
}
105105

106-
private function patternsToRegexps(array $patterns)
106+
private function patternsToRegexps(array $patterns): array
107107
{
108108
$regexps = [];
109109

@@ -125,7 +125,7 @@ private function patternsToRegexps(array $patterns)
125125
return $regexps;
126126
}
127127

128-
private function matchAnyRegexps(string $class, array $regexps)
128+
private function matchAnyRegexps(string $class, array $regexps): bool
129129
{
130130
$blacklisted = false !== strpos($class, 'Test');
131131

src/Symfony/Component/HttpKernel/EventListener/RouterListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public static function getSubscribedEvents()
161161
];
162162
}
163163

164-
private function createWelcomeResponse()
164+
private function createWelcomeResponse(): Response
165165
{
166166
$version = Kernel::VERSION;
167167
$projectDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR;

src/Symfony/Component/HttpKernel/UriSigner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public function check($uri)
8282
return $this->computeHash($this->buildUrl($url, $params)) === $hash;
8383
}
8484

85-
private function computeHash(string $uri)
85+
private function computeHash(string $uri): string
8686
{
8787
return base64_encode(hash_hmac('sha256', $uri, $this->secret, true));
8888
}
8989

90-
private function buildUrl(array $url, array $params = [])
90+
private function buildUrl(array $url, array $params = []): string
9191
{
9292
ksort($params, SORT_STRING);
9393
$url['query'] = http_build_query($params, '', '&');

src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private function generateAlpha3Codes(array $languageCodes, ArrayAccessibleResour
205205
return array_keys($alpha3Codes);
206206
}
207207

208-
private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $metadataBundle)
208+
private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $metadataBundle): array
209209
{
210210
$aliases = iterator_to_array($metadataBundle['alias']['language']);
211211
$alpha2ToAlpha3 = [];

src/Symfony/Component/Intl/Locale.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function getDefaultFallback(): ?string
6565
* @return string|null The ICU locale code of the fallback locale, or null
6666
* if no fallback exists
6767
*/
68-
public static function getFallback($locale): ?string
68+
public static function getFallback(string $locale): ?string
6969
{
7070
if (\function_exists('locale_parse')) {
7171
$localeSubTags = locale_parse($locale);

0 commit comments

Comments
 (0)
0