Skip to content

Commit 28f438d

Browse files
committed
Add support for Attributes without specified type
1 parent 4cc9967 commit 28f438d

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

src/Console/ModelsCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ public function getPropertiesFromMethods($model)
616616
if ($types->has('set')) {
617617
$this->setProperty($name, null, null, true, $comment);
618618
}
619+
620+
if (!$types->hasAny('get', 'set')) {
621+
$this->setProperty($name, null, true, null, $comment);
622+
}
619623
} elseif (
620624
Str::startsWith($methodReflection->getName(), 'set') && Str::endsWith(
621625
$methodReflection->getName(),

tests/Console/ModelsCommand/Attributes/Models/Simple.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public function uppercaseName(): Attribute
2828
});
2929
}
3030

31+
public function lowercaseName(): Attribute
32+
{
33+
return Attribute::get(function () {
34+
return strtolower($this->name);
35+
});
36+
}
37+
3138
/**
3239
* ide-helper does not recognize this method being an Attribute
3340
* because the method has no actual return type;
@@ -47,17 +54,4 @@ function (?string $value): ?string {
4754
}
4855
);
4956
}
50-
51-
/**
52-
* ide-helper does not recognize this method being an Attribute
53-
* because the callable has no specified return type;
54-
*
55-
* @return \Illuminate\Database\Eloquent\Casts\Attribute
56-
*/
57-
public function alsoNotAnAttribute(): Attribute
58-
{
59-
return Attribute::get(function () {
60-
return strtoupper($this->name);
61-
});
62-
}
6357
}

tests/Console/ModelsCommand/Attributes/__snapshots__/Test__test__1.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Attributes\Models\Simple
1212
*
1313
* @property integer $id
14+
* @property-read mixed $lowercase_name
1415
* @property string|null $name
1516
* @property-read string $uppercase_name
1617
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
@@ -40,6 +41,13 @@ public function uppercaseName(): Attribute
4041
});
4142
}
4243

44+
public function lowercaseName(): Attribute
45+
{
46+
return Attribute::get(function () {
47+
return strtolower($this->name);
48+
});
49+
}
50+
4351
/**
4452
* ide-helper does not recognize this method being an Attribute
4553
* because the method has no actual return type;
@@ -59,17 +67,4 @@ function (?string $value): ?string {
5967
}
6068
);
6169
}
62-
63-
/**
64-
* ide-helper does not recognize this method being an Attribute
65-
* because the callable has no specified return type;
66-
*
67-
* @return \Illuminate\Database\Eloquent\Casts\Attribute
68-
*/
69-
public function alsoNotAnAttribute(): Attribute
70-
{
71-
return Attribute::get(function () {
72-
return strtoupper($this->name);
73-
});
74-
}
7570
}

0 commit comments

Comments
 (0)