Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasweiss committed Jan 24, 2025
1 parent 4a1ccd2 commit 4066318
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Lazy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Closure;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Traits\Macroable;
use Inertia\DeferProp;
use Spatie\LaravelData\Support\Lazy\ClosureLazy;
use Spatie\LaravelData\Support\Lazy\ConditionalLazy;
use Spatie\LaravelData\Support\Lazy\DefaultLazy;
Expand Down Expand Up @@ -39,7 +38,7 @@ public static function inertia(Closure $value): InertiaLazy
return new InertiaLazy($value);
}

public static function inertiaDeferred(DeferProp $value): InertiaDeferred
public static function inertiaDeferred(mixed $value): InertiaDeferred
{
return new InertiaDeferred($value);
}
Expand Down
8 changes: 6 additions & 2 deletions src/Support/Lazy/InertiaDeferred.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
class InertiaDeferred extends ConditionalLazy
{
public function __construct(
DeferProp $value,
mixed $value,
) {
parent::__construct(fn () => true, fn () => $value());
$callback = is_a($value, DeferProp::class)
? fn () => $value()
: fn () => new DeferProp($value);

parent::__construct(fn () => true, $callback);
}

public function resolve(): DeferProp
Expand Down

0 comments on commit 4066318

Please sign in to comment.