classTableReader
final class TableReader
Reads the tables a statement names.
The names let a catalog be grouped and filtered by table, and are what a fixture generator needs in order to build rows for the statement. A name the analyzer knows only part of — a prefix read from configuration and a suffix written in the source — is still a name to group by, and is reported with the unknown part marked. A name nothing is known of is not guessed at.
Constants§
public const GAP = '{$}'The marker an unknown part of a name is reported with.
Methods§
public function __construct(?SqlLexer $lexer = null)public function read(TextPattern $pattern): list<string>The tables the statement names, in order and without repeats.
Parameters
$pattern | TextPattern |
Returns
list<string>Test cases 4
Called from 1
Calls 11
- method-call SqlLexer::tokenize() line 57
- method-call TextPattern::render() line 57
- class-const PlaceholderScanner::HOLE_MARKER() line 57
- class-const SqlTokenKind::Word() line 61
- function-call
in_arrayline 61 - class-const TableReader::INTRODUCERS() line 61
- method-call TableReader::readName() line 63
- function-call
array_sliceline 63 - function-call
str_replaceline 65 - class-const TableReader::GAP() line 65
- function-call
array_keysline 71
public function readName(list<SqlToken> $tokens): ?stringThe possibly qualified table name the tokens start with, or null when they name none.
Parameters
$tokens | list<SqlToken> |
Returns
?stringTest cases 2
Called from 1
Calls 9
- function-call
countline 83 - class-const SqlTokenKind::Word() line 84
- function-call
in_arrayline 84 - class-const TableReader::SKIPPED() line 84
- method-call TableReader::isName() line 87
- method-call TableReader::unquote() line 88
- class-const SqlTokenKind::Symbol() line 91
- function-call
implodeline 99 - function-call
array_sliceline 99
public function isName(SqlToken $token): boolWhether the token can start a table name.
A gap on its own is not a name, quoted or not; a word with a gap in it is, since the rest of the word is known.
Parameters
$token | SqlToken |
Returns
boolTest cases 1
Called from 1
Calls 7
- class-const SqlTokenKind::Identifier() line 113
- method-call TableReader::unquote() line 114
- class-const PlaceholderScanner::HOLE_MARKER() line 114
- class-const SqlTokenKind::Word() line 117
- function-call
in_arrayline 119 - method-call SqlToken::keyword() line 119
- class-const TableReader::NEVER_NAMES() line 119
Private surface 4§
Implementation details, listed for orientation only.
private const INTRODUCERS = ['FROM', 'JOIN', 'INTO', 'UPDATE', 'TABLE']private const SKIPPED = ['IF', 'NOT', 'EXISTS']private const NEVER_NAMES = ['SELECT', 'ONLY', 'LATERAL', 'WHERE', 'SET', 'VALUES', 'ON', 'STATUS', 'KEY', …private SqlLexer $lexerTest cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
TableReaderTest::testIsNameRejectsKeywordsAndGapMarkerscallsTableReaderTest::testReadcallsTableReaderTest::testReadDoesNotGuessAQuotedNameThatIsAllGapcallsTableReaderTest::testReadKeepsANameThatIsKnownInPartcallsTableReaderTest::testReadNameIsNullWhenNothingNamesATablecallsTableReaderTest::testReadNameStopsAtATrailingSeparatorcallsTableReaderTest::testReadStopsAtAGapInsteadOfGuessingATablecallsTableReaderTest::testUnquoteStripsIdentifierQuotingcalls
Other tests reaching this symbol 7
CatalogCommandTestcallsEntryFactoryTestcallsExpressionEvaluatorTestcallsCallModelTestcallsAnalyzerTestcallsJsonReporterTestcallsTextReporterTestcalls