Files
barryvdh_laravel-ide-helper/tests/Console/ModelsCommand/Attributes/Models/Simple.php
T
Markus Podar a8b34ad228 Removed support for Laravel 8 and therefore for PHP < 8.0 (#1504)
* Removed support for Laravel 8 and therefore for PHP < 8.0

* Update php-cs-fixer to v3

* composer fix-style
2024-02-05 13:25:08 +01:00

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;
}
);
}
}