mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Allow casts with a return type of static or this to reference themselves (#1103)
* Allow casts with a return type of static or this to reference themselves
Supports
```php
/**
* @param $model
* @param string $key
* @param $value
* @param array $attributes
* @return static
*/
public function get($model, string $key, $value, array $attributes)
{
return new static($value);
}
```
or
```php
/**
* @param $model
* @param string $key
* @param $value
* @param array $attributes
* @return $this
*/
public function get($model, string $key, $value, array $attributes)
{
return new static($value);
}
```
* Update CHANGELOG.md
This commit is contained in:
@@ -1089,13 +1089,17 @@ class ModelsCommand extends Command
|
||||
|
||||
$methodReflection = new \ReflectionMethod($type, 'get');
|
||||
|
||||
$type = $this->getReturnTypeFromReflection($methodReflection);
|
||||
$reflectionType = $this->getReturnTypeFromReflection($methodReflection);
|
||||
|
||||
if ($type === null) {
|
||||
$type = $this->getReturnTypeFromDocBlock($methodReflection);
|
||||
if ($reflectionType === null) {
|
||||
$reflectionType = $this->getReturnTypeFromDocBlock($methodReflection);
|
||||
}
|
||||
|
||||
if($reflectionType === 'static' || $reflectionType === '$this') {
|
||||
$reflectionType = $type;
|
||||
}
|
||||
|
||||
return $type;
|
||||
return $reflectionType;
|
||||
}
|
||||
|
||||
protected function getTypeInModel(object $model, ?string $type): ?string
|
||||
|
||||
Reference in New Issue
Block a user