Parser (parse, incremental reparse from lutra_text edits), outline with UTF-16 ranges and short signatures, folding ranges, 8 MiB parse cap. Snapshot tests for five PHP 8.3 fixtures, proptests (random bytes, reparse equals fresh parse, undo round trip), ignored release timing test. Docs: architecture Syntax section, parity evidence, G4 note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
1 KiB
PHP
64 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Contracts\HasLabel;
|
|
use App\Support\Str;
|
|
use function App\Support\slugify;
|
|
|
|
#[\Attribute(\Attribute::TARGET_CLASS)]
|
|
final class Entity
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Base model for every entity.
|
|
*/
|
|
#[Entity]
|
|
abstract class Model
|
|
{
|
|
protected static int $instances = 0;
|
|
|
|
#[\Deprecated]
|
|
abstract public function key(): string|int;
|
|
|
|
public function &attributes(): array
|
|
{
|
|
static $cache = [];
|
|
return $cache;
|
|
}
|
|
}
|
|
|
|
trait Timestamps
|
|
{
|
|
public ?\DateTimeImmutable $createdAt = null;
|
|
|
|
public function touch(\DateTimeImmutable $at = new \DateTimeImmutable()): void
|
|
{
|
|
$this->createdAt = $at;
|
|
}
|
|
}
|
|
|
|
namespace App\Enums;
|
|
|
|
enum Status: string implements \App\Contracts\HasLabel
|
|
{
|
|
case Draft = 'draft';
|
|
case Published = 'published';
|
|
|
|
const DEFAULT = self::Draft;
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::Draft => 'Draft',
|
|
self::Published => 'Published',
|
|
};
|
|
}
|
|
}
|
|
|
|
enum Suit
|
|
{
|
|
case Hearts;
|
|
case Spades;
|
|
}
|