classRenderer
final class Renderer
Restricted visibility: declared "@visibility SqlFormatter". Code outside that scope must not name this declaration.
Renders and verifies compact SQL using a dialect-specific canonical token stream.
Methods§
public function __construct(private SqlParser $parser, private Settings $settings)public function render(Node $tree): stringRemoves optional syntax, then reparses to check the canonical form.
Parameters
$tree | Node |
Returns
stringThrows
FormattingException When output verification failsTest cases 3
Called from 1
Calls 7
- method-call Renderer::document() line 42
- method-call Renderer::write() line 44
- method-call SqlParser::parse() line 46
- new FormattingException line 48
- function-call
array_valuesline 54 - function-call
array_filterline 54 - function-call
in_arrayline 54
public function write(list<Token> $tokens, string $trailing): stringEmits a canonical stream with only lexically necessary separators.
Parameters
$tokens | list<Token> | |
$trailing | string |
Returns
stringTest cases 1
Called from 2
Calls 2
- function-call
serializeline 83 - method-call Spacing::between() line 84
public function document(Node $tree): DocumentSelects dialect-specific normalization without relying on a default release.
Parameters
$tree | Node |
Returns
Test cases 1
Called from 3
- method-call SqlFormatter\Core\Compact\Renderer::render() packages/sql-formatter/src/Core/Compact/Renderer.php:42
- method-call SqlFormatter\Core\Compact\Renderer::render() packages/sql-formatter/src/Core/Compact/Renderer.php:46
- method-call SqlFormatter\Core\Compact\Renderer::render() packages/sql-formatter/src/Core/Compact/Renderer.php:57
Private surface 4§
Implementation details, listed for orientation only.
private array<string, string> $separators = []private Spacing $spacingprivate SqlParser $parserprivate Settings $settingsTest cases 20§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
RendererTest::testDocumentSelectsDialectSpecificSpellingscallsRendererTest::testRenderEquivalentSpellingscallsRendererTest::testRenderHonorsMysqlLexicalModescallsRendererTest::testRenderPreservesSqliteResultsAndOperatorAssociationcallsRendererTest::testWriteRetainsDirectiveOwnershipAndRequiredSeparatorscalls
Other tests reaching this symbol 15
DocumentTestcallsGroupingTestcallsKeywordsTestcallsReductionsTestcallsRulesTestcallsSettingsTestcallsShapeTestcallsSpacingTestcallsTriviaTestcallsVisitorTestcallsFormatterTestcallsFormatterTestcallsDialectTestcallsDialectTestcallsDialectTestcalls