From 81d5b223ff067a1f38e14c100997e153b837fe4a Mon Sep 17 00:00:00 2001 From: Bartlomiej Kwarcinski Date: Sat, 4 Feb 2023 14:56:40 +0100 Subject: [PATCH] Fix Castables issue #1312 (#1388) * Return Castable class if failed to detect it from return types * fix-style * Add CHANGELOG.md entry --- CHANGELOG.md | 1 + src/Console/ModelsCommand.php | 2 +- .../LaravelCustomCasts/__snapshots__/Test__test__1.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd51f26..ff7ef1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - Fix issue where \Eloquent is not included when using write_mixin [#1352 / Jefemy](https://github.com/barryvdh/laravel-ide-helper/pull/1352) - Fix model factory method arguments for Laravel >= 9 [#1361 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1361) - Improve return type of mock helper methods in tests [#1405 / bentleyo](https://github.com/barryvdh/laravel-ide-helper/pull/1405) +- Fix Castable class if failed to detect it from return types [#1388 / kwarcu](https://github.com/barryvdh/laravel-ide-helper/pull/1388) ### Added - Added Laravel 10 support [#1407 / lptn](https://github.com/barryvdh/laravel-ide-helper/pull/1407) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 30249d4..64ee077 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -1347,7 +1347,7 @@ class ModelsCommand extends Command return $this->getReturnTypeFromReflection($methodReflection) ?? $this->getReturnTypeFromDocBlock($methodReflection, $reflection) ?? - 'mixed'; + $type; } /** diff --git a/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php index 0438577..ee2c02f 100644 --- a/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test__1.php @@ -40,7 +40,7 @@ use Illuminate\Database\Eloquent\Model; * @property SelfCastingCasterWithStaticDocblockReturn $casted_property_with_static_return_docblock_and_param * @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_castable * @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_anonymous_cast - * @property mixed $casted_property_without_return_type + * @property CastableWithoutReturnType $casted_property_without_return_type * @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $cast_without_property * @property mixed $cast_inbound_attribute * @method static \Illuminate\Database\Eloquent\Builder|CustomCast newModelQuery()