Skip to content

Commit

Permalink
Fix PHP 8.4 deprecations (#163)
Browse files Browse the repository at this point in the history
* Fix PHP 8.4 deprecations

* Test against PHP 8.4

* Change min PHP requirement to 7.1.x
  • Loading branch information
cedric-anne authored Dec 22, 2024
1 parent 2b99251 commit 1f3a77a
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"config": {
"platform": {
"php": "5.4.45"
"php": "7.1.33"
}
},
"suggest": {
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/RemoteRef/Preloaded.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/SchemaContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ 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
* @param Context|null $options
* @throws InvalidValue
* @return array|mixed|null|object|\stdClass
*/
public function out($data, Context $options = null);
public function out($data, ?Context $options = null);

/**
* @return mixed
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Structure/ClassStructureTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1f3a77a

Please sign in to comment.