From dd1481642bfc34965e17d5e70e7fcc1bfcd2bfb4 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 7 Apr 2021 18:12:22 +0200 Subject: [PATCH] [PHPDoc] Fix some union type cases --- .../DataCollector/SecurityDataCollector.php | 2 +- src/Symfony/Component/BrowserKit/Response.php | 2 +- .../Console/Descriptor/Descriptor.php | 10 ---------- .../Console/Descriptor/TextDescriptor.php | 2 +- .../Console/Helper/QuestionHelper.php | 2 +- .../Validator/Constraints/FormValidator.php | 6 +++--- .../Component/HttpFoundation/HeaderBag.php | 2 +- .../Mailer/EventListener/EnvelopeListener.php | 4 ++-- .../Command/AbstractFailedMessagesCommand.php | 2 +- src/Symfony/Component/Mime/Address.php | 2 +- src/Symfony/Component/Mime/Header/Headers.php | 2 +- .../Mime/Part/Multipart/FormDataPart.php | 2 +- src/Symfony/Component/Process/Process.php | 4 ++-- .../Routing/Loader/XmlFileLoader.php | 2 +- .../Security/Core/User/UserInterface.php | 2 +- .../Component/Serializer/Serializer.php | 4 ++-- .../ContextualValidatorInterface.php | 20 +++++++++---------- .../RecursiveContextualValidator.php | 4 ++-- .../Validator/ValidatorInterface.php | 20 +++++++++---------- .../HttpClient/ResponseInterface.php | 6 +++--- 20 files changed, 45 insertions(+), 55 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index 4fb0b3f5f5..e5756bb006 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -389,7 +389,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn /** * Returns the configuration of the current firewall context. * - * @return array|Data + * @return array|Data|null */ public function getFirewall() { diff --git a/src/Symfony/Component/BrowserKit/Response.php b/src/Symfony/Component/BrowserKit/Response.php index 46838ed9e1..6ec30e5e41 100644 --- a/src/Symfony/Component/BrowserKit/Response.php +++ b/src/Symfony/Component/BrowserKit/Response.php @@ -123,7 +123,7 @@ class Response * @param string $header The header name * @param bool $first Whether to return the first value or all header values * - * @return string|array The first header value if $first is true, an array of values otherwise + * @return string|array|null The first header value if $first is true, an array of values otherwise */ public function getHeader($header, $first = true) { diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php index d25a708e47..9c3878d1ed 100644 --- a/src/Symfony/Component/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php @@ -72,36 +72,26 @@ abstract class Descriptor implements DescriptorInterface /** * Describes an InputArgument instance. - * - * @return string|mixed */ abstract protected function describeInputArgument(InputArgument $argument, array $options = []); /** * Describes an InputOption instance. - * - * @return string|mixed */ abstract protected function describeInputOption(InputOption $option, array $options = []); /** * Describes an InputDefinition instance. - * - * @return string|mixed */ abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []); /** * Describes a Command instance. - * - * @return string|mixed */ abstract protected function describeCommand(Command $command, array $options = []); /** * Describes an Application instance. - * - * @return string|mixed */ abstract protected function describeApplication(Application $application, array $options = []); } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 1db3686be4..220bd2e681 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -298,7 +298,7 @@ class TextDescriptor extends Descriptor } /** - * @param (Command|string)[] $commands + * @param array $commands */ private function getColumnWidth(array $commands): int { diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 6dde580cf6..f1a3c4b5d7 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -97,7 +97,7 @@ class QuestionHelper extends Helper /** * Asks the question to the user. * - * @return bool|mixed|string|null + * @return mixed * * @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden */ diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index a765276dd7..66f198c669 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -202,7 +202,7 @@ class FormValidator extends ConstraintValidator /** * Returns the validation groups of the given form. * - * @return string|GroupSequence|(string|GroupSequence)[] The validation groups + * @return string|GroupSequence|array The validation groups */ private function getValidationGroups(FormInterface $form) { @@ -241,9 +241,9 @@ class FormValidator extends ConstraintValidator /** * Post-processes the validation groups option for a given form. * - * @param string|GroupSequence|(string|GroupSequence)[]|callable $groups The validation groups + * @param string|GroupSequence|array|callable $groups The validation groups * - * @return GroupSequence|(string|GroupSequence)[] The validation groups + * @return GroupSequence|array The validation groups */ private static function resolveValidationGroups($groups, FormInterface $form) { diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index a74dce883b..cb280b9872 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -255,7 +255,7 @@ class HeaderBag implements \IteratorAggregate, \Countable * * @param string $key The directive name * - * @return mixed|null The directive value if defined, null otherwise + * @return mixed The directive value if defined, null otherwise */ public function getCacheControlDirective($key) { diff --git a/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php b/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php index 570a9e3955..b439b2f0bf 100644 --- a/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php +++ b/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php @@ -27,8 +27,8 @@ class EnvelopeListener implements EventSubscriberInterface private $recipients; /** - * @param Address|string $sender - * @param (Address|string)[] $recipients + * @param Address|string $sender + * @param array $recipients */ public function __construct($sender = null, array $recipients = null) { diff --git a/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php b/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php index a95eb1fd41..ce78ba6828 100644 --- a/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php @@ -45,7 +45,7 @@ abstract class AbstractFailedMessagesCommand extends Command } /** - * @return mixed|null + * @return mixed */ protected function getMessageId(Envelope $envelope) { diff --git a/src/Symfony/Component/Mime/Address.php b/src/Symfony/Component/Mime/Address.php index 61d35e39e9..54948749de 100644 --- a/src/Symfony/Component/Mime/Address.php +++ b/src/Symfony/Component/Mime/Address.php @@ -106,7 +106,7 @@ final class Address } /** - * @param (Address|string)[] $addresses + * @param array $addresses * * @return Address[] */ diff --git a/src/Symfony/Component/Mime/Header/Headers.php b/src/Symfony/Component/Mime/Header/Headers.php index 94614d9881..53ce8f94ae 100644 --- a/src/Symfony/Component/Mime/Header/Headers.php +++ b/src/Symfony/Component/Mime/Header/Headers.php @@ -59,7 +59,7 @@ final class Headers } /** - * @param (Address|string)[] $addresses + * @param array $addresses * * @return $this */ diff --git a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php index c293efe82f..93ae1b910f 100644 --- a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php +++ b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php @@ -26,7 +26,7 @@ final class FormDataPart extends AbstractMultipartPart private $fields = []; /** - * @param (string|array|DataPart)[] $fields + * @param array $fields */ public function __construct(array $fields = []) { diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 70e97d18a5..57420e1dc5 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -132,7 +132,7 @@ class Process implements \IteratorAggregate * @param array $command The command to run and its arguments listed as separate entries * @param string|null $cwd The working directory or null to use the working dir of the current PHP process * @param array|null $env The environment variables or null to use the same environment as the current PHP process - * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input + * @param mixed $input The input as stream resource, scalar or \Traversable, or null for no input * @param int|float|null $timeout The timeout in seconds or null to disable * * @throws LogicException When proc_open is not installed @@ -183,7 +183,7 @@ class Process implements \IteratorAggregate * @param string $command The command line to pass to the shell of the OS * @param string|null $cwd The working directory or null to use the working dir of the current PHP process * @param array|null $env The environment variables or null to use the same environment as the current PHP process - * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input + * @param mixed $input The input as stream resource, scalar or \Traversable, or null for no input * @param int|float|null $timeout The timeout in seconds or null to disable * * @return static diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index c78213387f..2f087793b5 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -370,7 +370,7 @@ class XmlFileLoader extends FileLoader /** * Recursively parses the value of a "default" element. * - * @return array|bool|float|int|string The parsed value + * @return array|bool|float|int|string|null The parsed value * * @throws \InvalidArgumentException when the XML is invalid */ diff --git a/src/Symfony/Component/Security/Core/User/UserInterface.php b/src/Symfony/Component/Security/Core/User/UserInterface.php index fa4e101e5b..32661de9fa 100644 --- a/src/Symfony/Component/Security/Core/User/UserInterface.php +++ b/src/Symfony/Component/Security/Core/User/UserInterface.php @@ -44,7 +44,7 @@ interface UserInterface * and populated in any number of different ways when the user object * is created. * - * @return (Role|string)[] The user roles + * @return array The user roles */ public function getRoles(); diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index 8e1f57f0c5..dfd106e6da 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -66,8 +66,8 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface private $normalizerCache = []; /** - * @param (NormalizerInterface|DenormalizerInterface)[] $normalizers - * @param (EncoderInterface|DecoderInterface)[] $encoders + * @param array $normalizers + * @param array $encoders */ public function __construct(array $normalizers = [], array $encoders = []) { diff --git a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php index c8b545b54b..f15dfd1b0d 100644 --- a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php @@ -40,9 +40,9 @@ interface ContextualValidatorInterface * If no constraint is passed, the constraint * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. * - * @param mixed $value The value to validate - * @param Constraint|Constraint[] $constraints The constraint(s) to validate against - * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate against + * @param string|GroupSequence|array|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ @@ -52,9 +52,9 @@ interface ContextualValidatorInterface * Validates a property of an object against the constraints specified * for this property. * - * @param object $object The object - * @param string $propertyName The name of the validated property - * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param string|GroupSequence|array|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ @@ -64,10 +64,10 @@ interface ContextualValidatorInterface * Validates a value against the constraints specified for an object's * property. * - * @param object|string $objectOrClass The object or its class name - * @param string $propertyName The name of the property - * @param mixed $value The value to validate against the property's constraints - * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the property's constraints + * @param string|GroupSequence|array|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index c816317fb5..0e8f50c348 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -271,9 +271,9 @@ class RecursiveContextualValidator implements ContextualValidatorInterface /** * Normalizes the given group or list of groups to an array. * - * @param string|GroupSequence|(string|GroupSequence)[] $groups The groups to normalize + * @param string|GroupSequence|array $groups The groups to normalize * - * @return (string|GroupSequence)[] A group array + * @return array A group array */ protected function normalizeGroups($groups) { diff --git a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php index 78157465ab..4112b2c4e4 100644 --- a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php @@ -30,9 +30,9 @@ interface ValidatorInterface extends MetadataFactoryInterface * If no constraint is passed, the constraint * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. * - * @param mixed $value The value to validate - * @param Constraint|Constraint[] $constraints The constraint(s) to validate against - * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate against + * @param string|GroupSequence|array|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation @@ -44,9 +44,9 @@ interface ValidatorInterface extends MetadataFactoryInterface * Validates a property of an object against the constraints specified * for this property. * - * @param object $object The object - * @param string $propertyName The name of the validated property - * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param string|GroupSequence|array|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation @@ -58,10 +58,10 @@ interface ValidatorInterface extends MetadataFactoryInterface * Validates a value against the constraints specified for an object's * property. * - * @param object|string $objectOrClass The object or its class name - * @param string $propertyName The name of the property - * @param mixed $value The value to validate against the property's constraints - * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the property's constraints + * @param string|GroupSequence|array|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation diff --git a/src/Symfony/Contracts/HttpClient/ResponseInterface.php b/src/Symfony/Contracts/HttpClient/ResponseInterface.php index b9917ac5f3..dfd457a45e 100644 --- a/src/Symfony/Contracts/HttpClient/ResponseInterface.php +++ b/src/Symfony/Contracts/HttpClient/ResponseInterface.php @@ -97,15 +97,15 @@ interface ResponseInterface * - response_headers (array) - an array modelled after the special $http_response_header variable * - start_time (float) - the time when the request was sent or 0.0 when it's pending * - url (string) - the last effective URL of the request - * - user_data (mixed|null) - the value of the "user_data" request option, null if not set + * - user_data (mixed) - the value of the "user_data" request option, null if not set * * When the "capture_peer_cert_chain" option is true, the "peer_certificate_chain" * attribute SHOULD list the peer certificates as an array of OpenSSL X.509 resources. * * Other info SHOULD be named after curl_getinfo()'s associative return value. * - * @return array|mixed|null An array of all available info, or one of them when $type is - * provided, or null when an unsupported type is requested + * @return array|mixed An array of all available info, or one of them when $type is + * provided, or null when an unsupported type is requested */ public function getInfo(string $type = null); }