classTableFile
final class TableFile
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Stores parse tables as deflated files and loads them once per process.
Methods§
public function __construct(private TableCodec $codec = new \SqlParser\Table\TableCodec())Parameters
$codec | TableCodec | Converts between tables and bytes |
Calls 1
- new TableCodec line 24
public function save(ParseTable $table, string $path): voidWrites a table to a file.
Parameters
$table | ParseTable | Table to store |
$path | string | Where to write it |
Throws
RuntimeException When the file cannot be writtenTest cases 2
Called from 1
Calls 4
- function-call
gzdeflateline 38 - method-call TableCodec::encode() line 38
- function-call
file_put_contentsline 39 - new
RuntimeExceptionline 40
public function load(string $path): ParseTableReads a table from a file, reusing it when the same file was read before.
Parameters
$path | string | File written by save() |
Returns
ParseTable The tableThrows
RuntimeException When the file is missing, not deflated, or not an encoded tableTest cases 5
Called from 3
- method-call SqlParser\MySql\MySqlParser::__construct() packages/sql-parser/src/MySql/MySqlParser.php:65
- method-call SqlParser\PostgreSql\PostgreSqlParser::__construct() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:61
- method-call SqlParser\Sqlite\SqliteParser::__construct() packages/sql-parser/src/Sqlite/SqliteParser.php:62
Calls 5
- function-call
is_fileline 58 - function-call
file_get_contentsline 58 - new
RuntimeExceptionline 60 - method-call TableFile::inflate() line 62
- method-call TableCodec::decode() line 67
public function inflate(string $compressed): string|nullInflates deflated bytes, quietly answering null when they are not deflated.
Parameters
$compressed | string | Bytes read from the file |
Returns
string|null The inflated bytes, or null when inflating failsTest cases 1
Called from 1
public static function forget(): voidForgets every table loaded so far, so a rewritten file is read again.
Test cases 2
Private surface 2§
Implementation details, listed for orientation only.
private static array<string, ParseTable> $loaded = []private TableCodec $codec = new \SqlParser\Table\TableCodec()Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
Other tests reaching this symbol 5
ParseBench::benchLoadTablecallsMySqlParserTestcallsPostgreSqlParserTestcallsResourceWriterTest::testWriteTablecallsSqliteParserTestcalls
Relations§
Instantiated in 4
- new SqlParser\MySql\MySqlParser::__construct() packages/sql-parser/src/MySql/MySqlParser.php:65
- new SqlParser\PostgreSql\PostgreSqlParser::__construct() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:61
- new SqlParser\Resource\ResourceWriter::__construct() packages/sql-parser/src/Resource/ResourceWriter.php:21
- new SqlParser\Sqlite\SqliteParser::__construct() packages/sql-parser/src/Sqlite/SqliteParser.php:62
Method calls 4
- method-call SqlParser\MySql\MySqlParser::__construct() packages/sql-parser/src/MySql/MySqlParser.php:65
- method-call SqlParser\PostgreSql\PostgreSqlParser::__construct() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:61
- method-call SqlParser\Resource\ResourceWriter::writeTable() packages/sql-parser/src/Resource/ResourceWriter.php:36
- method-call SqlParser\Sqlite\SqliteParser::__construct() packages/sql-parser/src/Sqlite/SqliteParser.php:62