8000 Parameter type leftovers by derrabus · Pull Request #33154 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Parameter type leftovers #33154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function format(array $record)
/**
* @internal
*/
public function echoLine($line, $depth, $indentPad)
public function echoLine(string $line, int $depth, string $indentPad)
{
if (-1 !== $depth) {
fwrite($this->outputBuffer, $line);
Expand All @@ -143,7 +143,7 @@ public function echoLine($line, $depth, $indentPad)
/**
* @internal
*/
public function castObject($v, array $a, Stub $s, $isNested)
public function castObject($v, array $a, Stub $s, bool $isNested)
{
if ($this->options['multiline']) {
return $a;
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Component/BrowserKit/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ public function clear()
* Updates the cookie jar from a response Set-Cookie headers.
*
* @param string[] $setCookies Set-Cookie headers from an HTTP response
* @param string $uri The base URL
*/
public function updateFromSetCookie(array $setCookies, $uri = null)
public function updateFromSetCookie(array $setCookies, string $uri = null)
{
$cookies = [];

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

/**
* Updates the cookie jar from a Response object.
*
* @param string $uri The base URL
*/
public function updateFromResponse(Response $response, string $uri = null)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Component/Config/Definition/ArrayNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,9 @@ protected function normalizeValue($value)
/**
* Remaps multiple singular values to a single plural value.
*
* @param array $value The source values
*
* @return array The remapped values
*/
protected function remapXml($value)
protected function remapXml(array $value)
{
foreach ($this->xmlRemappings as list($singular, $plural)) {
if (!isset($value[$singular])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function dump(ConfigurationInterface $configuration, string $namespace =
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
}

public function dumpNode(NodeInterface $node, $namespace = null)
public function dumpNode(NodeInterface $node, string $namespace = null)
{
$this->reference = '';
$this->writeNode($node, 0, true, $namespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function dump(ConfigurationInterface $configuration)
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ public function getPath()

/**
* Adds extra information that is suffixed to the original exception message.
*
* @param string $hint
*/
public function addHint($hint)
public function addHint(string $hint)
{
if (!$this->containsHints) {
$this->message .= "\nHint: ".$hint;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct($paths = [])
*/
public function locate(string $name, string $currentPath = null, bool $first = true)
{
if ('' == $name) {
if ('' === $name) {
throw new \InvalidArgumentException('An empty file name is not valid to be located.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function __sleep(): array
*
* @internal
*/
public static function throwOnRequiredClass($class, \Exception $previous = null)
public static function throwOnRequiredClass(string $class, \Exception $previous = null)
{
// If the passed class is the resource being checked, we shouldn't throw.
if (null === $previous && self::$autoloadedClass === $class) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Util/XmlUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static function phpize($value)
}
}

protected static function getXmlErrors($internalErrors)
protected static function getXmlErrors(bool $internalErrors)
{
$errors = [];
foreach (libxml_get_errors() as $error) {
Expand Down
12 changes: 3 additions & 9 deletions src/Symfony/Component/Console/Question/ChoiceQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ public function getChoices()
*
* When multiselect is set to true, multiple choices can be answered.
*
* @param bool $multiselect
*
* @return $this
*/
public function setMultiselect($multiselect)
public function setMultiselect(bool $multiselect)
{
$this->multiselect = $multiselect;
$this->setValidator($this->getDefaultValidator());
Expand Down Expand Up @@ -93,11 +91,9 @@ public function getPrompt()
/**
* Sets the prompt for choices.
*
* @param string $prompt
*
* @return $this
*/
public function setPrompt($prompt)
public function setPrompt(string $prompt)
{
$this->prompt = $prompt;

Expand All @@ -109,11 +105,9 @@ public function setPrompt($prompt)
*
* The error message has a string placeholder (%s) for the invalid value.
*
* @param string $errorMessage
*
* @return $this
*/
public function setErrorMessage($errorMessage)
public function setErrorMessage(string $errorMessage)
{
$this->errorMessage = $errorMessage;
$this->setValidator($this->getDefaultValidator());
Expand Down
15 changes: 4 additions & 11 deletions src/Symfony/Component/Console/Question/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ public function getAutocompleterValues()
/**
* Sets values for the autocompleter.
*
* @param iterable|null $values
*
* @return $this
*
* @throws InvalidArgumentException
* @throws LogicException
*/
public function setAutocompleterValues($values)
public function setAutocompleterValues(?iterable $values)
{
if (\is_array($values)) {
$values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
Expand All @@ -150,10 +147,8 @@ public function setAutocompleterValues($values)
$callback = static function () use ($values, &$valueCache) {
return $valueCache ?? $valueCache = iterator_to_array($values, false);
};
} elseif (null === $values) {
$callback = null;
} else {
throw new InvalidArgumentException('Autocompleter values can be either an array, "null" or a "Traversable" object.');
$callback = null;
}

return $this->setAutocompleterCallback($callback);
Expand Down Expand Up @@ -212,13 +207,11 @@ public function getValidator()
*
* Null means an unlimited number of attempts.
*
* @param int|null $attempts
*
* @return $this
*
* @throws InvalidArgumentException in case the number of attempts is invalid
*/
public function setMaxAttempts($attempts)
public function setMaxAttempts(?int $attempts)
{
if (null !== $attempts && $attempts < 1) {
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
Expand Down Expand Up @@ -267,7 +260,7 @@ public function getNormalizer()
return $this->normalizer;
}

protected function isAssoc($array)
protected function isAssoc(array $array)
{
return (bool) \count(array_filter(array_keys($array), 'is_string'));
}
Expand Down
8 changes: 2 additions & 6 deletions src/Symfony/Component/Console/Tests/Question/QuestionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Console\Tests\Question;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Question\Question;

class QuestionTest extends TestCase
Expand Down Expand Up @@ -150,10 +149,7 @@ public function providerSetAutocompleterValuesInvalid()
*/
public function testSetAutocompleterValuesInvalid($values)
{
self::expectException(InvalidArgumentException::class);
self::expectExceptionMessage(
'Autocompleter values can be either an array, "null" or a "Traversable" object.'
);
self::expectException(\TypeError::class);

$this->question->setAutocompleterValues($values);
}
Expand Down Expand Up @@ -271,7 +267,7 @@ public function testGetSetMaxAttempts($attempts)

public function providerSetMaxAttemptsInvalid()
{
return [['Potato'], [0], [-1]];
return [[0], [-1]];
}

/**
Expand Down
15 changes: 4 additions & 11 deletions src/Symfony/Component/EventDispatcher/GenericEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ public function getSubject()
/**
* Get argument by key.
*
* @param string $key Key
*
* @return mixed Contents of array key
*
* @throws \InvalidArgumentException if key is not found
*/
public function getArgument($key)
public function getArgument(string $key)
{
if ($this->hasArgument($key)) {
return $this->arguments[$key];
Expand All @@ -68,12 +66,11 @@ public function getArgument($key)
/**
* Add argument to event.
*
* @param string $key Argument name
* @param mixed $value Value
* @param mixed $value Value
*
* @return $this
*/
public function setArgument($key, $value)
public function setArgument(string $key, $value)
{
$this->arguments[$key] = $value;

Expand All @@ -93,8 +90,6 @@ public function getArguments()
/**
* Set args property.
*
* @param array $args Arguments
*
* @return $this
*/
public function setArguments(array $args = [])
Expand All @@ -107,11 +102,9 @@ public function setArguments(array $args = [])
/**
* Has argument.
*
* @param string $key Key of arguments array
*
* @return bool
*/
public function hasArgument($key)
public function hasArgument(string $key)
{
return \array_key_exists($key, $this->arguments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function reverseTransform($value)
*
* @throws TransformationFailedException in case the date formatter can not be constructed
*/
protected function getIntlDateFormatter($ignoreTimezone = false)
protected function getIntlDateFormatter(bool $ignoreTimezone = false)
{
$dateFormat = $this->dateFormat;
$timeFormat = $this->timeFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getBlockPrefix()
* The pattern contains the placeholder "{{ widget }}" where the HTML tag should
* be inserted
*/
protected static function getPattern($currency)
protected static function getPattern(?string $currency)
{
if (!$currency) {
return '{{ widget }}';
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function create($data = null, int $status = 200, array $headers =
*
* @return static
*/
public static function fromJsonString($data = null, int $status = 200, array $headers = [])
public static function fromJsonString(string $data = null, int $status = 200, array $headers = [])
{
return new static($data, $status, $headers, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function execute()
*
* @internal
*/
public function getResource($idx = 0)
public function getResource(int $idx = 0)
{
if (null === $this->results || $idx >= \count($this->results)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Security/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function supportsClass(string $class)
*
* @return LdapUser
*/
protected function loadUser($username, Entry $entry)
protected function loadUser(string $username, Entry $entry)
{
$password = null;
$extraFields = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function resetLifetime()
/**
* @param float $ttl the expiration delay of locks in seconds
*/
public function reduceLifetime($ttl)
public function reduceLifetime(float $ttl)
{
$newTime = microtime(true) + $ttl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class AbstractStream

private $debug = '';

public function write(string $bytes, $debug = true): void
public function write(string $bytes, bool $debug = true): void
{
if ($debug) {
foreach (explode("\n", trim($bytes)) as $line) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getConfiguration(): array
return $this->configuration;
}

public static function buildConfiguration($dsn, array $options = []): array
public static function buildConfiguration(string $dsn, array $options = []): array
{
if (false === $components = parse_url($dsn)) {
throw new InvalidArgumentException(sprintf('The given Doctrine Messenger DSN "%s" is invalid.', $dsn));
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function stop(): void
$this->shouldStop = true;
}

private function dispatchEvent($event)
private function dispatchEvent(object $event): void
{
if (null === $this->eventDispatcher) {
return;
Expand Down
Loading
0