From 1f3a77a382c5d273a0f1fe34be3b8af4060a88cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Sun, 22 Dec 2024 22:18:27 +0100 Subject: [PATCH] Fix PHP 8.4 deprecations (#163) * Fix PHP 8.4 deprecations * Test against PHP 8.4 * Change min PHP requirement to 7.1.x --- .github/workflows/test-unit.yml | 2 +- README.md | 2 +- composer.json | 4 ++-- composer.lock | 8 ++++---- 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 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 70f6a04..a447ea1 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: operating-system: [ 'ubuntu-latest' ] - php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '8.0', '8.1', '8.2', '8.3' ] + php-versions: [ '7.1', '7.2', '7.3', '8.0', '8.1', '8.2', '8.3', '8.4' ] steps: - name: Checkout uses: actions/checkout@v4 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/composer.json b/composer.json index 6af9eb7..decb09f 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "High definition PHP structures with JSON-schema based validation", "type": "library", "require": { - "php": ">=5.4", + "php": ">=7.1", "ext-json": "*", "phplang/scope-exit": "^1.0", "swaggest/json-diff": "^3.8.2", @@ -35,7 +35,7 @@ }, "config": { "platform": { - "php": "5.4.45" + "php": "7.1.33" } }, "suggest": { diff --git a/composer.lock b/composer.lock index 3cc41ea..f27811f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f85c752aa7be87c0a9ba169493adbeba", + "content-hash": "cc266b32b15203be9de99c8ffa8c5740", "packages": [ { "name": "phplang/scope-exit", @@ -1310,12 +1310,12 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=5.4", + "php": ">=7.1", "ext-json": "*" }, "platform-dev": [], "platform-overrides": { - "php": "5.4.45" + "php": "7.1.33" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } 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); }