Skip to content

Commit bd060f6

Browse files
Fix small bug where Lazy classes were hard coded when deciding data type
1 parent f2340be commit bd060f6

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

src/Support/Factories/DataTypeFactory.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
use Spatie\LaravelData\Support\Annotations\DataIterableAnnotationReader;
2323
use Spatie\LaravelData\Support\DataPropertyType;
2424
use Spatie\LaravelData\Support\DataType;
25-
use Spatie\LaravelData\Support\Lazy\ClosureLazy;
26-
use Spatie\LaravelData\Support\Lazy\ConditionalLazy;
27-
use Spatie\LaravelData\Support\Lazy\DefaultLazy;
28-
use Spatie\LaravelData\Support\Lazy\InertiaLazy;
29-
use Spatie\LaravelData\Support\Lazy\RelationalLazy;
3025
use Spatie\LaravelData\Support\Types\IntersectionType;
3126
use Spatie\LaravelData\Support\Types\NamedType;
3227
use Spatie\LaravelData\Support\Types\Storage\AcceptedTypesStorage;
@@ -473,7 +468,7 @@ protected function inferPropertiesForCombinationType(
473468
continue;
474469
}
475470

476-
if ($inferForProperty && in_array($name, [Lazy::class, DefaultLazy::class, ClosureLazy::class, ConditionalLazy::class, RelationalLazy::class, InertiaLazy::class])) {
471+
if ($inferForProperty && ($name === Lazy::class || is_subclass_of($name, Lazy::class))) {
477472
$lazyType = $name;
478473

479474
continue;

tests/Datasets/RulesDataset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function fixature(
105105
ValidationRule $attribute,
106106
object|string|array $expected,
107107
object|string|null $expectCreatedAttribute = null,
108-
string $exception = null
108+
?string $exception = null
109109
): array {
110110
return [
111111
$attribute,

tests/Support/TypeScriptTransformer/DataTypeScriptTransformerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use Spatie\TypeScriptTransformer\Attributes\Optional as TypeScriptOptional;
2424
use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig;
2525

26-
function assertMatchesSnapshot($actual, Driver $driver = null): void
26+
function assertMatchesSnapshot($actual, ?Driver $driver = null): void
2727
{
2828
baseAssertMatchesSnapshot(str_replace('\\r\\n', '\\n', $actual), $driver);
2929
}

0 commit comments

Comments
 (0)