classValueReader
final class ValueReader
uses Assertion
Lowers transient parser nodes into typed SQL arguments and finite options.
A comment is kept by the outermost value whose symbol begins with the token the comment was written before. Comments before the first token and after the last one belong to the statement.
Type Aliases§
Recipe = array{forward: int}|array{constant: string}|array{class: class-string<Element>, fields: list<int>}Methods§
public function __construct(
private array<string, array<int, Recipe>> $recipes,
private TriviaReader $trivia = new \SqlSemantics\Core\Analysis\TriviaReader(),
)Parameters
$recipes | array<string, array<int, Recipe>> | Complete construction vocabulary |
$trivia | TriviaReader | Reads the comments of the language |
Calls 2
- new TriviaReader line 35
- new Comments line 37
public static function fromFile(string $path, TriviaReader|null $trivia = null): selfLoads the construction vocabulary supplied by a database package.
Parameters
$path | string | |
$trivia | TriviaReader|null | Reads the comments of the language, or null to read them as plain block and line comments |
Returns
selfThrows
LogicException When generated resources are missing or invalidCalled from 3
- static-call SqlSemantics\Platform\MySql\Platform::values() packages/sql-semantics-mysql/src/Platform.php:42
- static-call SqlSemantics\Platform\PostgreSql\Platform::values() packages/sql-semantics-postgres/src/Platform.php:41
- static-call SqlSemantics\Platform\Sqlite\Platform::values() packages/sql-semantics-sqlite/src/Platform.php:41
Lowers a complete parse tree into a statement that keeps its comments, and discards the tree.
Parameters
$root | Node |
Returns
Throws
LogicException When parser and model resources disagreeCalled from 1
Calls 7
- method-call TriviaReader::read() line 67
- method-call ValueReader::lower() line 68
- method-call ValueReader::assertCompleteCommand() line 69
- class-const Statement::BEFORE() line 72
- class-const Statement::AFTER() line 75
- new Statement line 78
- new Comments line 78
Discards the input node after assigning its values to their named fields.
Comments before the first token and after the last one are not kept; use statement() for a complete tree.
Parameters
$node | Node |
Returns
Throws
LogicException When parser and model resources disagreeCalled from 6
- method-call SqlSemantics\Core\Ast\ColumnProperties::generation() packages/sql-semantics/src/Core/Ast/ColumnProperties.php:55
- method-call SqlSemantics\Core\Ast\ColumnProperties::collation() packages/sql-semantics/src/Core/Ast/ColumnProperties.php:69
- method-call SqlSemantics\Core\Ast\ColumnReader::read() packages/sql-semantics/src/Core/Ast/ColumnReader.php:59
- method-call SqlSemantics\Core\Ast\ColumnReader::read() packages/sql-semantics/src/Core/Ast/ColumnReader.php:68
- method-call SqlSemantics\Core\Ast\ConstraintReader::read() packages/sql-semantics/src/Core/Ast/ConstraintReader.php:53
- method-call SqlSemantics\Core\Ast\SchemaReader::table() packages/sql-semantics/src/Core/Ast/SchemaReader.php:98
Calls 2
- method-call ValueReader::lower() line 91
- method-call TriviaReader::read() line 91
public function lower(Node $node, SourceComments $comments, bool $firstKept): ElementBuilds the value of a node, keeping the comments of the symbols it owns.
Parameters
$node | Node | |
$comments | SourceComments | The comments of the tree the node belongs to |
$firstKept | bool | Whether an enclosing value or the statement already keeps the comments before the first token |
Returns
Throws
LogicException When parser and model resources disagreeCalled from 4
- method-call SqlSemantics\Core\Analysis\ValueReader::statement() packages/sql-semantics/src/Core/Analysis/ValueReader.php:68
- method-call SqlSemantics\Core\Analysis\ValueReader::read() packages/sql-semantics/src/Core/Analysis/ValueReader.php:91
- method-call SqlSemantics\Core\Analysis\ValueReader::lower() packages/sql-semantics/src/Core/Analysis/ValueReader.php:114
- method-call SqlSemantics\Core\Analysis\ValueReader::lower() packages/sql-semantics/src/Core/Analysis/ValueReader.php:147
Calls 6
- new
LogicExceptionline 106 - method-call ValueReader::lower() line 114
- function-call
constantline 117 - method-call SourceComments::first() line 127
- method-call SourceComments::before() line 136
- new Comments line 150
Private surface 3§
Implementation details, listed for orientation only.
private Comments $noneprivate array<string, array<int, Recipe>> $recipesprivate TriviaReader $trivia = new \SqlSemantics\Core\Analysis\TriviaReader()Test cases 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
ValueReaderTestcalls
Other tests reaching this symbol 16
AnalyzerTestcallsSchemaAnalyzerTestcallsAnalysisExceptionTestcallsColumnPropertiesTestcallsSchemaChangesTestcallsPlatformTestcallsSchemaRulesTest::testColumnNodesHonorsAnInjectedPolicycallsColumnGenerationTestcallsGenerationKindTestcallsInvariantTestcallsSchemaTestcallsSemanticsTestcallsPlatformTestcallsElementTestcallsStatementTestcallsWriterTestcalls
Relations§
Static calls 3
- static-call SqlSemantics\Platform\MySql\Platform::values() packages/sql-semantics-mysql/src/Platform.php:42
- static-call SqlSemantics\Platform\PostgreSql\Platform::values() packages/sql-semantics-postgres/src/Platform.php:41
- static-call SqlSemantics\Platform\Sqlite\Platform::values() packages/sql-semantics-sqlite/src/Platform.php:41
Method calls 7
- method-call SqlSemantics\Core\Analysis\Analyzer::analyze() packages/sql-semantics/src/Core/Analysis/Analyzer.php:45
- method-call SqlSemantics\Core\Ast\ColumnProperties::generation() packages/sql-semantics/src/Core/Ast/ColumnProperties.php:55
- method-call SqlSemantics\Core\Ast\ColumnProperties::collation() packages/sql-semantics/src/Core/Ast/ColumnProperties.php:69
- method-call SqlSemantics\Core\Ast\ColumnReader::read() packages/sql-semantics/src/Core/Ast/ColumnReader.php:59
- method-call SqlSemantics\Core\Ast\ColumnReader::read() packages/sql-semantics/src/Core/Ast/ColumnReader.php:68
- method-call SqlSemantics\Core\Ast\ConstraintReader::read() packages/sql-semantics/src/Core/Ast/ConstraintReader.php:53
- method-call SqlSemantics\Core\Ast\SchemaReader::table() packages/sql-semantics/src/Core/Ast/SchemaReader.php:98
Type declarations 12
- type SqlSemantics\Platform\MySql\Platform packages/sql-semantics-mysql/src/Platform.php:40
- type SqlSemantics\Platform\PostgreSql\Platform packages/sql-semantics-postgres/src/Platform.php:39
- type SqlSemantics\Platform\Sqlite\Platform packages/sql-semantics-sqlite/src/Platform.php:39
- type SqlSemantics\Core\Analysis\Analyzer packages/sql-semantics/src/Core/Analysis/Analyzer.php:21
- type SqlSemantics\Core\Ast\ColumnProperties packages/sql-semantics/src/Core/Ast/ColumnProperties.php:23
- type SqlSemantics\Core\Ast\ColumnReader packages/sql-semantics/src/Core/Ast/ColumnReader.php:20
- type SqlSemantics\Core\Ast\ColumnReader packages/sql-semantics/src/Core/Ast/ColumnReader.php:24
- type SqlSemantics\Core\Ast\ConstraintReader packages/sql-semantics/src/Core/Ast/ConstraintReader.php:19
- type SqlSemantics\Core\Ast\ConstraintReader packages/sql-semantics/src/Core/Ast/ConstraintReader.php:23
- type SqlSemantics\Core\Ast\SchemaReader packages/sql-semantics/src/Core/Ast/SchemaReader.php:23
- type SqlSemantics\Core\Ast\SchemaReader packages/sql-semantics/src/Core/Ast/SchemaReader.php:27
- type SqlSemantics\Core\Platform packages/sql-semantics/src/Core/Platform.php:28