Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ "ubuntu-latest" ]
php-versions: [ "8.2" ]
php-versions: [ "8.2", "8.3", "8.4" ]
phpunit-versions: [ "latest" ]

steps:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ebsp/resting",
"description": "Simple REST library for Laravel",
"require": {
"php": "^8.2",
"php": "^8.2|^8.3|^8.4",
"laravel/framework": "^8.0|^9.0|^10.0|^11.0|^12.0",
"ext-json": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion src/DynamicResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct()
$this->fields = collect();
}

public function fields(array $filter = null, array $rename = null, bool $requireFilled = false): Collection
public function fields(?array $filter = null, ?array $rename = null, bool $requireFilled = false): Collection
{
return $this->transformFields(
$this->fields->collect(),
Expand Down
14 changes: 7 additions & 7 deletions src/Fields/ArrayField.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function set($value): static
return parent::set($value);
}

public function ofStrings(callable $config = null, ?bool $nullable = null): static
public function ofStrings(?callable $config = null, ?bool $nullable = null): static
{
if ($nullable !== null) {
$this->validator->allowNullElements(state: $nullable);
Expand All @@ -90,7 +90,7 @@ public function ofStrings(callable $config = null, ?bool $nullable = null): stat
return $this->of($validator, $parser);
}

public function ofIntegers(callable $config = null, ?bool $nullable = null): static
public function ofIntegers(?callable $config = null, ?bool $nullable = null): static
{
if ($nullable !== null) {
$this->validator->allowNullElements(state: $nullable);
Expand All @@ -106,7 +106,7 @@ public function ofIntegers(callable $config = null, ?bool $nullable = null): sta
return $this->of($validator, $parser);
}

public function ofNumbers(callable $config = null, ?bool $nullable = null): static
public function ofNumbers(?callable $config = null, ?bool $nullable = null): static
{
if ($nullable !== null) {
$this->validator->allowNullElements(state: $nullable);
Expand All @@ -122,7 +122,7 @@ public function ofNumbers(callable $config = null, ?bool $nullable = null): stat
return $this->of($validator, $parser);
}

public function ofBooleans(callable $config = null, ?bool $nullable = null): static
public function ofBooleans(?callable $config = null, ?bool $nullable = null): static
{
if ($nullable !== null) {
$this->validator->allowNullElements(state: $nullable);
Expand All @@ -138,7 +138,7 @@ public function ofBooleans(callable $config = null, ?bool $nullable = null): sta
return $this->of($validator, $parser);
}

public function ofTimes(callable $config = null, ?bool $nullable = null): static
public function ofTimes(?callable $config = null, ?bool $nullable = null): static
{
if ($nullable !== null) {
$this->validator->allowNullElements(state: $nullable);
Expand All @@ -154,7 +154,7 @@ public function ofTimes(callable $config = null, ?bool $nullable = null): static
return $this->of($validator, $parser);
}

public function ofArrays(callable $config = null, ?bool $nullable = null): static
public function ofArrays(?callable $config = null, ?bool $nullable = null): static
{
if ($nullable !== null) {
$this->validator->allowNullElements(state: $nullable);
Expand All @@ -170,7 +170,7 @@ public function ofArrays(callable $config = null, ?bool $nullable = null): stati
return $this->of($validator, $parser);
}

public function ofCarbons(callable $config = null, ?bool $nullable = null): static
public function ofCarbons(?callable $config = null, ?bool $nullable = null): static
{
if ($nullable !== null) {
$this->validator->allowNullElements(state: $nullable);
Expand Down
6 changes: 3 additions & 3 deletions src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function nullable(bool|Predicate $state = true): static
* @return $this
* @throws ValidationException When the default value does not pass validation.
*/
public function omittedDefault(mixed $value, Predicate $predicate = null): static
public function omittedDefault(mixed $value, ?Predicate $predicate = null): static
{
$this->validateValue($value);

Expand Down Expand Up @@ -123,7 +123,7 @@ public function omittedDefault(mixed $value, Predicate $predicate = null): stati
* @throws ValidationException When the default value does not pass validation.
* @see Field::omittedDefault() Another way to register default values for fields.
*/
public function nullDefault(mixed $value, Predicate $predicate = null): static
public function nullDefault(mixed $value, ?Predicate $predicate = null): static
{
$this->validateValue($value);

Expand Down Expand Up @@ -152,7 +152,7 @@ public function nullDefault(mixed $value, Predicate $predicate = null): static
* @see Field::omittedDefault() Another way to register default values for fields.
* @see Field::nullDefault() Another way to register default values for the field.
*/
public function withDefault(mixed $value, Predicate $predicate = null): static
public function withDefault(mixed $value, ?Predicate $predicate = null): static
{
$this->required(false);
$this->nullable();
Expand Down
6 changes: 3 additions & 3 deletions src/Fields/ResourceArrayField.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,17 @@ public function offsetExists($offset): bool
return array_key_exists($offset, $this->value);
}

public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->value[$offset];
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->value[$offset] = $value;
}

public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->value[$offset]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function only(Field ...$fields): static
return $this;
}

public function fields(array $filter = null, array $rename = null, bool $requireFilled = false): Collection
public function fields(?array $filter = null, ?array $rename = null, bool $requireFilled = false): Collection
{
$fields = collect(get_object_vars($this))->filter(function ($value) use ($requireFilled) {
return $value instanceof Field && $value->isEnabled();
Expand Down Expand Up @@ -240,7 +240,7 @@ protected function values(
})->toArray();
}

public function toArray(array $filter = null, array $rename = null, bool $requireFilled = false): array
public function toArray(?array $filter = null, ?array $rename = null, bool $requireFilled = false): array
{
return $this->values(
format: false,
Expand All @@ -260,7 +260,7 @@ public function copy(): static
return new static();
}

public function toResponseArray(array $filter = null, array $rename = null, bool $requireFilled = false): array
public function toResponseArray(?array $filter = null, ?array $rename = null, bool $requireFilled = false): array
{
$array = $this->values(
format: true,
Expand All @@ -284,7 +284,7 @@ public function toResponseArray(array $filter = null, array $rename = null, bool
});
}

public function toResponseObject(array $filter = null, array $rename = null, bool $requireFilled = false): stdClass
public function toResponseObject(?array $filter = null, ?array $rename = null, bool $requireFilled = false): stdClass
{
return (object)$this->toResponseArray(
filter: $filter,
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Laravel/ResourceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function from(Collection $collection): static
return $this;
}

public static function fromCollection(Collection $collection, Transformer $transformer = null): ResourceCollection
public static function fromCollection(Collection $collection, ?Transformer $transformer = null): ResourceCollection
{
return (new static)->use($transformer)->from(
$collection
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Laravel/UsesResting.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private function handleVariadicParameters(string $method, array $parameters): ar
return $values;
}

public function transform($data, Transformer $transformer = null)
public function transform($data, ?Transformer $transformer = null)
{
if (!$transformer) {
$transformer = new BaseTransformer;
Expand Down
4 changes: 2 additions & 2 deletions src/UnionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function setFieldsFromCollection(Collection $collection): static
}
}

public function toArray(array $filter = null, array $rename = null, bool $requireFilled = false): array
public function toArray(?array $filter = null, ?array $rename = null, bool $requireFilled = false): array
{
return $this->delegate(__FUNCTION__, func_get_args());
}
Expand All @@ -77,7 +77,7 @@ public function toJson($options = 0): bool|string
return $this->delegate(__FUNCTION__, func_get_args());
}

public function toResponseArray(array $filter = null, array $rename = null, bool $requireFilled = false): array
public function toResponseArray(?array $filter = null, ?array $rename = null, bool $requireFilled = false): array
{
return $this->delegate(__FUNCTION__, func_get_args());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/Secondary/Numeric/NumericValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function positive(): static
return $this;
}

public function decimalCount(int $min = null, int $max = null): static
public function decimalCount(?int $min = null, ?int $max = null): static
{
if ($min !== null || $max !== null) {
$this->getSupportsSecondaryValidation()->withValidator(new DecimalCountValidator(
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/Secondary/String/StringValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function matches(string $pattern): static
return $this;
}

public function digits(int $length = null): static
public function digits(?int $length = null): static
{
$this->getSupportsSecondaryValidation()->withValidator(
new StringRegexValidator('/^[0-9]+$/')
Expand Down
2 changes: 1 addition & 1 deletion tests/UnionResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function testUnionResourceArrayField()
$this->assertEquals('a_value', $return[0]->a->get());
$this->assertEquals('a_value', $return[0]->value->get());

assert($return[0] instanceof UnionResourceB);
assert($return[1] instanceof UnionResourceB);
$this->assertEquals('b_value', $return[1]->b->get());
$this->assertEquals('b_value', $return[1]->value->get());
}
Expand Down
Loading