classSqlFormatter
final class SqlFormatter
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Formats report SQL with sql-formatter's expanded layout.
Catalog entries do not carry a dialect, so each supported grammar is tried. Gaps are temporarily represented by identifiers and restored with their provenance after formatting. Text no grammar accepts is kept as written.
Methods§
public function __construct(private list<SqlFormatter> $formatters = [])Parameters
$formatters | list<SqlFormatter> | Ordered application policies |
public function format(list<StatementPart> $parts): list<StatementPart>The statement laid out for reading, with gap metadata preserved.
Parameters
$parts | list<StatementPart> |
Returns
list<StatementPart>Calls 3
- method-call SqlFormatter::mask() line 36
- function-call
array_filterline 37 - method-call SqlFormatter::restore() line 44
public function mask(list<StatementPart> $parts): array{string, array<string, StatementPart>}Replaces gaps with identifiers that cannot collide with known SQL text.
Parameters
$parts | list<StatementPart> |
Returns
array{string, array<string, StatementPart>}Called from 1
public function maskParameters(
string $sql,
array<string, StatementPart> $gaps,
string $prefix,
): array{string, array<string, StatementPart>}Protects client placeholders that are not part of the server grammar.
Parameters
$sql | string | |
$gaps | array<string, StatementPart> | |
$prefix | string |
Returns
array{string, array<string, StatementPart>}Called from 1
Calls 7
- function-call
preg_match_allline 90 - class-const SqlHighlighter::TOKENS() line 90
- function-call
in_arrayline 95 - function-call
countline 99 - new StatementPart line 100
- function-call
substrline 101 - function-call
strlenline 102
public function restore(string $sql, array<string, StatementPart> $gaps): list<StatementPart>Restores gaps and client placeholders without interpreting literal gap-like text.
Parameters
$sql | string | |
$gaps | array<string, StatementPart> |
Returns
list<StatementPart>Throws
FormattingException When a marker cannot be restoredCalled from 1
Calls 8
- function-call
str_containsline 118 - new FormattingException line 119
- new StatementPart line 123
- function-call
implodeline 125 - function-call
array_mapline 125 - function-call
preg_quoteline 125 - function-call
array_keysline 125 - function-call
preg_splitline 126
Private surface 1§
Implementation details, listed for orientation only.
private list<SqlFormatter> $formatters = []Test cases 18§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 16
ReporterInterfaceTestcallsBuiltinsTestcallsHtmlReporterTestcallsClassPageTestcallsFileIndexPageTestcallsFilePageTestcallsFindingPageTestcallsNamespacePageTestcallsOverviewPageTestcallsStatementIndexPageTestcallsStatementPageTestcallsTableIndexPageTestcallsTablePageTestcallsPageShellTestcallsStatementListTestcallsStatementRowTestcalls
Relations§
Instantiated in 5
- new SqlCatalog\Facade\Builtins::sqlFormatter() packages/sql-catalog/src/Facade/Builtins.php:78
- new SqlCatalog\Reporter\Html\HtmlReporter::__construct() packages/sql-catalog/src/Reporter/Html/HtmlReporter.php:39
- new SqlCatalog\Reporter\Html\Page\StatementPage::__construct() packages/sql-catalog/src/Reporter/Html/Page/StatementPage.php:66
- new SqlCatalog\Reporter\Html\ReportSite::__construct() packages/sql-catalog/src/Reporter/Html/ReportSite.php:79
- new SqlCatalog\Reporter\Html\StatementRow::__construct() packages/sql-catalog/src/Reporter/Html/StatementRow.php:42
Type declarations 9
- type SqlCatalog\Facade\Builtins packages/sql-catalog/src/Facade/Builtins.php:76
- type SqlCatalog\Reporter\Html\HtmlReporter packages/sql-catalog/src/Reporter/Html/HtmlReporter.php:39
- type SqlCatalog\Reporter\Html\Page\StatementPage packages/sql-catalog/src/Reporter/Html/Page/StatementPage.php:48
- type SqlCatalog\Reporter\Html\Page\StatementPage packages/sql-catalog/src/Reporter/Html/Page/StatementPage.php:60
- type SqlCatalog\Reporter\Html\Page\StatementPage packages/sql-catalog/src/Reporter/Html/Page/StatementPage.php:134
- type SqlCatalog\Reporter\Html\ReportSite packages/sql-catalog/src/Reporter/Html/ReportSite.php:79
- type SqlCatalog\Reporter\Html\StatementRow packages/sql-catalog/src/Reporter/Html/StatementRow.php:32
- type SqlCatalog\Reporter\Html\StatementRow packages/sql-catalog/src/Reporter/Html/StatementRow.php:37
- type SqlCatalog\Reporter\Html\StatementRow packages/sql-catalog/src/Reporter/Html/StatementRow.php:96