packages/sql-semantics-mysql/src/Model/Statement/Reference/Missing/UndeclaredRoutine.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\MySql\Model\Statement\Reference\Missing;
6
7use SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName;
8use SqlSemantics\Platform\MySql\Model\Statement\Snapshot;
9
10/**
11 * A function or procedure whose signature is neither fixed by the language profile nor declared in the context.
12 *
13 * @visibility public
14 * @example Naming an undeclared routine
15 *     $name = new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('score'));
16 *     (new \SqlSemantics\Platform\MySql\Model\Statement\Reference\Missing\UndeclaredRoutine($name))->describe() // => 'the signature of routine score'
17 */
18final class UndeclaredRoutine implements MissingInput
19{
20    use Snapshot;
21
22    /**
23     * @param QualifiedName $name The routine name as the statement wrote it
24     */
25    public function __construct(public readonly QualifiedName $name)
26    {
27    }
28
29    /**
30     * Describes the missing signature.
31     */
32    public function describe(): string
33    {
34        return 'the signature of routine ' . $this->name->name->value;
35    }
36}
37