diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index d7ad3f0..578991c 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -562,7 +562,7 @@ class ModelsCommand extends Command sort($methods); foreach ($methods as $method) { $reflection = new \ReflectionMethod($model, $method); - $type = $this->getReturnType($reflection); + $type = $this->getReturnTypeFromReflection($reflection); $isAttribute = is_a($type, '\Illuminate\Database\Eloquent\Casts\Attribute', true); if ( Str::startsWith($method, 'get') && Str::endsWith( diff --git a/tests/Console/ModelsCommand/Attributes/Models/Simple.php b/tests/Console/ModelsCommand/Attributes/Models/Simple.php index 6457000..0d1eff8 100644 --- a/tests/Console/ModelsCommand/Attributes/Models/Simple.php +++ b/tests/Console/ModelsCommand/Attributes/Models/Simple.php @@ -20,4 +20,24 @@ class Simple extends Model } ); } + + /** + * ide-helper does not recognize this method being an Attribute + * because the method has no actual return type; + * phpdoc is ignored here deliberately due to performance reasons and also + * isn't supported by Laravel itself. + * + * @return \Illuminate\Database\Eloquent\Casts\Attribute + */ + public function notAnAttribute() + { + return new Attribute( + function (?string $value): ?string { + return $value; + }, + function (?string $value): ?string { + return $value; + } + ); + } } diff --git a/tests/Console/ModelsCommand/Attributes/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/Attributes/__snapshots__/Test__test__1.php index 7e8fcd4..eabeffc 100644 --- a/tests/Console/ModelsCommand/Attributes/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/Attributes/__snapshots__/Test__test__1.php @@ -31,4 +31,24 @@ class Simple extends Model } ); } + + /** + * ide-helper does not recognize this method being an Attribute + * because the method has no actual return type; + * phpdoc is ignored here deliberately due to performance reasons and also + * isn't supported by Laravel itself. + * + * @return \Illuminate\Database\Eloquent\Casts\Attribute + */ + public function notAnAttribute() + { + return new Attribute( + function (?string $value): ?string { + return $value; + }, + function (?string $value): ?string { + return $value; + } + ); + } }