diff --git a/CHANGELOG.md b/CHANGELOG.md index dc87c01..143651e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. ### Added - Add support of variadic parameters in `ide-helper:models` [\#1234 / shaffe-fr](https://github.com/barryvdh/laravel-ide-helper/pull/1234) +- Add support of custom casts without properties [\#1267 / sparclex](https://github.com/barryvdh/laravel-ide-helper/pull/1267) ### Changed - Move default models helper filename to config [\#1241 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1241) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 6873df7..2419061 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -392,6 +392,7 @@ class ModelsCommand extends Command // the `$type` until the `:` $type = strtok($type, ':'); $realType = class_exists($type) ? ('\\' . $type) : 'mixed'; + $this->setProperty($name, null, true, true); break; } diff --git a/tests/Console/ModelsCommand/LaravelCustomCasts/Models/CustomCast.php b/tests/Console/ModelsCommand/LaravelCustomCasts/Models/CustomCast.php index 6b7bf2b..c8876b8 100644 --- a/tests/Console/ModelsCommand/LaravelCustomCasts/Models/CustomCast.php +++ b/tests/Console/ModelsCommand/LaravelCustomCasts/Models/CustomCast.php @@ -34,5 +34,6 @@ class CustomCast extends Model 'extended_casted_property_with_static_return_docblock' => ExtendedSelfCastingCasterWithStaticDocblockReturn::class, 'extended_casted_property_with_this_return_docblock' => ExtendedSelfCastingCasterWithThisDocblockReturn::class, 'casted_property_with_static_return_docblock_and_param' => SelfCastingCasterWithStaticDocblockReturn::class . ':param', + 'cast_without_property' => CustomCasterWithReturnType::class, ]; } diff --git a/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php index a108dbc..2bc8716 100644 --- a/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php @@ -34,6 +34,7 @@ use Illuminate\Database\Eloquent\Model; * @property ExtendedSelfCastingCasterWithStaticDocblockReturn $extended_casted_property_with_static_return_docblock * @property ExtendedSelfCastingCasterWithThisDocblockReturn $extended_casted_property_with_this_return_docblock * @property SelfCastingCasterWithStaticDocblockReturn $casted_property_with_static_return_docblock_and_param + * @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $cast_without_property * @method static \Illuminate\Database\Eloquent\Builder|CustomCast newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|CustomCast newQuery() * @method static \Illuminate\Database\Eloquent\Builder|CustomCast query() @@ -68,5 +69,6 @@ class CustomCast extends Model 'extended_casted_property_with_static_return_docblock' => ExtendedSelfCastingCasterWithStaticDocblockReturn::class, 'extended_casted_property_with_this_return_docblock' => ExtendedSelfCastingCasterWithThisDocblockReturn::class, 'casted_property_with_static_return_docblock_and_param' => SelfCastingCasterWithStaticDocblockReturn::class . ':param', + 'cast_without_property' => CustomCasterWithReturnType::class, ]; }