Skip to content

Commit

Permalink
Merge branch '6.3' into 6.4
Browse files Browse the repository at this point in the history
* 6.3:
  minor #53524 [Messenger] [AmazonSqs] Allow `async-aws/sqs` version 2 (smoench)
  Fix bad merge
  List CS fix in .git-blame-ignore-revs
  Fix implicitly-required parameters
  List CS fix in .git-blame-ignore-revs
  Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents 0b1eb47 + 5c67cd1 commit c149d49
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Command/XliffLintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class XliffLintCommand extends Command
private ?\Closure $isReadableProvider;
private bool $requireStrictFileNames;

public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null, bool $requireStrictFileNames = true)
public function __construct(?string $name = null, ?callable $directoryIteratorProvider = null, ?callable $isReadableProvider = null, bool $requireStrictFileNames = true)
{
parent::__construct($name);

Expand Down Expand Up @@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return $this->display($io, $filesInfo);
}

private function validate(string $content, string $file = null): array
private function validate(string $content, ?string $file = null): array
{
$errors = [];

Expand Down
2 changes: 1 addition & 1 deletion DataCollector/TranslationDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function lateCollect(): void
$this->data = $this->cloneVar($this->data);
}

public function collect(Request $request, Response $response, \Throwable $exception = null): void
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
$this->data['locale'] = $this->translator->getLocale();
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
Expand Down
6 changes: 3 additions & 3 deletions DataCollectorTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(TranslatorInterface $translator)
$this->translator = $translator;
}

public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
$trans = $this->translator->trans($id = (string) $id, $parameters, $domain, $locale);
$this->collectMessage($locale, $domain, $id, $trans, $parameters);
Expand All @@ -61,7 +61,7 @@ public function getLocale(): string
return $this->translator->getLocale();
}

public function getCatalogue(string $locale = null): MessageCatalogueInterface
public function getCatalogue(?string $locale = null): MessageCatalogueInterface
{
return $this->translator->getCatalogue($locale);
}
Expand All @@ -71,7 +71,7 @@ public function getCatalogues(): array
return $this->translator->getCatalogues();
}

public function warmUp(string $cacheDir, string $buildDir = null): array
public function warmUp(string $cacheDir, ?string $buildDir = null): array
{
if ($this->translator instanceof WarmableInterface) {
return (array) $this->translator->warmUp($cacheDir, $buildDir);
Expand Down
2 changes: 1 addition & 1 deletion Dumper/XliffFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private function dumpXliff2(string $defaultLocale, MessageCatalogue $messages, ?
return $dom->saveXML();
}

private function hasMetadataArrayInfo(string $key, array $metadata = null): bool
private function hasMetadataArrayInfo(string $key, ?array $metadata = null): bool
{
return is_iterable($metadata[$key] ?? null);
}
Expand Down
2 changes: 1 addition & 1 deletion Exception/IncompleteDsnException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class IncompleteDsnException extends InvalidArgumentException
{
public function __construct(string $message, string $dsn = null, \Throwable $previous = null)
public function __construct(string $message, ?string $dsn = null, ?\Throwable $previous = null)
{
if ($dsn) {
$message = sprintf('Invalid "%s" provider DSN: ', $dsn).$message;
Expand Down
2 changes: 1 addition & 1 deletion Exception/MissingRequiredOptionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class MissingRequiredOptionException extends IncompleteDsnException
{
public function __construct(string $option, string $dsn = null, \Throwable $previous = null)
public function __construct(string $option, ?string $dsn = null, ?\Throwable $previous = null)
{
$message = sprintf('The option "%s" is required but missing.', $option);

Expand Down
2 changes: 1 addition & 1 deletion Exception/ProviderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ProviderException extends RuntimeException implements ProviderExceptionInt
private ResponseInterface $response;
private string $debug;

public function __construct(string $message, ResponseInterface $response, int $code = 0, \Exception $previous = null)
public function __construct(string $message, ResponseInterface $response, int $code = 0, ?\Exception $previous = null)
{
$this->response = $response;
$this->debug = $response->getInfo('debug') ?? '';
Expand Down
2 changes: 1 addition & 1 deletion Exception/UnsupportedSchemeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UnsupportedSchemeException extends LogicException
],
];

public function __construct(Dsn $dsn, string $name = null, array $supported = [])
public function __construct(Dsn $dsn, ?string $name = null, array $supported = [])
{
$provider = $dsn->getScheme();
if (false !== $pos = strpos($provider, '+')) {
Expand Down
2 changes: 1 addition & 1 deletion Extractor/PhpStringTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static function parse(string $str): string
* @param string $str String without quotes
* @param string|null $quote Quote type
*/
public static function parseEscapeSequences(string $str, string $quote = null): string
public static function parseEscapeSequences(string $str, ?string $quote = null): string
{
if (null !== $quote) {
$str = str_replace('\\'.$quote, $quote, $str);
Expand Down
2 changes: 1 addition & 1 deletion Extractor/Visitor/AbstractVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function nodeFirstNamedArgumentIndex(Node\Expr\CallLike|Node\Attribute
return \PHP_INT_MAX;
}

private function getStringNamedArguments(Node\Expr\CallLike|Node\Attribute $node, string $argumentName = null, bool $isArgumentNamePattern = false): array
private function getStringNamedArguments(Node\Expr\CallLike|Node\Attribute $node, ?string $argumentName = null, bool $isArgumentNamePattern = false): array
{
$args = $node instanceof Node\Expr\CallLike ? $node->getArgs() : $node->args;
$argumentValues = [];
Expand Down
2 changes: 1 addition & 1 deletion Formatter/MessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterf
/**
* @param TranslatorInterface|null $translator An identity translator to use as selector for pluralization
*/
public function __construct(TranslatorInterface $translator = null, IntlFormatterInterface $intlFormatter = null)
public function __construct(?TranslatorInterface $translator = null, ?IntlFormatterInterface $intlFormatter = null)
{
$this->translator = $translator ?? new IdentityTranslator();
$this->intlFormatter = $intlFormatter ?? new IntlFormatter();
Expand Down
2 changes: 1 addition & 1 deletion Loader/IcuResFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function load(mixed $resource, string $locale, string $domain = 'messages
* @param array $messages Used internally for recursive calls
* @param string|null $path Current path being parsed, used internally for recursive calls
*/
protected function flatten(\ResourceBundle $rb, array &$messages = [], string $path = null): array
protected function flatten(\ResourceBundle $rb, array &$messages = [], ?string $path = null): array
{
foreach ($rb as $key => $value) {
$nodePath = $path ? $path.'.'.$key : $key;
Expand Down
4 changes: 2 additions & 2 deletions Loader/XliffFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private function extractXliff2(\DOMDocument $dom, MessageCatalogue $catalogue, s
/**
* Convert a UTF8 string to the specified encoding.
*/
private function utf8ToCharset(string $content, string $encoding = null): string
private function utf8ToCharset(string $content, ?string $encoding = null): string
{
if ('UTF-8' !== $encoding && !empty($encoding)) {
return mb_convert_encoding($content, $encoding, 'UTF-8');
Expand All @@ -204,7 +204,7 @@ private function utf8ToCharset(string $content, string $encoding = null): string
return $content;
}

private function parseNotesMetadata(\SimpleXMLElement $noteElement = null, string $encoding = null): array
private function parseNotesMetadata(?\SimpleXMLElement $noteElement = null, ?string $encoding = null): array
{
$notes = [];

Expand Down
4 changes: 2 additions & 2 deletions LoggingTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(TranslatorInterface $translator, LoggerInterface $lo
$this->logger = $logger;
}

public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
$trans = $this->translator->trans($id = (string) $id, $parameters, $domain, $locale);
$this->log($id, $domain, $locale);
Expand All @@ -64,7 +64,7 @@ public function getLocale(): string
return $this->translator->getLocale();
}

public function getCatalogue(string $locale = null): MessageCatalogueInterface
public function getCatalogue(?string $locale = null): MessageCatalogueInterface
{
return $this->translator->getCatalogue($locale);
}
Expand Down
2 changes: 1 addition & 1 deletion MessageCatalogue.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getDomains(): array
return array_values($domains);
}

public function all(string $domain = null): array
public function all(?string $domain = null): array
{
if (null !== $domain) {
// skip messages merge if intl-icu requested explicitly
Expand Down
2 changes: 1 addition & 1 deletion MessageCatalogueInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getDomains(): array;
*
* If $domain is null, it returns all messages.
*/
public function all(string $domain = null): array;
public function all(?string $domain = null): array;

/**
* Sets a message translation.
Expand Down
2 changes: 1 addition & 1 deletion Provider/Dsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getPassword(): ?string
return $this->password;
}

public function getPort(int $default = null): ?int
public function getPort(?int $default = null): ?int
{
return $this->port ?? $default;
}
Expand Down
2 changes: 1 addition & 1 deletion PseudoLocalizationTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct(TranslatorInterface $translator, array $options = []
$this->localizableHTMLAttributes = $options['localizable_html_attributes'] ?? [];
}

public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
$trans = '';
$visibleText = '';
Expand Down
2 changes: 1 addition & 1 deletion Resources/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* @author Nate Wiebe <nate@northern.co>
*/
function t(string $message, array $parameters = [], string $domain = null): TranslatableMessage
function t(string $message, array $parameters = [], ?string $domain = null): TranslatableMessage
{
return new TranslatableMessage($message, $parameters, $domain);
}
Expand Down
4 changes: 2 additions & 2 deletions Test/ProviderFactoryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testCreate(string $expected, string $dsn)
/**
* @dataProvider unsupportedSchemeProvider
*/
public function testUnsupportedSchemeException(string $dsn, string $message = null)
public function testUnsupportedSchemeException(string $dsn, ?string $message = null)
{
$factory = $this->createFactory();

Expand All @@ -107,7 +107,7 @@ public function testUnsupportedSchemeException(string $dsn, string $message = nu
/**
* @dataProvider incompleteDsnProvider
*/
public function testIncompleteDsnException(string $dsn, string $message = null)
public function testIncompleteDsnException(string $dsn, ?string $message = null)
{
$factory = $this->createFactory();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function getNotImplementingTranslatorBagInterfaceTranslatorClassNa

class TranslatorWithoutTranslatorBag implements TranslatorInterface
{
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Provider/DsnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class DsnTest extends TestCase
/**
* @dataProvider constructProvider
*/
public function testConstruct(string $dsnString, string $scheme, string $host, string $user = null, string $password = null, int $port = null, array $options = [], string $path = null)
public function testConstruct(string $dsnString, string $scheme, string $host, ?string $user = null, ?string $password = null, ?int $port = null, array $options = [], ?string $path = null)
{
$dsn = new Dsn($dsnString);
$this->assertSame($dsnString, $dsn->getOriginalDsn());
Expand Down Expand Up @@ -172,7 +172,7 @@ public static function invalidDsnProvider(): iterable
/**
* @dataProvider getOptionProvider
*/
public function testGetOption($expected, string $dsnString, string $option, string $default = null)
public function testGetOption($expected, string $dsnString, string $option, ?string $default = null)
{
$dsn = new Dsn($dsnString);

Expand Down
4 changes: 2 additions & 2 deletions TranslatableMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TranslatableMessage implements TranslatableInterface
private array $parameters;
private ?string $domain;

public function __construct(string $message, array $parameters = [], string $domain = null)
public function __construct(string $message, array $parameters = [], ?string $domain = null)
{
$this->message = $message;
$this->parameters = $parameters;
Expand All @@ -50,7 +50,7 @@ public function getDomain(): ?string
return $this->domain;
}

public function trans(TranslatorInterface $translator, string $locale = null): string
public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return $translator->trans($this->getMessage(), array_map(
static fn ($parameter) => $parameter instanceof TranslatableInterface ? $parameter->trans($translator, $locale) : $parameter,
Expand Down
8 changes: 4 additions & 4 deletions Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA
/**
* @throws InvalidArgumentException If a locale contains invalid characters
*/
public function __construct(string $locale, MessageFormatterInterface $formatter = null, string $cacheDir = null, bool $debug = false, array $cacheVary = [])
public function __construct(string $locale, ?MessageFormatterInterface $formatter = null, ?string $cacheDir = null, bool $debug = false, array $cacheVary = [])
{
$this->setLocale($locale);

Expand Down Expand Up @@ -110,7 +110,7 @@ public function addLoader(string $format, LoaderInterface $loader)
*
* @throws InvalidArgumentException If the locale contains invalid characters
*/
public function addResource(string $format, mixed $resource, string $locale, string $domain = null)
public function addResource(string $format, mixed $resource, string $locale, ?string $domain = null)
{
$domain ??= 'messages';

Expand Down Expand Up @@ -171,7 +171,7 @@ public function getFallbackLocales(): array
return $this->fallbackLocales;
}

public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
if (null === $id || '' === $id) {
return '';
Expand Down Expand Up @@ -203,7 +203,7 @@ public function trans(?string $id, array $parameters = [], string $domain = null
return $this->formatter->format($catalogue->get($id, $domain), $locale, $parameters);
}

public function getCatalogue(string $locale = null): MessageCatalogueInterface
public function getCatalogue(?string $locale = null): MessageCatalogueInterface
{
if (!$locale) {
$locale = $this->getLocale();
Expand Down
2 changes: 1 addition & 1 deletion TranslatorBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function addBag(TranslatorBagInterface $bag): void
}
}

public function getCatalogue(string $locale = null): MessageCatalogueInterface
public function getCatalogue(?string $locale = null): MessageCatalogueInterface
{
if (null === $locale || !isset($this->catalogues[$locale])) {
$this->catalogues[$locale] = new MessageCatalogue($locale);
Expand Down
2 changes: 1 addition & 1 deletion TranslatorBagInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface TranslatorBagInterface
*
* @throws InvalidArgumentException If the locale contains invalid characters
*/
public function getCatalogue(string $locale = null): MessageCatalogueInterface;
public function getCatalogue(?string $locale = null): MessageCatalogueInterface;

/**
* Returns all catalogues of the instance.
Expand Down

0 comments on commit c149d49

Please sign in to comment.