8000 Added more parameter type declarations. · symfony/symfony@34eda04 · GitHub
[go: up one dir, main page]

Skip to content

Commit 34eda04

Browse files
committed
Added more parameter type declarations.
1 parent f07faaa commit 34eda04

File tree

34 files changed

+51
-96
lines changed

34 files changed

+51
-96
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function format(array $record)
133133
/**
134134
* @internal
135135
*/
136-
public function echoLine($line, $depth, $indentPad)
136+
public function echoLine(string $line, int $depth, string $indentPad)
137137
{
138138
if (-1 !== $depth) {
139139
fwrite($this->outputBuffer, $line);
@@ -143,7 +143,7 @@ public function echoLine($line, $depth, $indentPad)
143143
/**
144144
* @internal
145145
*/
146-
public function castObject($v, array $a, Stub $s, $isNested)
146+
public function castObject($v, array $a, Stub $s, bool $isNested)
147147
{
148148
if ($this->options['multiline']) {
149149
return $a;

src/Symfony/Component/BrowserKit/CookieJar.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ public function clear()
106106
* Updates the cookie jar from a response Set-Cookie headers.
107107
*
108108
* @param string[] $setCookies Set-Cookie headers from an HTTP response
109-
* @param string $uri The base URL
110109
*/
111-
public function updateFromSetCookie(array $setCookies, $uri = null)
110+
public function updateFromSetCookie(array $setCookies, string $uri = null)
112111
{
113112
$cookies = [];
114113

@@ -133,8 +132,6 @@ public function updateFromSetCookie(array $setCookies, $uri = null)
133132

134133
/**
135134
* Updates the cookie jar from a Response object.
136-
*
137-
* @param string $uri The base URL
138135
*/
139136
public function updateFromResponse(Response $response, string $uri = null)
140137
{

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,9 @@ protected function normalizeValue($value)
332332
/**
333333
* Remaps multiple singular values to a single plural value.
334334
*
335-
* @param array $value The source values
336-
*
337335
* @return array The remapped values
338336
*/
339-
protected function remapXml($value)
337+
protected function remapXml(array $value)
340338
{
341339
foreach ($this->xmlRemappings as list($singular, $plural)) {
342340
if (!isset($value[$singular])) {

src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function dump(ConfigurationInterface $configuration, string $namespace =
3131
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
3232
}
3333

34-
public function dumpNode(NodeInterface $node, $namespace = null)
34+
public function dumpNode(NodeInterface $node, string $namespace = null)
3535
{
3636
$this->reference = '';
3737
$this->writeNode($node, 0, true, $namespace);

src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function dump(ConfigurationInterface $configuration)
3333
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
3434
}
3535

36-
public function dumpAtPath(ConfigurationInterface $configuration, $path)
36+
public function dumpAtPath(ConfigurationInterface $configuration, string $path)
3737
{
3838
$rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree();
3939

src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public function getPath()
3434

3535
/**
3636
* Adds extra information that is suffixed to the original exception message.
37-
*
38-
* @param string $hint
3937
*/
40-
public function addHint($hint)
38+
public function addHint(string $hint)
4139
{
4240
if (!$this->containsHints) {
4341
$this->message .= "\nHint: ".$hint;

src/Symfony/Component/Config/FileLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct($paths = [])
3535
*/
3636
public function locate(string $name, string $currentPath = null, bool $first = true)
3737
{
38-
if ('' == $name) {
38+
if ('' === $name) {
3939
throw new \InvalidArgumentException('An empty file name is not valid to be located.');
4040
}
4141

src/Symfony/Component/Config/Resource/ClassExistenceResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function __sleep(): array
128128
*
129129
* @internal
130130
*/
131-
public static function throwOnRequiredClass($class, \Exception $previous = null)
131+
public static function throwOnRequiredClass(string $class, \Exception $previous = null)
132132
{
133133
// If the passed class is the resource being checked, we shouldn't throw.
134134
if (null === $previous && self::$autoloadedClass === $class) {

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public static function phpize($value)
247247
}
248248
}
249249

250-
protected static function getXmlErrors($internalErrors)
250+
protected static function getXmlErrors(bool $internalErrors)
251251
{
252252
$errors = [];
253253
foreach (libxml_get_errors() as $error) {

src/Symfony/Component/Console/Question/ChoiceQuestion.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ public function getChoices()
5858
*
5959
* When multiselect is set to true, multiple choices can be answered.
6060
*
61-
* @param bool $multiselect
62-
*
6361
* @return $this
6462
*/
65-
public function setMultiselect($multiselect)
63+
public function setMultiselect(bool $multiselect)
6664
{
6765
$this->multiselect = $multiselect;
6866
$this->setValidator($this->getDefaultValidator());
@@ -93,11 +91,9 @@ public function getPrompt()
9391
/**
9492
* Sets the prompt for choices.
9593
*
96-
* @param string $prompt
97-
*
9894
* @return $thi 10000 s
9995
*/
100-
public function setPrompt($prompt)
96+
public function setPrompt(string $prompt)
10197
{
10298
$this->prompt = $prompt;
10399

@@ -109,11 +105,9 @@ public function setPrompt($prompt)
109105
*
110106
* The error message has a string placeholder (%s) for the invalid value.
111107
*
112-
* @param string $errorMessage
113-
*
114108
* @return $this
115109
*/
116-
public function setErrorMessage($errorMessage)
110+
public function setErrorMessage(string $errorMessage)
117111
{
118112
$this->errorMessage = $errorMessage;
119113
$this->setValidator($this->getDefaultValidator());

src/Symfony/Component/Console/Question/Question.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,11 @@ public function getAutocompleterValues()
130130
/**
131131
* Sets values for the autocompleter.
132132
*
133-
* @param iterable|null $values
134-
*
135133
* @return $this
136134
*
137-
* @throws InvalidArgumentException
138135
* @throws LogicException
139136
*/
140-
public function setAutocompleterValues($values)
137+
public function setAutocompleterValues(?iterable $values)
141138
{
142139
if (\is_array($values)) {
143140
$values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
@@ -150,10 +147,8 @@ public function setAutocompleterValues($values)
150147
$callback = static function () use ($values, &$valueCache) {
151148
return $valueCache ?? $valueCache = iterator_to_array($values, false);
152149
};
153-
} elseif (null === $values) {
154-
$callback = null;
155150
} else {
156-
throw new InvalidArgumentException('Autocompleter values can be either an array, "null" or a "Traversable" object.');
151+
$callback = null;
157152
}
158153

159154
return $this->setAutocompleterCallback($callback);
@@ -212,13 +207,11 @@ public function getValidator()
212207
*
213208
* Null means an unlimited number of attempts.
214209
*
215-
* @param int|null $attempts
216-
*
217210
* @return $this
218211
*
219212
* @throws InvalidArgumentException in case the number of attempts is invalid
220213
*/
221-
public function setMaxAttempts($attempts)
214+
public function setMaxAttempts(?int $attempts)
222215
{
223216
if (null !== $attempts && $attempts < 1) {
224217
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
@@ -267,7 +260,7 @@ public function getNormalizer()
267260
return $this->normalizer;
268261
}
269262

270-
protected function isAssoc($array)
263+
protected function isAssoc(array $array)
271264
{
272265
return (bool) \count(array_filter(array_keys($array), 'is_string'));
273266
}

src/Symfony/Component/Console/Tests/Question/QuestionTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Tests\Question;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Console\Exception\InvalidArgumentException;
1615
use Symfony\Component\Console\Question\Question;
1716

1817
class QuestionTest extends TestCase
@@ -150,10 +149,7 @@ public function providerSetAutocompleterValuesInvalid()
150149
*/
151150
public function testSetAutocompleterValuesInvalid($values)
152151
{
153-
self::expectException(InvalidArgumentException::class);
154-
self::expectExceptionMessage(
155-
'Autocompleter values can be either an array, "null" or a "Traversable" object.'
156-
);
152+
self::expectException(\TypeError::class);
157153

158154
$this->question->setAutocompleterValues($values);
159155
}
@@ -271,7 +267,7 @@ public function testGetSetMaxAttempts($attempts)
271267

272268
public function providerSetMaxAttemptsInvalid()
273269
{
274-
return [['Potato'], [0], [-1]];
270+
return [[0], [-1]];
275271
}
276272

277273
/**

src/Symfony/Component/EventDispatcher/GenericEvent.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ public function getSubject()
5050
/**
5151
* Get argument by key.
5252
*
53-
* @param string $key Key
54-
*
5553
* @return mixed Contents of array key
5654
*
5755
* @throws \InvalidArgumentException if key is not found
5856
*/
59-
public function getArgument($key)
57+
public function getArgument(string $key)
6058
{
6159
if ($this->hasArgument($key)) {
6260
return $this->arguments[$key];
@@ -68,12 +66,11 @@ public function getArgument($key)
6866
/**
6967
* Add argument to event.
7068
*
71-
* @param string $key Argument name
72-
* @param mixed $value Value
69+
* @param mixed $value Value
7370
*< 741A /div>
7471
* @return $this
7572
*/
76-
public function setArgument($key, $value)
73+
public function setArgument(string $key, $value)
7774
{
7875
$this->arguments[$key] = $value;
7976

@@ -93,8 +90,6 @@ public function getArguments()
9390
/**
9491
* Set args property.
9592
*
96-
* @param array $args Arguments
97-
*
9893
* @return $this
9994
*/
10095
public function setArguments(array $args = [])
@@ -107,11 +102,9 @@ public function setArguments(array $args = [])
107102
/**
108103
* Has argument.
109104
*
110-
* @param string $key Key of arguments array
111-
*
112105
* @return bool
113106
*/
114-
public function hasArgument($key)
107+
public function hasArgument(string $key)
115108
{
116109
return \array_key_exists($key, $this->arguments);
117110
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function reverseTransform($value)
158158
*
159159
* @throws TransformationFailedException in case the date formatter can not be constructed
160160
*/
161-
protected function getIntlDateFormatter($ignoreTimezone = false)
161+
protected function getIntlDateFormatter(bool $ignoreTimezone = false)
162162
{
163163
$dateFormat = $this->dateFormat;
164164
$timeFormat = $this->timeFormat;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getBlockPrefix()
8787
* The pattern contains the placeholder "{{ widget }}" where the HTML tag should
8888
* be inserted
8989
*/
90-
protected static function getPattern($currency)
90+
protected static function getPattern(?string $currency)
9191
{
9292
if (!$currency) {
9393
return '{{ widget }}';

src/Symfony/Component/HttpFoundation/JsonResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function create($data = null, int $status = 200, array $headers =
8383
*
8484
* @return static
8585
*/
86-
public static function fromJsonString($data = null, int $status = 200, array $headers = [])
86+
public static function fromJsonString(string $data = null, int $status = 200, array $headers = [])
8787
{
8888
return new static($data, $status, $headers, true);
8989
}

src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function execute()
153153
*
154154
* @internal
155155
*/
156-
public function getResource($idx = 0)
156+
public function getResource(int $idx = 0)
157157
{
158158
if (null === $this->results || $idx >= \count($this->results)) {
159159
return null;

src/Symfony/Component/Ldap/Security/LdapUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function supportsClass(string $class)
146146
*
147147
* @return LdapUser
148148
*/
149-
protected function loadUser($username, Entry $entry)
149+
protected function loadUser(string $username, Entry $entry)
150150
{
151151
$password = null;
152152
$extraFields = [];

src/Symfony/Component/Lock/Key.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function resetLifetime()
6060
/**
6161
* @param float $ttl the expiration delay of locks in seconds
6262
*/
63-
public function reduceLifetime($ttl)
63+
public function reduceLifetime(float $ttl)
6464
{
6565
$newTime = microtime(true) + $ttl;
6666

src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class AbstractStream
3030

3131
private $debug = '';
3232

33-
public function write(string $bytes, $debug = true): void
33+
public function write(string $bytes, bool $debug = true): void
3434
{
3535
if ($debug) {
3636
foreach (explode("\n", trim($bytes)) as $line) {

src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getConfiguration(): array
6363
return $this->configuration;
6464
}
6565

66-
public static function buildConfiguration($dsn, array $options = []): array
66+
public static function buildConfiguration(string $dsn, array $options = []): array
6767
{
6868
if (false === $components = parse_url($dsn)) {
6969
throw new InvalidArgumentException(sprintf('The given Doctrine Messenger DSN "%s" is invalid.', $dsn));

src/Symfony/Component/Messenger/Worker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function stop(): void
178178
$this->shouldStop = true;
179179
}
180180

181-
private function dispatchEvent($event)
181+
private function dispatchEvent(object $event): void
182182
{
183183
if (null === $this->eventDispatcher) {
184184
return;

0 commit comments

Comments
 (0)
0