mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Add static to isBuiltin() check in ide-helper:models (#1541)
* Add `\\static` as check For some reason, the `static` keyword as a return type, does not return `isBuiltin()` === true, so a `\\` is added. We need to manually add it to the built in check. * Update ModelsCommand.php * Add tests * Add CHANGELOG.md entry --------- Co-authored-by: Markus Podar <[email protected]> Co-authored-by: Barry vd. Heuvel <[email protected]>
This commit is contained in:
co-authored by
Markus Podar
Barry vd. Heuvel
parent
f7a3dc8ff2
commit
f5759e2001
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix return value of query scopes from parent class [#1366 / sforward](https://github.com/barryvdh/laravel-ide-helper/pull/1366)
|
- Fix return value of query scopes from parent class [#1366 / sforward](https://github.com/barryvdh/laravel-ide-helper/pull/1366)
|
||||||
|
- Add static to isBuiltin() check in ide-helper:models [#1541 / bram-pkg](https://github.com/barryvdh/laravel-ide-helper/pull/1541)
|
||||||
- Fix for getSomethingAttribute functions which return a collection with type templating in the phpDoc. [#1567 / stefanScrumble](https://github.com/barryvdh/laravel-ide-helper/pull/1567)
|
- Fix for getSomethingAttribute functions which return a collection with type templating in the phpDoc. [#1567 / stefanScrumble](https://github.com/barryvdh/laravel-ide-helper/pull/1567)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -1633,7 +1633,7 @@ class ModelsCommand extends Command
|
|||||||
protected function getReflectionNamedType(ReflectionNamedType $paramType): string
|
protected function getReflectionNamedType(ReflectionNamedType $paramType): string
|
||||||
{
|
{
|
||||||
$parameterName = $paramType->getName();
|
$parameterName = $paramType->getName();
|
||||||
if (!$paramType->isBuiltin()) {
|
if (!$paramType->isBuiltin() && $paramType->getName() !== 'static') {
|
||||||
$parameterName = '\\' . $parameterName;
|
$parameterName = '\\' . $parameterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CustomCasterWithStaticReturnType implements CastsAttributes
|
||||||
|
{
|
||||||
|
public function get(Model $model, string $key, mixed $value, array $attributes): static
|
||||||
|
{
|
||||||
|
// TODO: Implement get() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set(Model $model, string $key, mixed $value, array $attributes): array
|
||||||
|
{
|
||||||
|
// TODO: Implement set() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Cas
|
|||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveDocblockReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveDocblockReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithReturnType;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithReturnType;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithStaticReturnType;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithStaticDocblockReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithStaticDocblockReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithThisDocblockReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithThisDocblockReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\InboundAttributeCaster;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\InboundAttributeCaster;
|
||||||
@@ -26,6 +27,7 @@ class CustomCast extends Model
|
|||||||
{
|
{
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'casted_property_with_return_type' => CustomCasterWithReturnType::class,
|
'casted_property_with_return_type' => CustomCasterWithReturnType::class,
|
||||||
|
'casted_property_with_static_return_type' => CustomCasterWithStaticReturnType::class,
|
||||||
'casted_property_with_return_docblock' => CustomCasterWithDocblockReturn::class,
|
'casted_property_with_return_docblock' => CustomCasterWithDocblockReturn::class,
|
||||||
'casted_property_with_return_docblock_fqn' => CustomCasterWithDocblockReturnFqn::class,
|
'casted_property_with_return_docblock_fqn' => CustomCasterWithDocblockReturnFqn::class,
|
||||||
'casted_property_with_return_primitive' => CustomCasterWithPrimitiveReturn::class,
|
'casted_property_with_return_primitive' => CustomCasterWithPrimitiveReturn::class,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Cas
|
|||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveDocblockReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveDocblockReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithPrimitiveReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithReturnType;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithReturnType;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CustomCasterWithStaticReturnType;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithStaticDocblockReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithStaticDocblockReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithThisDocblockReturn;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\ExtendedSelfCastingCasterWithThisDocblockReturn;
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\InboundAttributeCaster;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\InboundAttributeCaster;
|
||||||
@@ -39,6 +40,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* @property ExtendedSelfCastingCasterWithStaticDocblockReturn $extended_casted_property_with_static_return_docblock
|
* @property ExtendedSelfCastingCasterWithStaticDocblockReturn $extended_casted_property_with_static_return_docblock
|
||||||
* @property ExtendedSelfCastingCasterWithThisDocblockReturn $extended_casted_property_with_this_return_docblock
|
* @property ExtendedSelfCastingCasterWithThisDocblockReturn $extended_casted_property_with_this_return_docblock
|
||||||
* @property SelfCastingCasterWithStaticDocblockReturn $casted_property_with_static_return_docblock_and_param
|
* @property SelfCastingCasterWithStaticDocblockReturn $casted_property_with_static_return_docblock_and_param
|
||||||
|
* @property CustomCasterWithStaticReturnType $casted_property_with_static_return_type
|
||||||
* @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_castable
|
||||||
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_anonymous_cast
|
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_anonymous_cast
|
||||||
* @property CastableWithoutReturnType $casted_property_without_return_type
|
* @property CastableWithoutReturnType $casted_property_without_return_type
|
||||||
@@ -67,6 +69,7 @@ class CustomCast extends Model
|
|||||||
{
|
{
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'casted_property_with_return_type' => CustomCasterWithReturnType::class,
|
'casted_property_with_return_type' => CustomCasterWithReturnType::class,
|
||||||
|
'casted_property_with_static_return_type' => CustomCasterWithStaticReturnType::class,
|
||||||
'casted_property_with_return_docblock' => CustomCasterWithDocblockReturn::class,
|
'casted_property_with_return_docblock' => CustomCasterWithDocblockReturn::class,
|
||||||
'casted_property_with_return_docblock_fqn' => CustomCasterWithDocblockReturnFqn::class,
|
'casted_property_with_return_docblock_fqn' => CustomCasterWithDocblockReturnFqn::class,
|
||||||
'casted_property_with_return_primitive' => CustomCasterWithPrimitiveReturn::class,
|
'casted_property_with_return_primitive' => CustomCasterWithPrimitiveReturn::class,
|
||||||
|
|||||||
Reference in New Issue
Block a user