From 1072087a961a49d2810144f063df48b703776fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Fri, 26 Jul 2024 13:31:18 +0200 Subject: [PATCH] Fix PHP 8.4 deprecations --- README.md | 2 +- src/Context.php | 2 +- src/RemoteRef/Preloaded.php | 2 +- src/Schema.php | 8 ++++---- src/SchemaContract.php | 6 +++--- src/Structure/ClassStructureTrait.php | 6 +++--- src/Wrapper.php | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f681a15..eb23097 100644 --- a/README.md +++ b/README.md @@ -466,7 +466,7 @@ If you want to map data to a different class you can register mapping at top lev ```php class CustomSwaggerSchema extends SwaggerSchema { - public static function import($data, Context $options = null) + public static function import($data, ?Context $options = null) { if ($options === null) { $options = new Context(); diff --git a/src/Context.php b/src/Context.php index c655dde..fff2862 100644 --- a/src/Context.php +++ b/src/Context.php @@ -75,7 +75,7 @@ public function setSkipValidation($skipValidation = true) * ProcessingOptions constructor. * @param RemoteRefProvider $remoteRefProvider */ - public function __construct(RemoteRefProvider $remoteRefProvider = null) + public function __construct(?RemoteRefProvider $remoteRefProvider = null) { $this->remoteRefProvider = $remoteRefProvider; } diff --git a/src/RemoteRef/Preloaded.php b/src/RemoteRef/Preloaded.php index e5b4a38..dc92937 100644 --- a/src/RemoteRef/Preloaded.php +++ b/src/RemoteRef/Preloaded.php @@ -42,7 +42,7 @@ public function getSchemaData($url) * @param Context|null $options * @throws \Swaggest\JsonSchema\Exception */ - public function populateSchemas(RefResolver $refResolver, Context $options = null) + public function populateSchemas(RefResolver $refResolver, ?Context $options = null) { if ($options === null) { $options = new Context(); diff --git a/src/Schema.php b/src/Schema.php index 6c1cee8..ff07f0c 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -109,7 +109,7 @@ public function addPropertyMapping($dataName, $propertyName, $mapping = self::DE * @throws InvalidValue * @throws \Exception */ - public static function import($data, Context $options = null) + public static function import($data, ?Context $options = null) { if (null === $options) { $options = new Context(); @@ -148,7 +148,7 @@ public static function import($data, Context $options = null) * @throws InvalidValue * @throws \Exception */ - public function in($data, Context $options = null) + public function in($data, ?Context $options = null) { if (null !== $this->__booleanSchema) { if ($this->__booleanSchema) { @@ -187,7 +187,7 @@ public function in($data, Context $options = null) * @throws InvalidValue * @throws \Exception */ - public function out($data, Context $options = null) + public function out($data, ?Context $options = null) { if ($options === null) { $options = new Context(); @@ -1385,7 +1385,7 @@ public function getMeta($name) * @param Context $options * @return ObjectItemContract */ - public function makeObjectItem(Context $options = null) + public function makeObjectItem(?Context $options = null) { if (null === $this->objectItemClass) { return new ObjectItem(); diff --git a/src/SchemaContract.php b/src/SchemaContract.php index a051305..bff1363 100644 --- a/src/SchemaContract.php +++ b/src/SchemaContract.php @@ -22,7 +22,7 @@ public function process($data, Context $options, $path = '#', $result = null); * @throws InvalidValue * @return array|mixed|null|object|\stdClass */ - public function in($data, Context $options = null); + public function in($data, ?Context $options = null); /** * @param mixed $data @@ -30,7 +30,7 @@ public function in($data, Context $options = null); * @throws InvalidValue * @return array|mixed|null|object|\stdClass */ - public function out($data, Context $options = null); + public function out($data, ?Context $options = null); /** * @return mixed @@ -44,7 +44,7 @@ public function getProperties(); * @param Context|null $options * @return Structure\ObjectItemContract */ - public function makeObjectItem(Context $options = null); + public function makeObjectItem(?Context $options = null); /** * @return string diff --git a/src/Structure/ClassStructureTrait.php b/src/Structure/ClassStructureTrait.php index c0bb6fc..393e65b 100644 --- a/src/Structure/ClassStructureTrait.php +++ b/src/Structure/ClassStructureTrait.php @@ -55,7 +55,7 @@ public static function properties() * @throws \Swaggest\JsonSchema\Exception * @throws \Swaggest\JsonSchema\InvalidValue */ - public static function import($data, Context $options = null) + public static function import($data, ?Context $options = null) { return static::schema()->in($data, $options); } @@ -67,7 +67,7 @@ public static function import($data, Context $options = null) * @throws \Swaggest\JsonSchema\InvalidValue * @throws \Exception */ - public static function export($data, Context $options = null) + public static function export($data, ?Context $options = null) { return static::schema()->out($data, $options); } @@ -150,7 +150,7 @@ public function jsonSerialize() /** * @return static|NameMirror */ - public static function names(Properties $properties = null, $mapping = Schema::DEFAULT_MAPPING) + public static function names(?Properties $properties = null, $mapping = Schema::DEFAULT_MAPPING) { if ($properties !== null) { return new NameMirror($properties->getDataKeyMap($mapping)); diff --git a/src/Wrapper.php b/src/Wrapper.php index 98946f6..421ec12 100644 --- a/src/Wrapper.php +++ b/src/Wrapper.php @@ -53,7 +53,7 @@ public function process($data, Context $options, $path = '#', $result = null) * @throws Exception * @throws InvalidValue */ - public function in($data, Context $options = null) + public function in($data, ?Context $options = null) { return $this->schema->in($data, $options); } @@ -65,7 +65,7 @@ public function in($data, Context $options = null) * @throws InvalidValue * @throws \Exception */ - public function out($data, Context $options = null) + public function out($data, ?Context $options = null) { return $this->schema->out($data, $options); } @@ -199,7 +199,7 @@ public function getMeta($name) * @param Context|null $options * @return Structure\ObjectItemContract */ - public function makeObjectItem(Context $options = null) + public function makeObjectItem(?Context $options = null) { return $this->schema->makeObjectItem($options); }