classTableFile
final class TableFile
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Stores parse tables as native PHP codec bytes and reuses identical file contents.
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 3
Called from 1
Calls 3
- 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.
The file is read on every call and recognized by a fast non-cryptographic digest of its contents, which only has to tell file contents apart within one process.
Parameters
$path | string | File written by save() |
Returns
ParseTable The tableThrows
RuntimeException When the file is missing or is not a readable encoded tableTest cases 6
Called from 3
- method-call SqlParser\MySql\MySqlParser::__construct() packages/sql-parser/src/MySql/MySqlParser.php:70
- method-call SqlParser\PostgreSql\PostgreSqlParser::__construct() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:66
- method-call SqlParser\Sqlite\SqliteParser::__construct() packages/sql-parser/src/Sqlite/SqliteParser.php:62
Calls 8
- function-call
is_fileline 58 - function-call
file_get_contentsline 58 - new
RuntimeExceptionline 60 - function-call
hashline 62 - function-call
str_starts_withline 66 - class-const TableCodec::MAGIC() line 66
- method-call TableFile::inflate() line 66
- method-call TableCodec::decode() line 71
public function inflate(string $compressed): string|nullReads legacy compressed caches when the optional zlib extension is available. New and shipped artifacts use uncompressed codec bytes and never call this method.
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 11§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
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:70
- new SqlParser\PostgreSql\PostgreSqlParser::__construct() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:66
- 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:70
- method-call SqlParser\PostgreSql\PostgreSqlParser::__construct() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:66
- 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