diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ae67938..37514a3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2, 8.3] + php: [8.2, 8.3, 8.4] laravel: [11] steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index ec8da56..cc64dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. This projec ## Unreleased +### Fixed + +- Remove deprecation notices in PHP 8.4. + ## [4.3.1] - 2024-10-31 ### Fixed diff --git a/composer.json b/composer.json index 9615bcf..715f51c 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "ext-json": "*", "illuminate/database": "^11.0", "illuminate/support": "^11.0", - "laravel-json-api/core": "^4.0" + "laravel-json-api/core": "^4.3.2" }, "require-dev": { "orchestra/testbench": "^9.0", diff --git a/phpunit.xml b/phpunit.xml index 1d3f64e..9816699 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -13,6 +13,7 @@ failOnWarning="true" failOnDeprecation="true" failOnNotice="true" + displayDetailsOnTestsThatTriggerDeprecations="true" > diff --git a/src/Fields/ArrayHash.php b/src/Fields/ArrayHash.php index 170eb4a..7abd2bd 100644 --- a/src/Fields/ArrayHash.php +++ b/src/Fields/ArrayHash.php @@ -55,7 +55,7 @@ class ArrayHash extends Attribute * @param string|null $column * @return ArrayHash */ - public static function make(string $fieldName, string $column = null): self + public static function make(string $fieldName, ?string $column = null): self { return new self($fieldName, $column); } diff --git a/src/Fields/ArrayList.php b/src/Fields/ArrayList.php index a1faa3a..b961818 100644 --- a/src/Fields/ArrayList.php +++ b/src/Fields/ArrayList.php @@ -30,7 +30,7 @@ class ArrayList extends Attribute * @param string|null $column * @return ArrayList */ - public static function make(string $fieldName, string $column = null): self + public static function make(string $fieldName, ?string $column = null): self { return new self($fieldName, $column); } diff --git a/src/Fields/Attribute.php b/src/Fields/Attribute.php index 80c35cc..2d40671 100644 --- a/src/Fields/Attribute.php +++ b/src/Fields/Attribute.php @@ -91,7 +91,7 @@ abstract protected function assertValue($value): void; * @param string $fieldName * @param string|null $column */ - public function __construct(string $fieldName, string $column = null) + public function __construct(string $fieldName, ?string $column = null) { if (empty($fieldName)) { throw new InvalidArgumentException('Expecting a non-empty string field name.'); diff --git a/src/Fields/Boolean.php b/src/Fields/Boolean.php index 3d8ff4d..2733935 100644 --- a/src/Fields/Boolean.php +++ b/src/Fields/Boolean.php @@ -21,7 +21,7 @@ class Boolean extends Attribute * @param string|null $column * @return Boolean */ - public static function make(string $fieldName, string $column = null): self + public static function make(string $fieldName, ?string $column = null): self { return new self($fieldName, $column); } diff --git a/src/Fields/DateTime.php b/src/Fields/DateTime.php index 7f7c5d3..8d58d81 100644 --- a/src/Fields/DateTime.php +++ b/src/Fields/DateTime.php @@ -37,7 +37,7 @@ class DateTime extends Attribute * @param string|null $column * @return static */ - public static function make(string $fieldName, string $column = null): self + public static function make(string $fieldName, ?string $column = null): self { return new static($fieldName, $column); } diff --git a/src/Fields/ID.php b/src/Fields/ID.php index 44dad77..216b093 100644 --- a/src/Fields/ID.php +++ b/src/Fields/ID.php @@ -36,7 +36,7 @@ class ID implements IDContract, Fillable * @param string|null $column * @return static */ - public static function make(string $column = null): self + public static function make(?string $column = null): self { return new static($column); } @@ -46,7 +46,7 @@ public static function make(string $column = null): self * * @param string|null $column */ - public function __construct(string $column = null) + public function __construct(?string $column = null) { $this->column = $column ?: null; $this->sortable(); diff --git a/src/Fields/Number.php b/src/Fields/Number.php index c683820..097b995 100644 --- a/src/Fields/Number.php +++ b/src/Fields/Number.php @@ -27,7 +27,7 @@ class Number extends Attribute * @param string|null $column * @return Number */ - public static function make(string $fieldName, string $column = null): self + public static function make(string $fieldName, ?string $column = null): self { return new self($fieldName, $column); } diff --git a/src/Fields/Relations/BelongsTo.php b/src/Fields/Relations/BelongsTo.php index dad2dfd..9be9951 100644 --- a/src/Fields/Relations/BelongsTo.php +++ b/src/Fields/Relations/BelongsTo.php @@ -26,7 +26,7 @@ class BelongsTo extends ToOne implements FillableToOne * @param string|null $relation * @return static */ - public static function make(string $fieldName, string $relation = null): BelongsTo + public static function make(string $fieldName, ?string $relation = null): BelongsTo { return new static($fieldName, $relation); } @@ -37,7 +37,7 @@ public static function make(string $fieldName, string $relation = null): Belongs * @param string $fieldName * @param string|null $relation */ - public function __construct(string $fieldName, string $relation = null) + public function __construct(string $fieldName, ?string $relation = null) { parent::__construct($fieldName, $relation); $this->mustValidate(); diff --git a/src/Fields/Relations/BelongsToMany.php b/src/Fields/Relations/BelongsToMany.php index e940482..ec3e859 100644 --- a/src/Fields/Relations/BelongsToMany.php +++ b/src/Fields/Relations/BelongsToMany.php @@ -31,7 +31,7 @@ class BelongsToMany extends ToMany implements FillableToMany * @param string|null $relation * @return BelongsToMany */ - public static function make(string $fieldName, string $relation = null): BelongsToMany + public static function make(string $fieldName, ?string $relation = null): BelongsToMany { return new self($fieldName, $relation); } diff --git a/src/Fields/Relations/HasMany.php b/src/Fields/Relations/HasMany.php index 3ebd37b..4d1eff6 100644 --- a/src/Fields/Relations/HasMany.php +++ b/src/Fields/Relations/HasMany.php @@ -46,7 +46,7 @@ class HasMany extends ToMany implements FillableToMany * @param string|null $relation * @return HasMany */ - public static function make(string $fieldName, string $relation = null): HasMany + public static function make(string $fieldName, ?string $relation = null): HasMany { return new self($fieldName, $relation); } diff --git a/src/Fields/Relations/HasManyThrough.php b/src/Fields/Relations/HasManyThrough.php index cd7cf54..ced413f 100644 --- a/src/Fields/Relations/HasManyThrough.php +++ b/src/Fields/Relations/HasManyThrough.php @@ -21,7 +21,7 @@ class HasManyThrough extends ToMany * @param string|null $relation * @return HasManyThrough */ - public static function make(string $fieldName, string $relation = null): HasManyThrough + public static function make(string $fieldName, ?string $relation = null): HasManyThrough { return new self($fieldName, $relation); } diff --git a/src/Fields/Relations/HasOne.php b/src/Fields/Relations/HasOne.php index 4901528..5ccb580 100644 --- a/src/Fields/Relations/HasOne.php +++ b/src/Fields/Relations/HasOne.php @@ -44,7 +44,7 @@ class HasOne extends ToOne implements FillableToOne * @param string|null $relation * @return HasOne */ - public static function make(string $fieldName, string $relation = null): HasOne + public static function make(string $fieldName, ?string $relation = null): HasOne { return new self($fieldName, $relation); } diff --git a/src/Fields/Relations/HasOneThrough.php b/src/Fields/Relations/HasOneThrough.php index 5a80fe9..7840054 100644 --- a/src/Fields/Relations/HasOneThrough.php +++ b/src/Fields/Relations/HasOneThrough.php @@ -21,7 +21,7 @@ class HasOneThrough extends ToOne * @param string|null $relation * @return HasOneThrough */ - public static function make(string $fieldName, string $relation = null): HasOneThrough + public static function make(string $fieldName, ?string $relation = null): HasOneThrough { return new self($fieldName, $relation); } diff --git a/src/Fields/Relations/Relation.php b/src/Fields/Relations/Relation.php index 87a1a06..6ffda6e 100644 --- a/src/Fields/Relations/Relation.php +++ b/src/Fields/Relations/Relation.php @@ -89,7 +89,7 @@ abstract protected function guessInverse(): string; * @param string $fieldName * @param string|null $relation */ - public function __construct(string $fieldName, string $relation = null) + public function __construct(string $fieldName, ?string $relation = null) { $this->name = $fieldName; $this->relation = $relation; diff --git a/src/Fields/SoftDelete.php b/src/Fields/SoftDelete.php index 74bc769..6c472c5 100644 --- a/src/Fields/SoftDelete.php +++ b/src/Fields/SoftDelete.php @@ -32,7 +32,7 @@ class SoftDelete extends DateTime * @param string $fieldName * @param string|null $column */ - public function __construct(string $fieldName, string $column = null) + public function __construct(string $fieldName, ?string $column = null) { parent::__construct($fieldName, $column); $this->unguarded(); diff --git a/src/Fields/Str.php b/src/Fields/Str.php index b4d436b..3304745 100644 --- a/src/Fields/Str.php +++ b/src/Fields/Str.php @@ -21,7 +21,7 @@ class Str extends Attribute * @param string|null $column * @return Str */ - public static function make(string $fieldName, string $column = null): self + public static function make(string $fieldName, ?string $column = null): self { return new self($fieldName, $column); } diff --git a/src/Filters/Has.php b/src/Filters/Has.php index 2fb357e..55fe880 100644 --- a/src/Filters/Has.php +++ b/src/Filters/Has.php @@ -30,7 +30,7 @@ class Has implements Filter * @param string|null $key * @return static */ - public static function make(Schema $schema, string $fieldName, string $key = null) + public static function make(Schema $schema, string $fieldName, ?string $key = null) { return new static($schema, $fieldName, $key); } @@ -42,7 +42,7 @@ public static function make(Schema $schema, string $fieldName, string $key = nul * @param string $fieldName * @param string|null $key */ - public function __construct(Schema $schema, string $fieldName, string $key = null) + public function __construct(Schema $schema, string $fieldName, ?string $key = null) { $this->schema = $schema; $this->fieldName = $fieldName; diff --git a/src/Filters/Scope.php b/src/Filters/Scope.php index 9e21653..4983ca7 100644 --- a/src/Filters/Scope.php +++ b/src/Filters/Scope.php @@ -37,7 +37,7 @@ class Scope implements Filter * @param string|null $scope * @return static */ - public static function make(string $name, string $scope = null) + public static function make(string $name, ?string $scope = null) { return new static($name, $scope); } @@ -48,7 +48,7 @@ public static function make(string $name, string $scope = null) * @param string $name * @param string|null $scope */ - public function __construct(string $name, string $scope = null) + public function __construct(string $name, ?string $scope = null) { $this->name = $name; $this->scope = $scope ?: $this->guessScope(); diff --git a/src/Filters/Where.php b/src/Filters/Where.php index d1672e2..b8b870f 100644 --- a/src/Filters/Where.php +++ b/src/Filters/Where.php @@ -34,7 +34,7 @@ class Where implements Filter * @param string|null $column * @return static */ - public static function make(string $name, string $column = null): self + public static function make(string $name, ?string $column = null): self { return new static($name, $column); } @@ -45,7 +45,7 @@ public static function make(string $name, string $column = null): self * @param string $name * @param string|null $column */ - public function __construct(string $name, string $column = null) + public function __construct(string $name, ?string $column = null) { $this->name = $name; $this->column = $column ?: $this->guessColumn(); diff --git a/src/Filters/WhereAll.php b/src/Filters/WhereAll.php index 9acf9a2..f1c36d1 100644 --- a/src/Filters/WhereAll.php +++ b/src/Filters/WhereAll.php @@ -34,7 +34,7 @@ class WhereAll implements Filter * @param array|null $columns * @return static */ - public static function make(string $name, array $columns = null): static + public static function make(string $name, ?array $columns = null): static { return new static($name, $columns); } @@ -45,7 +45,7 @@ public static function make(string $name, array $columns = null): static * @param string $name * @param array|null $columns */ - public function __construct(string $name, array $columns = null) + public function __construct(string $name, ?array $columns = null) { $this->name = $name; $this->columns = $columns ?? []; diff --git a/src/Filters/WhereAny.php b/src/Filters/WhereAny.php index 8a08c42..d8ae439 100644 --- a/src/Filters/WhereAny.php +++ b/src/Filters/WhereAny.php @@ -34,7 +34,7 @@ class WhereAny implements Filter * @param array|null $columns * @return static */ - public static function make(string $name, array $columns = null): static + public static function make(string $name, ?array $columns = null): static { return new static($name, $columns); } @@ -45,7 +45,7 @@ public static function make(string $name, array $columns = null): static * @param string $name * @param array|null $columns */ - public function __construct(string $name, array $columns = null) + public function __construct(string $name, ?array $columns = null) { $this->name = $name; $this->columns = $columns ?? []; diff --git a/src/Filters/WhereHas.php b/src/Filters/WhereHas.php index 2241f55..f80471f 100644 --- a/src/Filters/WhereHas.php +++ b/src/Filters/WhereHas.php @@ -33,7 +33,7 @@ class WhereHas implements Filter * @param string|null $key * @return static */ - public static function make(Schema $schema, string $fieldName, string $key = null) + public static function make(Schema $schema, string $fieldName, ?string $key = null) { return new static($schema, $fieldName, $key); } @@ -45,7 +45,7 @@ public static function make(Schema $schema, string $fieldName, string $key = nul * @param string $fieldName * @param string|null $key */ - public function __construct(Schema $schema, string $fieldName, string $key = null) + public function __construct(Schema $schema, string $fieldName, ?string $key = null) { $this->schema = $schema; $this->fieldName = $fieldName; diff --git a/src/Filters/WhereIdIn.php b/src/Filters/WhereIdIn.php index c823208..6541382 100644 --- a/src/Filters/WhereIdIn.php +++ b/src/Filters/WhereIdIn.php @@ -45,7 +45,7 @@ class WhereIdIn implements Filter * @param string|null $key * @return static */ - public static function make(Schema $schema, string $key = null): self + public static function make(Schema $schema, ?string $key = null): self { if ($schema instanceof EloquentSchema) { return new static( diff --git a/src/Filters/WhereIn.php b/src/Filters/WhereIn.php index 0b4f230..7f97e3d 100644 --- a/src/Filters/WhereIn.php +++ b/src/Filters/WhereIn.php @@ -33,7 +33,7 @@ class WhereIn implements Filter * @param string|null $column * @return static */ - public static function make(string $name, string $column = null): self + public static function make(string $name, ?string $column = null): self { return new static($name, $column); } @@ -44,7 +44,7 @@ public static function make(string $name, string $column = null): self * @param string $name * @param string|null $column */ - public function __construct(string $name, string $column = null) + public function __construct(string $name, ?string $column = null) { $this->name = $name; $this->column = $column ?: $this->guessColumn(); diff --git a/src/Filters/WhereNull.php b/src/Filters/WhereNull.php index f6cbd79..112cf06 100644 --- a/src/Filters/WhereNull.php +++ b/src/Filters/WhereNull.php @@ -32,7 +32,7 @@ class WhereNull implements Filter * * @return static */ - public static function make(string $name, string $column = null): self + public static function make(string $name, ?string $column = null): self { return new static($name, $column); } @@ -42,7 +42,7 @@ public static function make(string $name, string $column = null): self * * @param string|null $column */ - public function __construct(string $name, string $column = null) + public function __construct(string $name, ?string $column = null) { $this->name = $name; $this->column = $column ?: $this->guessColumn(); diff --git a/src/ProxySchema.php b/src/ProxySchema.php index bd16ed6..4a3afb3 100644 --- a/src/ProxySchema.php +++ b/src/ProxySchema.php @@ -55,7 +55,7 @@ public function isModel($model): bool * @param Model|null $model * @return ProxyContract */ - public function newProxy(Model $model = null): ProxyContract + public function newProxy(?Model $model = null): ProxyContract { $proxyClass = $this->model(); diff --git a/src/QueryBuilder/Applicators/FilterApplicator.php b/src/QueryBuilder/Applicators/FilterApplicator.php index 1eb462b..cbb1b0a 100644 --- a/src/QueryBuilder/Applicators/FilterApplicator.php +++ b/src/QueryBuilder/Applicators/FilterApplicator.php @@ -50,7 +50,7 @@ class FilterApplicator * @param SchemaRelation|null $relation * @return static */ - public static function make(Schema $schema, SchemaRelation $relation = null): self + public static function make(Schema $schema, ?SchemaRelation $relation = null): self { return new self($schema, $relation); } diff --git a/src/QueryBuilder/JsonApiBuilder.php b/src/QueryBuilder/JsonApiBuilder.php index a7532fd..103c34f 100644 --- a/src/QueryBuilder/JsonApiBuilder.php +++ b/src/QueryBuilder/JsonApiBuilder.php @@ -93,7 +93,7 @@ class JsonApiBuilder * @param Builder|Relation $query * @param SchemaRelation|null $relation */ - public function __construct(Container $schemas, Schema $schema, $query, SchemaRelation $relation = null) + public function __construct(Container $schemas, Schema $schema, $query, ?SchemaRelation $relation = null) { if ($query instanceof Relation && !$relation) { throw new InvalidArgumentException('Expecting a schema relation when querying an Eloquent relation.'); diff --git a/src/Resources/Relation.php b/src/Resources/Relation.php index 75f2253..1c48bc3 100644 --- a/src/Resources/Relation.php +++ b/src/Resources/Relation.php @@ -35,7 +35,7 @@ class Relation extends BaseRelation * @param string|null $key * @return string */ - public static function withCount(string $key = null): string + public static function withCount(?string $key = null): string { if (empty($key)) { return self::$countAs; diff --git a/src/Sorting/SortColumn.php b/src/Sorting/SortColumn.php index e6e1ebb..208b3fc 100644 --- a/src/Sorting/SortColumn.php +++ b/src/Sorting/SortColumn.php @@ -34,7 +34,7 @@ class SortColumn implements SortField * @param string|null $column * @return static */ - public static function make(string $fieldName, string $column = null): self + public static function make(string $fieldName, ?string $column = null): self { return new self($fieldName, $column); } @@ -45,7 +45,7 @@ public static function make(string $fieldName, string $column = null): self * @param string $fieldName * @param string|null $column */ - public function __construct(string $fieldName, string $column = null) + public function __construct(string $fieldName, ?string $column = null) { $this->fieldName = $fieldName; $this->column = $column ?? $this->guessColumn(); diff --git a/src/Sorting/SortCountable.php b/src/Sorting/SortCountable.php index fe9876f..49959aa 100644 --- a/src/Sorting/SortCountable.php +++ b/src/Sorting/SortCountable.php @@ -40,7 +40,7 @@ class SortCountable implements SortField * @param string|null $key * @return static */ - public static function make(Schema $schema, string $fieldName, string $key = null): self + public static function make(Schema $schema, string $fieldName, ?string $key = null): self { return new self($schema, $fieldName, $key); } @@ -52,7 +52,7 @@ public static function make(Schema $schema, string $fieldName, string $key = nul * @param string $fieldName * @param string|null $key */ - public function __construct(Schema $schema, string $fieldName, string $key = null) + public function __construct(Schema $schema, string $fieldName, ?string $key = null) { $this->schema = $schema; $this->fieldName = $fieldName; diff --git a/src/Sorting/SortWithCount.php b/src/Sorting/SortWithCount.php index 1c71346..1eacc68 100644 --- a/src/Sorting/SortWithCount.php +++ b/src/Sorting/SortWithCount.php @@ -45,7 +45,7 @@ class SortWithCount implements SortField * @param string|null $key * @return static */ - public static function make(string $fieldName, string $key = null): self + public static function make(string $fieldName, ?string $key = null): self { return new self($fieldName, $key); } @@ -56,7 +56,7 @@ public static function make(string $fieldName, string $key = null): self * @param string $relationName * @param string|null $key */ - public function __construct(string $relationName, string $key = null) + public function __construct(string $relationName, ?string $key = null) { $this->relationName = $relationName; $this->key = $key ?? $relationName; diff --git a/tests/app/Models/UserAccount.php b/tests/app/Models/UserAccount.php index b0cb37e..3006472 100644 --- a/tests/app/Models/UserAccount.php +++ b/tests/app/Models/UserAccount.php @@ -24,7 +24,7 @@ class UserAccount extends Proxy implements Scope * * @param User|null $user */ - public function __construct(User $user = null) + public function __construct(?User $user = null) { parent::__construct($user ?: new User()); }