Skip to content

Commit 4ad74ba

Browse files
authored
Add weak generics for array type objects (#1621)
1 parent 347483b commit 4ad74ba

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/Console/ModelsCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public function castPropertiesType($model)
426426
break;
427427
case 'array':
428428
case 'json':
429-
$realType = 'array';
429+
$realType = 'array<array-key, mixed>';
430430
break;
431431
case 'object':
432432
$realType = 'object';
@@ -450,10 +450,10 @@ public function castPropertiesType($model)
450450
$realType = '\Carbon\CarbonImmutable';
451451
break;
452452
case 'collection':
453-
$realType = '\Illuminate\Support\Collection';
453+
$realType = '\Illuminate\Support\Collection<array-key, mixed>';
454454
break;
455455
case AsArrayObject::class:
456-
$realType = '\ArrayObject';
456+
$realType = '\ArrayObject<array-key, mixed>';
457457
break;
458458
default:
459459
// In case of an optional custom cast parameter , only evaluate

tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
* @property \Carbon\CarbonImmutable $cast_to_immutable_datetime
2323
* @property int $cast_to_timestamp
2424
* @property mixed $cast_to_encrypted
25-
* @property array $cast_to_encrypted_array
26-
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection
27-
* @property array $cast_to_encrypted_json
25+
* @property array<array-key, mixed> $cast_to_encrypted_array
26+
* @property \Illuminate\Support\Collection<array-key, mixed> $cast_to_encrypted_collection
27+
* @property array<array-key, mixed> $cast_to_encrypted_json
2828
* @property object $cast_to_encrypted_object
2929
* @property \Illuminate\Support\Collection $cast_to_as_collection
3030
* @property \Illuminate\Support\Collection $cast_to_as_enum_collection
31-
* @property \ArrayObject $cast_to_as_array_object
31+
* @property \ArrayObject<array-key, mixed> $cast_to_as_array_object
3232
* @property AdvancedCastCollection $cast_to_as_collection_using
3333
* @property \Illuminate\Support\Collection<int, AdvancedCastEnum> $cast_to_as_enum_collection_of
3434
* @method static \Illuminate\Database\Eloquent\Builder<static>|AdvancedCast newModelQuery()

tests/Console/ModelsCommand/SimpleCasts/__snapshots__/Test__test__1.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
* @property bool $cast_to_bool
2020
* @property bool $cast_to_boolean
2121
* @property object $cast_to_object
22-
* @property array $cast_to_array
23-
* @property array $cast_to_json
24-
* @property \Illuminate\Support\Collection $cast_to_collection
22+
* @property array<array-key, mixed> $cast_to_array
23+
* @property array<array-key, mixed> $cast_to_json
24+
* @property \Illuminate\Support\Collection<array-key, mixed> $cast_to_collection
2525
* @property \Illuminate\Support\Carbon $cast_to_date
2626
* @property \Illuminate\Support\Carbon $cast_to_datetime
2727
* @property \Illuminate\Support\Carbon $cast_to_date_serialization
@@ -34,9 +34,9 @@
3434
* @property \Carbon\CarbonImmutable $cast_to_immutable_datetime_serialization
3535
* @property int $cast_to_timestamp
3636
* @property mixed $cast_to_encrypted
37-
* @property array $cast_to_encrypted_array
38-
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection
39-
* @property array $cast_to_encrypted_json
37+
* @property array<array-key, mixed> $cast_to_encrypted_array
38+
* @property \Illuminate\Support\Collection<array-key, mixed> $cast_to_encrypted_collection
39+
* @property array<array-key, mixed> $cast_to_encrypted_json
4040
* @property object $cast_to_encrypted_object
4141
* @method static \Illuminate\Database\Eloquent\Builder<static>|SimpleCast newModelQuery()
4242
* @method static \Illuminate\Database\Eloquent\Builder<static>|SimpleCast newQuery()

0 commit comments

Comments
 (0)