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
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
laravel: [12.*]
stability: [prefer-stable]
include:
- laravel: 12.*
testbench: 10.*
carbon: ^3.8.4
- laravel: 11.*
testbench: 9.*
carbon: 2.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"larastan/larastan": "^3.0",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^8.1",
"orchestra/testbench": "^10.0",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^4.0",
"pestphp/pest-plugin-arch": "^4.0",
"pestphp/pest-plugin-laravel": "^4.0",
Expand Down
545 changes: 232 additions & 313 deletions composer.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@
privatization: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true
);
12 changes: 6 additions & 6 deletions src/CustomFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function useCustomFieldModel(string $model): static
*/
public static function valueModel(): string
{
return static::$valueModel;
return self::$valueModel;
}

/**
Expand All @@ -88,7 +88,7 @@ public static function newValueModel(): mixed
*/
public static function useValueModel(string $model): static
{
static::$valueModel = $model;
self::$valueModel = $model;

return new self;
}
Expand All @@ -100,7 +100,7 @@ public static function useValueModel(string $model): static
*/
public static function optionModel(): string
{
return static::$optionModel;
return self::$optionModel;
}

/**
Expand All @@ -118,7 +118,7 @@ public static function newOptionModel(): mixed
*/
public static function useOptionModel(string $model): static
{
static::$optionModel = $model;
self::$optionModel = $model;

return new self;
}
Expand All @@ -130,7 +130,7 @@ public static function useOptionModel(string $model): static
*/
public static function sectionModel(): string
{
return static::$sectionModel;
return self::$sectionModel;
}

/**
Expand All @@ -148,7 +148,7 @@ public static function newSectionModel(): mixed
*/
public static function useSectionModel(string $model): static
{
static::$sectionModel = $model;
self::$sectionModel = $model;

return new self;
}
Expand Down
6 changes: 1 addition & 5 deletions src/Data/CustomFieldSectionSettingsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@
use Spatie\LaravelData\Mappers\SnakeCaseMapper;

#[MapName(SnakeCaseMapper::class)]
class CustomFieldSectionSettingsData extends Data
{
public function __construct(
) {}
}
class CustomFieldSectionSettingsData extends Data {}
4 changes: 2 additions & 2 deletions src/EntitySystem/EntityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function sortedByLabel(): static
*/
public function toOptions(bool $usePlural = true): array
{
return $this->mapWithKeys(fn (EntityConfigurationData $entity) => [
return $this->mapWithKeys(fn (EntityConfigurationData $entity): array => [
$entity->getAlias() => $usePlural
? $entity->getLabelPlural()
: $entity->getLabelSingular(),
Expand All @@ -171,7 +171,7 @@ public function toOptions(bool $usePlural = true): array
*/
public function toDetailedOptions(): array
{
return $this->mapWithKeys(fn (EntityConfigurationData $entity) => [
return $this->mapWithKeys(fn (EntityConfigurationData $entity): array => [
$entity->getAlias() => [
'label' => $entity->getLabelPlural(),
'icon' => $entity->getIcon(),
Expand Down
2 changes: 1 addition & 1 deletion src/Enums/FieldDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getCompatibleOperators(): array
public function getCompatibleOperatorOptions(): array
{
return collect($this->getCompatibleOperators())
->mapWithKeys(fn (VisibilityOperator $operator) => [$operator->value => $operator->getLabel()])
->mapWithKeys(fn (VisibilityOperator $operator): array => [$operator->value => $operator->getLabel()])
->toArray();
}
}
2 changes: 1 addition & 1 deletion src/Enums/ValidationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function getDescription(): string
*/
private static function isEmptyRule(mixed $rule): bool
{
return $rule === null || $rule === '' || $rule === '0';
return in_array($rule, [null, '', '0'], true);
}

public static function hasParameterForRule(?string $rule): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Enums/VisibilityOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private function evaluateIsEmpty(mixed $fieldValue): bool
public static function options(): array
{
return collect(self::cases())
->mapWithKeys(fn (self $operator) => [$operator->value => $operator->getLabel()])
->mapWithKeys(fn (self $operator): array => [$operator->value => $operator->getLabel()])
->toArray();
}

Expand Down
8 changes: 3 additions & 5 deletions src/Filament/Integration/Base/AbstractFormComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@ private function applyVisibility(
$allFields
);

return $jsExpression !== null &&
$jsExpression !== '' &&
$jsExpression !== '0'
? $field->live()->visibleJs($jsExpression)
: $field;
return in_array($jsExpression, [null, '', '0'], true)
? $field
: $field->live()->visibleJs($jsExpression);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Integration/Builders/InfolistBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function values(null|(Model&HasCustomFields) $model = null): Collection

$createField = fn (CustomField $customField) => $fieldInfolistsFactory->create($customField)
->hiddenLabel($this->hiddenLabels)
->when($this->visibleWhenFilled, fn (Entry $field): Entry => $field->visible(fn (mixed $state) => filled($state)));
->when($this->visibleWhenFilled, fn (Entry $field): Entry => $field->visible(fn (mixed $state): bool => filled($state)));

$getVisibleFields = fn (CustomFieldSection $section) => $backendVisibilityService
->getVisibleFields($this->model, $section->fields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ protected function createOptions(
): void {
$customField->options()->createMany(
collect($options)
->map(function (mixed $value, mixed $key) {
->map(function (mixed $value, mixed $key): array {
$data = [
'name' => $value,
'sort_order' => $key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private function getAvailableRuleOptions(Get $get): array
) && $rule->value !== $currentRuleName
)
->mapWithKeys(
fn (ValidationRule $rule) => [
fn (ValidationRule $rule): array => [
$rule->value => $rule->getLabel(),
]
)
Expand Down Expand Up @@ -249,7 +249,7 @@ private function handleRuleChange(

$set('parameters', []);

if ($state === null || $state === '' || $state === '0') {
if (in_array($state, [null, '', '0'], true)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ private function getFieldTypeData(Get $get): ?object
}

return rescue(
fn () => CustomFieldsType::getFieldType($field->type),
null
fn () => CustomFieldsType::getFieldType($field->type)
);
}

Expand All @@ -356,7 +355,7 @@ private function getCustomField(string $fieldCode, Get $get): ?CustomField
->forMorphEntity($entityType)
->where('code', $fieldCode)
->first();
}, null);
});
}

private function getEntityType(Get $get): ?string
Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Management/Pages/CustomFieldsManagementPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function sections(): Collection
#[Computed]
public function currentEntityLabel(): string
{
if ($this->currentEntityType === null || $this->currentEntityType === '' || $this->currentEntityType === '0') {
if (in_array($this->currentEntityType, [null, '', '0'], true)) {
return '';
}

Expand All @@ -79,7 +79,7 @@ public function currentEntityLabel(): string
#[Computed]
public function currentEntityIcon(): string
{
if ($this->currentEntityType === null || $this->currentEntityType === '' || $this->currentEntityType === '0') {
if (in_array($this->currentEntityType, [null, '', '0'], true)) {
return 'heroicon-o-document';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CustomField extends Model
use HasFieldType;

/**
* @var array<string>|bool
* @var array<string>
*/
protected $guarded = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Models/CustomFieldOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function name(): Attribute
{
return Attribute::make(
get: function (?string $value) {
if ($value === null || $value === '' || $value === '0') {
if (in_array($value, [null, '', '0'], true)) {
return $value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/CustomFieldSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CustomFieldSection extends Model
use HasFactory;

/**
* @var array<string>|bool
* @var array<string>
*/
protected $guarded = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/EntityServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private function registerEntities(EntityManager $manager): void
return;
}

$manager->register(function () use ($entities) {
$manager->register(function () use ($entities): array {
$configurations = [];

foreach ($entities as $alias => $config) {
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Visibility/FrontendVisibilityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function buildCondition(
$targetField
);

if ($expression === null || $expression === '' || $expression === '0') {
if (in_array($expression, [null, '', '0'], true)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@
})->with([
'text field min length' => ['text', 'a', 'min:3'],
'number field must be numeric' => ['number', 'not-a-number', 'numeric'],
'date field must be valid date' => ['date', 'invalid-date', 'date'],
]);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected function defineEnvironment($app): void

// Fix Spatie Laravel Data configuration for testing
config()->set('data.throw_when_max_depth_reached', false);
config()->set('data.max_transformation_depth', null);
config()->set('data.max_transformation_depth');
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config()->set() call is missing its second argument. The value parameter is required to set a configuration value. This line should either provide a value (e.g., null) or be removed if the configuration should not be set.

Suggested change
config()->set('data.max_transformation_depth');
config()->set('data.max_transformation_depth', null);

Copilot uses AI. Check for mistakes.
config()->set('data.validation_strategy', 'only_requests');
}

Expand Down