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>
67 lines
1.3 KiB
PHP
67 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shop\Catalog {
|
|
use Shop\Money\Price;
|
|
|
|
interface Sellable extends \Stringable, \Countable
|
|
{
|
|
public const string CURRENCY = 'EUR';
|
|
|
|
public function price(): Price;
|
|
}
|
|
|
|
final class Product implements Sellable
|
|
{
|
|
private array $tags = [], $notes = [];
|
|
|
|
public function __construct(
|
|
public readonly int $id,
|
|
protected ?string $title = null,
|
|
private array &$cache = [],
|
|
string $unused = '',
|
|
) {
|
|
}
|
|
|
|
public function find(int $id): ?Product
|
|
{
|
|
return $id === $this->id ? $this : null;
|
|
}
|
|
|
|
public static function tagged(string ...$tags): static
|
|
{
|
|
return new static(0);
|
|
}
|
|
|
|
public function price(): Price
|
|
{
|
|
return new Price(0);
|
|
}
|
|
|
|
public function __toString(): string
|
|
{
|
|
return (string) $this->title;
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return \count($this->tags);
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace Shop\Orders {
|
|
function total(array $lines, float $vat = 0.19): float
|
|
{
|
|
return array_sum($lines) * (1 + $vat);
|
|
}
|
|
|
|
const MAX_LINES = 100, MIN_LINES = 1;
|
|
}
|
|
|
|
namespace {
|
|
function bootstrap(): void
|
|
{
|
|
}
|
|
}
|