Skip to content

Commit 1f3a77a

Browse files
authored
Fix PHP 8.4 deprecations (#163)
* Fix PHP 8.4 deprecations * Test against PHP 8.4 * Change min PHP requirement to 7.1.x
1 parent 2b99251 commit 1f3a77a

10 files changed

+23
-23
lines changed

.github/workflows/test-unit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
operating-system: [ 'ubuntu-latest' ]
14-
php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '8.0', '8.1', '8.2', '8.3' ]
14+
php-versions: [ '7.1', '7.2', '7.3', '8.0', '8.1', '8.2', '8.3', '8.4' ]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ If you want to map data to a different class you can register mapping at top lev
466466
```php
467467
class CustomSwaggerSchema extends SwaggerSchema
468468
{
469-
public static function import($data, Context $options = null)
469+
public static function import($data, ?Context $options = null)
470470
{
471471
if ($options === null) {
472472
$options = new Context();

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "High definition PHP structures with JSON-schema based validation",
44
"type": "library",
55
"require": {
6-
"php": ">=5.4",
6+
"php": ">=7.1",
77
"ext-json": "*",
88
"phplang/scope-exit": "^1.0",
99
"swaggest/json-diff": "^3.8.2",
@@ -35,7 +35,7 @@
3535
},
3636
"config": {
3737
"platform": {
38-
"php": "5.4.45"
38+
"php": "7.1.33"
3939
}
4040
},
4141
"suggest": {

composer.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Context.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function setSkipValidation($skipValidation = true)
7575
* ProcessingOptions constructor.
7676
* @param RemoteRefProvider $remoteRefProvider
7777
*/
78-
public function __construct(RemoteRefProvider $remoteRefProvider = null)
78+
public function __construct(?RemoteRefProvider $remoteRefProvider = null)
7979
{
8080
$this->remoteRefProvider = $remoteRefProvider;
8181
}

src/RemoteRef/Preloaded.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getSchemaData($url)
4242
* @param Context|null $options
4343
* @throws \Swaggest\JsonSchema\Exception
4444
*/
45-
public function populateSchemas(RefResolver $refResolver, Context $options = null)
45+
public function populateSchemas(RefResolver $refResolver, ?Context $options = null)
4646
{
4747
if ($options === null) {
4848
$options = new Context();

src/Schema.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function addPropertyMapping($dataName, $propertyName, $mapping = self::DE
109109
* @throws InvalidValue
110110
* @throws \Exception
111111
*/
112-
public static function import($data, Context $options = null)
112+
public static function import($data, ?Context $options = null)
113113
{
114114
if (null === $options) {
115115
$options = new Context();
@@ -148,7 +148,7 @@ public static function import($data, Context $options = null)
148148
* @throws InvalidValue
149149
* @throws \Exception
150150
*/
151-
public function in($data, Context $options = null)
151+
public function in($data, ?Context $options = null)
152152
{
153153
if (null !== $this->__booleanSchema) {
154154
if ($this->__booleanSchema) {
@@ -187,7 +187,7 @@ public function in($data, Context $options = null)
187187
* @throws InvalidValue
188188
* @throws \Exception
189189
*/
190-
public function out($data, Context $options = null)
190+
public function out($data, ?Context $options = null)
191191
{
192192
if ($options === null) {
193193
$options = new Context();
@@ -1385,7 +1385,7 @@ public function getMeta($name)
13851385
* @param Context $options
13861386
* @return ObjectItemContract
13871387
*/
1388-
public function makeObjectItem(Context $options = null)
1388+
public function makeObjectItem(?Context $options = null)
13891389
{
13901390
if (null === $this->objectItemClass) {
13911391
return new ObjectItem();

src/SchemaContract.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public function process($data, Context $options, $path = '#', $result = null);
2222
* @throws InvalidValue
2323
* @return array|mixed|null|object|\stdClass
2424
*/
25-
public function in($data, Context $options = null);
25+
public function in($data, ?Context $options = null);
2626

2727
/**
2828
* @param mixed $data
2929
* @param Context|null $options
3030
* @throws InvalidValue
3131
* @return array|mixed|null|object|\stdClass
3232
*/
33-
public function out($data, Context $options = null);
33+
public function out($data, ?Context $options = null);
3434

3535
/**
3636
* @return mixed
@@ -44,7 +44,7 @@ public function getProperties();
4444
* @param Context|null $options
4545
* @return Structure\ObjectItemContract
4646
*/
47-
public function makeObjectItem(Context $options = null);
47+
public function makeObjectItem(?Context $options = null);
4848

4949
/**
5050
* @return string

src/Structure/ClassStructureTrait.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static function properties()
5555
* @throws \Swaggest\JsonSchema\Exception
5656
* @throws \Swaggest\JsonSchema\InvalidValue
5757
*/
58-
public static function import($data, Context $options = null)
58+
public static function import($data, ?Context $options = null)
5959
{
6060
return static::schema()->in($data, $options);
6161
}
@@ -67,7 +67,7 @@ public static function import($data, Context $options = null)
6767
* @throws \Swaggest\JsonSchema\InvalidValue
6868
* @throws \Exception
6969
*/
70-
public static function export($data, Context $options = null)
70+
public static function export($data, ?Context $options = null)
7171
{
7272
return static::schema()->out($data, $options);
7373
}
@@ -150,7 +150,7 @@ public function jsonSerialize()
150150
/**
151151
* @return static|NameMirror
152152
*/
153-
public static function names(Properties $properties = null, $mapping = Schema::DEFAULT_MAPPING)
153+
public static function names(?Properties $properties = null, $mapping = Schema::DEFAULT_MAPPING)
154154
{
155155
if ($properties !== null) {
156156
return new NameMirror($properties->getDataKeyMap($mapping));

src/Wrapper.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function process($data, Context $options, $path = '#', $result = null)
5353
* @throws Exception
5454
* @throws InvalidValue
5555
*/
56-
public function in($data, Context $options = null)
56+
public function in($data, ?Context $options = null)
5757
{
5858
return $this->schema->in($data, $options);
5959
}
@@ -65,7 +65,7 @@ public function in($data, Context $options = null)
6565
* @throws InvalidValue
6666
* @throws \Exception
6767
*/
68-
public function out($data, Context $options = null)
68+
public function out($data, ?Context $options = null)
6969
{
7070
return $this->schema->out($data, $options);
7171
}
@@ -199,7 +199,7 @@ public function getMeta($name)
199199
* @param Context|null $options
200200
* @return Structure\ObjectItemContract
201201
*/
202-
public function makeObjectItem(Context $options = null)
202+
public function makeObjectItem(?Context $options = null)
203203
{
204204
return $this->schema->makeObjectItem($options);
205205
}

0 commit comments

Comments
 (0)