8000 [5.2] Backport type fixes by nicolas-grekas · Pull Request #41946 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[5.2] Backport type fixes #41946

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
Jul 2, 2021
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/Doctrine/Form/Type/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function configureOptions(OptionsResolver $resolver)
*
* @return ORMQueryBuilderLoader
*/
public function getLoader(ObjectManager $manager, $queryBuilder, string $class)
public function getLoader(ObjectManager $manager, object $queryBuilder, string $class)
{
if (!$queryBuilder instanceof QueryBuilder) {
throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, get_debug_type($queryBuilder)));
Expand All @@ -76,7 +76,7 @@ public function getBlockPrefix()
* @internal This method is public to be usable as callback. It should not
* be used in user code.
*/
public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array
public function getQueryBuilderPartsForCachingHash(object $queryBuilder): ?array
{
if (!$queryBuilder instanceof QueryBuilder) {
throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, get_debug_type($queryBuilder)));
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Node/DumpNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class DumpNode extends Node
{
private $varPrefix;

public function __construct($varPrefix, ?Node $values, int $lineno, string $tag = null)
public function __construct(string $varPrefix, ?Node $values, int $lineno, string $tag = null)
{
$nodes = [];
if (null !== $values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Psr6CacheClearer $poolClearer, array $pools = [])
*
* @return string[]
*/
public function warmUp($cacheDirectory): array
public function warmUp(string $cacheDirectory): array
{
foreach ($this->pools as $pool) {
if ($this->poolClearer->hasPool($pool)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
/**
* {@inheritdoc}
*/
public function find($name)
public function find(string $name)
{
$this->registerCommands();

Expand All @@ -119,7 +119,7 @@ public function find($name)
/**
* {@inheritdoc}
*/
public function get($name)
public function get(string $name)
{
$this->registerCommands();

Expand All @@ -135,7 +135,7 @@ public function get($name)
/**
* {@inheritdoc}
*/
public function all($namespace = null)
public function all(string $namespace = null)
{
$this->registerCommands();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ abstract protected function describeContainerTags(ContainerBuilder $builder, arr
*
* @param Definition|Alias|object $service
*/
abstract protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null);
abstract protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null);

/**
* Describes container services.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio
$this->writeData($data, $options);
}

protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null)
protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null)
{
if (!isset($options['id'])) {
throw new \InvalidArgumentException('An "id" option must be provided.');
Expand Down
Original file line number Diff lin 10000 e number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio
}
}

protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null)
protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null)
{
if (!isset($options['id'])) {
throw new \InvalidArgumentException('An "id" option must be provided.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio
}
}

protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null)
protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null)
{
if (!isset($options['id'])) {
throw new \InvalidArgumentException('An "id" option must be provided.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio
$this->writeDocument($this->getContainerTagsDocument($builder, isset($options['show_hidden']) && $options['show_hidden']));
}

protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null)
protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null)
{
if (!isset($options['id'])) {
throw new \InvalidArgumentException('An "id" option must be provided.');
Expand Down Expand Up @@ -255,7 +255,7 @@ private function getContainerTagsDocument(ContainerBuilder $builder, bool $showH
return $dom;
}

private function getContainerServiceDocument($service, string $id, ContainerBuilder $builder = null, bool $showArguments = false): \DOMDocument
private function getContainerServiceDocument(object $service, string $id, ContainerBuilder $builder = null, bool $showArguments = false): \DOMDocument
{
$dom = new \DOMDocument('1.0', 'UTF-8');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ protected function isCsrfTokenValid(string $id, ?string $token): bool
*
* @param object|Envelope $message The message or the message pre-wrapped in an envelope
*/
protected function dispatchMessage($message, array $stamps = []): Envelope
protected function dispatchMessage(object $message, array $stamps = []): Envelope
{
if (!$this->container->has('messenger.default_bus')) {
$message = class_exists(Envelope::class) ? 'You need to define the "messenger.default_bus" configuration option.' : 'Try running "composer require symfony/messenger".';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ControllerResolver extends ContainerControllerResolver
/**
* {@inheritdoc}
*/
protected function instantiateController($class): object
protected function instantiateController(string $class): object
{
$controller = parent::instantiateController($class);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function enableReboot()
/**
* @param UserInterface $user
*/
public function loginUser($user, string $firewallContext = 'main'): self
public function loginUser(object $user, string $firewallContext = 'main'): self
{
if (!interface_exists(UserInterface::class)) {
throw new \LogicException(sprintf('"%s" requires symfony/security-core to be installed.', __METHOD__));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ class AnnotatedRouteControllerLoader extends AnnotationClassLoader
{
/**
* Configures the _controller default parameter of a given Route instance.
*
* @param object $annot The annotation class instance
*/
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
{
if ('__invoke' === $method->getName()) {
$route->setDefault('_controller', $class->getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static function assertRequestAttributeValueSame(string $name, string $exp
self::assertThat(self::getRequest(), new ResponseConstraint\RequestAttributeValueSame($name, $expectedValue), $message);
}

public static function assertRouteSame($expectedRoute, array $parameters = [], string $message = ''): void
public static function assertRouteSame(string $expectedRoute, array $parameters = [], string $message = ''): void
{
$constraint = new ResponseConstraint\RequestAttributeValueSame('_route', $expectedRoute);
$constraints = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function getListenerId()
/**
* {@inheritdoc}
*/
protected function isRememberMeAware($config)
protected function isRememberMeAware(array $config)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class FirewallConfig
private $listeners;
private $switchUser;

public function __construct(string $name, string $userChecker, string $requestMatcher = null, bool $securityEnabled = true, bool $stateless = false, string $provider = null, string $context = null, string $entryPoint = null, string $accessDeniedHandler = null, string $accessDeniedUrl = null, array $listeners = [], $switchUser = null)
public function __construct(string $name, string $userChecker, string $requestMatcher = null, bool $securityEnabled = true, bool $stateless = false, string $provider = null, string $context = null, string $entryPoint = null, string $accessDeniedHandler = null, string $accessDeniedUrl = null, array $listeners = [], array $switchUser = null)
{
$this->name = $name;
$this->userChecker = $userChecker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private function hasHashOrNonce(array $directives): bool
return false;
}

private function getDirectiveFallback(array $directiveSet, $type)
private function getDirectiveFallback(array $directiveSet, string $type)
{
if (\in_array($type, ['script-src-elem', 'style-src-elem'], true) || !isset($directiveSet['default-src'])) {
// Let the browser fallback on it's own
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/BrowserKit/Tests/TestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function setNextResponse(Response $response)
$this->nextResponse = $response;
}

public function setNextScript($script)
public function setNextScript(string $script)
{
$this->nextScript = $script;
}

protected function doRequest($request): Response
protected function doRequest(object $request): Response
{
if (null === $this->nextResponse) {
return new Response();
Expand All @@ -41,7 +41,7 @@ protected function doRequest($request): Response
return $response;
}

protected function getScript($request)
protected function getScript(object $request)
{
$r = new \ReflectionClass(Response::class);
$path = $r->getFileName();
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/BrowserKit/Tests/TestHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public function setNextResponse(Response $response)
$this->nextResponse = $response;
}

public function setNextScript($script)
public function setNextScript(string $script)
{
$this->nextScript = $script;
}

protected function doRequest($request): Response
protected function doRequest(object $request): Response
{
if (null === $this->nextResponse) {
return parent::doRequest($request);
Expand All @@ -64,7 +64,7 @@ protected function doRequest($request): Response
return $response;
}

protected function getScript($request)
protected function getScript(object $request)
{
$r = new \ReflectionClass(Response::class);
$path = $r->getFileName();
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Config/Definition/ArrayNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
protected $removeExtraKeys = true;
protected $normalizeKeys = true;

public function setNormalizeKeys($normalizeKeys)
public function setNormalizeKeys(bool $normalizeKeys)
{
$this->normalizeKeys = (bool) $normalizeKeys;
$this->normalizeKeys = $normalizeKeys;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Config/Definition/BaseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ public function addEquivalentValue($originalValue, $equivalentValue)

/**
* Set this node as required.
*
* @param bool $boolean Required node
*/
public function setRequired(bool $boolean)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ public function end()
/**
* Creates the node.
*
* @param bool $forceRootNode Whether to force this node as the root node
*
* @return NodeInterface
*/
public function getNode(bool $forceRootNode = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class InvalidConfigurationException extends Exception
private $path;
private $containsHints = false;

public function setPath($path)
public function setPath(string $path)
{
$this->path = $path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private function safelyUnserialize(string $file)
/**
* @internal
*/
public static function handleUnserializeCallback($class)
public static function handleUnserializeCallback(string $class)
{
trigger_error('Class not found: '.$class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected function getPrototypeNodeWithDefaultChildren()
*
* @dataProvider getDataForKeyRemovedLeftValueOnly
*/
public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, $children, array $expected)
public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, array $children, array $expected)
{
$node = new PrototypedArrayNode('root');
$node->setKeyAttribute('id', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class NodeBuilder extends BaseNodeBuilder
{
public function barNode($name): NodeDefinition
public function barNode(?string $name): NodeDefinition
{
return $this->node($name, 'bar');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __toString(): string
return 'stub';
}

public function isFresh($timestamp): bool
public function isFresh(int $timestamp): bool
{
return $this->fresh;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function getDataForConvertDomToArray(): array
/**
* @dataProvider getDataForPhpize
*/
public function testPhpize($expected, $value)
public function testPhpize($expected, string $value)
{
$this->assertSame($expected, XmlUtils::phpize($value));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public function getNativeDefinition()
* Adds an argument.
*
* @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
* @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
* @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
*
* @throws InvalidArgumentException When argument mode is not valid
*
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Descriptor/Descriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class Descriptor implements DescriptorInterface
/**
* {@inheritdoc}
*/
public function describe(OutputInterface $output, $object, array $options = [])
public function describe(OutputInterface $output, object $object, array $options = [])
{
$this->output = $output;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MarkdownDescriptor extends Descriptor
/**
* {@inheritdoc}
*/
public function describe(OutputInterface $output, $object, array $options = [])
public function describe(OutputInterface $output, object $object, array $options = [])
{
$decorated = $output->isDecorated();
$output->setDecorated(false);
Expand Down
8 changes: 3 additions & 5 deletions src/Symfony/Component/Console/Input/InputOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ class InputOption
private $description;

/**
* @param string $name The option name
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int|null $mode The option mode: One of the VALUE_* constants
* @param string $description A description text
* @param mixed $default The default value (must be null for self::VALUE_NONE)
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int|null $mode The option mode: One of the VALUE_* constants
* @param mixed $default The default value (must be null for self::VALUE_NONE)
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function addContent(string $input)
/**
* {@inheritdoc}
*/
protected function doWrite($message, $newline)
protected function doWrite(string $message, bool $newline)
{
if (!$this->isDecorated()) {
parent::doWrite($message, $newline);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Output/TrimmedBufferOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function fetch()
/**
* {@inheritdoc}
*/
protected function doWrite($message, $newline)
protected function doWrite(string $message, bool $newline)
{
$this->buffer .= $message;

Expand Down
Loading
0