diff --git a/composer.json b/composer.json index e94814f..be2caeb 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ } }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.38", + "friendsofphp/php-cs-fixer": "^3.51", "phpstan/phpstan": "^1.10", "phpunit/phpunit" : "^9.6" }, diff --git a/lib/Deserializer/functions.php b/lib/Deserializer/functions.php index 2a05eb0..5f9731d 100644 --- a/lib/Deserializer/functions.php +++ b/lib/Deserializer/functions.php @@ -57,7 +57,7 @@ * * @phpstan-return array */ -function keyValue(Reader $reader, string $namespace = null): array +function keyValue(Reader $reader, ?string $namespace = null): array { // If there's no children, we don't do anything. if ($reader->isEmptyElement) { @@ -148,7 +148,7 @@ function keyValue(Reader $reader, string $namespace = null): array * * @phpstan-return list */ -function enum(Reader $reader, string $namespace = null): array +function enum(Reader $reader, ?string $namespace = null): array { // If there's no children, we don't do anything. if ($reader->isEmptyElement) { diff --git a/lib/LibXMLException.php b/lib/LibXMLException.php index 9b5332b..5c642a3 100644 --- a/lib/LibXMLException.php +++ b/lib/LibXMLException.php @@ -31,7 +31,7 @@ class LibXMLException extends ParseException * * @param \LibXMLError[] $errors */ - public function __construct(array $errors, int $code = 0, \Throwable $previousException = null) + public function __construct(array $errors, int $code = 0, ?\Throwable $previousException = null) { $this->errors = $errors; parent::__construct($errors[0]->message.' on line '.$errors[0]->line.', column '.$errors[0]->column, $code, $previousException); diff --git a/lib/Reader.php b/lib/Reader.php index c1399ad..49a7733 100644 --- a/lib/Reader.php +++ b/lib/Reader.php @@ -107,7 +107,7 @@ public function parse(): array * * @return array> */ - public function parseGetElements(array $elementMap = null): array + public function parseGetElements(?array $elementMap = null): array { $result = $this->parseInnerTree($elementMap); if (!is_array($result)) { @@ -132,7 +132,7 @@ public function parseGetElements(array $elementMap = null): array * * @return array>|string|null */ - public function parseInnerTree(array $elementMap = null) + public function parseInnerTree(?array $elementMap = null) { $text = null; $elements = []; diff --git a/lib/Service.php b/lib/Service.php index 1dd3427..598b41e 100644 --- a/lib/Service.php +++ b/lib/Service.php @@ -107,7 +107,7 @@ public function getWriter(): Writer * * @throws ParseException */ - public function parse($input, string $contextUri = null, string &$rootElementName = null) + public function parse($input, ?string $contextUri = null, ?string &$rootElementName = null) { if (is_resource($input)) { // Unfortunately the XMLReader doesn't support streams. When it @@ -151,7 +151,7 @@ public function parse($input, string $contextUri = null, string &$rootElementNam * * @throws ParseException */ - public function expect($rootElementName, $input, string $contextUri = null) + public function expect($rootElementName, $input, ?string $contextUri = null) { if (is_resource($input)) { // Unfortunately the XMLReader doesn't support streams. When it @@ -200,7 +200,7 @@ public function expect($rootElementName, $input, string $contextUri = null) * * @param string|array|object|XmlSerializable $value */ - public function write(string $rootElementName, $value, string $contextUri = null): string + public function write(string $rootElementName, $value, ?string $contextUri = null): string { $w = $this->getWriter(); $w->openMemory(); @@ -263,7 +263,7 @@ public function mapValueObject(string $elementName, string $className): void * * @throws \InvalidArgumentException */ - public function writeValueObject(object $object, string $contextUri = null): string + public function writeValueObject(object $object, ?string $contextUri = null): string { if (!isset($this->valueObjectMap[get_class($object)])) { throw new \InvalidArgumentException('"'.get_class($object).'" is not a registered value object class. Register your class with mapValueObject.'); diff --git a/tests/Sabre/Xml/Element/XmlFragmentTest.php b/tests/Sabre/Xml/Element/XmlFragmentTest.php index 62e2a2a..b6be236 100644 --- a/tests/Sabre/Xml/Element/XmlFragmentTest.php +++ b/tests/Sabre/Xml/Element/XmlFragmentTest.php @@ -111,7 +111,7 @@ public function xmlProvider(): array /** * @dataProvider xmlProvider */ - public function testSerialize(string $expectedFallback, string $input, string $expected = null): void + public function testSerialize(string $expectedFallback, string $input, ?string $expected = null): void { if (is_null($expected)) { $expected = $expectedFallback;