From e78db7f5c70a21f0417a31f414c4a95fe76c07e4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 14:51:25 +0100 Subject: [PATCH] Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value --- Command/LintCommand.php | 4 ++-- Exception/ParseException.php | 2 +- Inline.php | 8 ++++---- Parser.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Command/LintCommand.php b/Command/LintCommand.php index 3ebd570e..6eac3998 100644 --- a/Command/LintCommand.php +++ b/Command/LintCommand.php @@ -43,7 +43,7 @@ class LintCommand extends Command private $directoryIteratorProvider; private $isReadableProvider; - public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null) + public function __construct(?string $name = null, ?callable $directoryIteratorProvider = null, ?callable $isReadableProvider = null) { parent::__construct($name); @@ -133,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return $this->display($io, $filesInfo); } - private function validate(string $content, int $flags, string $file = null) + private function validate(string $content, int $flags, ?string $file = null) { $prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) { if (\E_USER_DEPRECATED === $level) { diff --git a/Exception/ParseException.php b/Exception/ParseException.php index 8748d2b2..9b59ea30 100644 --- a/Exception/ParseException.php +++ b/Exception/ParseException.php @@ -29,7 +29,7 @@ class ParseException extends RuntimeException * @param string|null $snippet The snippet of code near the problem * @param string|null $parsedFile The file name where the error occurred */ - public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Throwable $previous = null) + public function __construct(string $message, int $parsedLine = -1, ?string $snippet = null, ?string $parsedFile = null, ?\Throwable $previous = null) { $this->parsedFile = $parsedFile; $this->parsedLine = $parsedLine; diff --git a/Inline.php b/Inline.php index 712add90..36cc404a 100644 --- a/Inline.php +++ b/Inline.php @@ -34,7 +34,7 @@ class Inline private static $objectForMap = false; private static $constantSupport = false; - public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null) + public static function initialize(int $flags, ?int $parsedLineNumber = null, ?string $parsedFilename = null) { self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags); @@ -58,7 +58,7 @@ public static function initialize(int $flags, int $parsedLineNumber = null, stri * * @throws ParseException */ - public static function parse(string $value = null, int $flags = 0, array &$references = []) + public static function parse(?string $value = null, int $flags = 0, array &$references = []) { if (null === $value) { return ''; @@ -269,7 +269,7 @@ private static function dumpNull(int $flags): string * * @throws ParseException When malformed inline YAML string is parsed */ - public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], bool &$isQuoted = null) + public static function parseScalar(string $scalar, int $flags = 0, ?array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], ?bool &$isQuoted = null) { if (\in_array($scalar[$i], ['"', "'"], true)) { // quoted scalar @@ -562,7 +562,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a * * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved */ - private static function evaluateScalar(string $scalar, int $flags, array &$references = [], bool &$isQuotedString = null) + private static function evaluateScalar(string $scalar, int $flags, array &$references = [], ?bool &$isQuotedString = null) { $isQuotedString = false; $scalar = trim($scalar); diff --git a/Parser.php b/Parser.php index e4bacd78..1b193ee6 100644 --- a/Parser.php +++ b/Parser.php @@ -576,7 +576,7 @@ private function getCurrentLineIndentation(): int * * @throws ParseException When indentation problem are detected */ - private function getNextEmbedBlock(int $indentation = null, bool $inSequence = false): string + private function getNextEmbedBlock(?int $indentation = null, bool $inSequence = false): string { $oldLineIndentation = $this->getCurrentLineIndentation(); @@ -1082,7 +1082,7 @@ private function isStringUnIndentedCollectionItem(): bool * * @internal */ - public static function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int + public static function preg_match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int { if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) { switch (preg_last_error()) {