mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-17 17:47:13 +00:00
* Removed support for Laravel 8 and therefore for PHP < 8.0 * Update php-cs-fixer to v3 * composer fix-style
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Attributes\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Simple extends Model
|
|
{
|
|
protected function name(): Attribute
|
|
{
|
|
return new Attribute(
|
|
function (?string $name): ?string {
|
|
return $name;
|
|
},
|
|
function (?string $name): ?string {
|
|
return $name === null ? null : ucfirst($name);
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 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 Attribute
|
|
*/
|
|
protected function notAnAttribute()
|
|
{
|
|
return new Attribute(
|
|
function (?string $value): ?string {
|
|
return $value;
|
|
},
|
|
function (?string $value): ?string {
|
|
return $value;
|
|
}
|
|
);
|
|
}
|
|
}
|