classLayout
final class Layout
uses Snapshot
@visibility public.The written spelling of a region whose spelling the database makes observable.
Rule: CORE-SPELLING-001. Some databases name an unaliased result column after the text of its expression (SQLite, MySQL). Where a database does so, the text is part of the meaning, and the model keeps it as a layout: one spelled token per token the rendering of the region produces, in order. The tokens themselves still come from the structure; a layout only chooses the trivia between them and after the last of them, and an equivalent spelling of each. Publication refuses a layout that does not align one to one with the rendered tokens, whose spellings are not the same tokens, or whose gaps are not trivia, and the rendered SQL must lower to the same structure, layout included. A layout never stands for structure, and nothing is rendered from it alone. Status: Implemented.
$layout = new \SqlSemantics\Platform\MySql\Model\Statement\Spelling\Layout([new \SqlSemantics\Platform\MySql\Model\Statement\Spelling\Spelled('', '1'), new \SqlSemantics\Platform\MySql\Model\Statement\Spelling\Spelled('', '+'), new \SqlSemantics\Platform\MySql\Model\Statement\Spelling\Spelled('', '1')]);
$layout->text() // => '1+1'Properties§
public non-empty-list<Spelled> $tokenspublic string $trail = ''Methods§
public function __construct(list<Spelled> $tokens, public string $trail = '')Parameters
$tokens | list<Spelled> | The spelled tokens in order; at least one |
$trail | string | The whitespace and comments written after the last token, before whatever follows the region |
Calls 2
- static-call Check::listOf() line 46
- class-const Spelled::class() line 46
public function text(): stringAnswers the text of the region from its first to its last token.
Returns
stringTest cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Other tests reaching this symbol 6
ItemNamingTest::testNameAnswersTheAliasTheColumnNameOrTheTextcallsItemNamingTest::testNameRefusesALayoutOfAnItemThatNamesItselfcallsItemNamingTest::testNameRefusesALayoutThatSpellsTheCanonicalRenderingcallsItemNamingTest::testTextAnswersTheLayoutOrTheCanonicalRenderingcallsSelectExpressionTest::testALayoutWithTrailingTriviaIsRejectedcallsSelectExpressionTest::testAnAliasedItemWithALayoutIsRejectedcalls
Relations§
Instantiated in 2
Type declarations 4
- type SqlSemantics\Platform\MySql\Lowering\Query\Shared\ItemLayout packages/sql-semantics-mysql/src/Lowering/Query/Shared/ItemLayout.php:51
- type SqlSemantics\Platform\MySql\Model\Construction\Layouts packages/sql-semantics-mysql/src/Model/Construction/Layouts.php:27
- type SqlSemantics\Platform\MySql\Model\Rendering\Output packages/sql-semantics-mysql/src/Model/Rendering/Output.php:156
- type SqlSemantics\Platform\MySql\Statement\Query\SelectExpression packages/sql-semantics-mysql/src/Statement/Query/SelectExpression.php:47