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:
Matthew Hailwood
2020-12-04 07:33:45 +01:00
committed by GitHub
parent b4138e5122
commit b3a79fe6c1
9 changed files with 118 additions and 4 deletions
@@ -19,6 +19,11 @@ class CustomCastsTable extends Migration
$table->string('casted_property_with_return_nullable_primitive');
$table->string('casted_property_without_return');
$table->string('casted_property_with_param');
$table->string('casted_property_with_static_return_docblock');
$table->string('casted_property_with_this_return_docblock');
$table->string('extended_casted_property_with_static_return_docblock');
$table->string('extended_casted_property_with_this_return_docblock');
$table->string('casted_property_with_static_return_docblock_and_param');
});
}
}