classJsonReporter
final class JsonReporter
implements ReporterInterface
Writes the catalog as JSON, in an order two runs can be compared in.
Nothing that changes between runs of the same source, such as a timestamp, is written, so the artifact can be committed and its diff read as the change in the SQL an application issues.
Type Aliases§
BoundValue = array{type: string, values: list<string|int|float|bool|null>, exhaustive: bool, origins: list<string>}PlaceholderNode = array{token: string, position: int, name: string|null, value: BoundValue|null}FindingNode = array{rule: string, severity: string, message: string}SiteNode = array{file: string, line: int, function: string, sink: string}StatementNode = array{id: string, kind: string, sql: string, exact: bool, resolution: string, searchClosed: bool, correlated: bool, tables: list<string>, site: SiteNode, through: list<string>, placeholders: list<PlaceholderNode>, findings: list<FindingNode>}SummaryNode = array{statements: int, resolved: int, undetermined: int, findings: int}CatalogDocument = array{'$schema': string, version: int, analysis: array{conditions: string, reachability: string}, summary: SummaryNode, statements: list<StatementNode>, problems: list<array{file: string, message: string}>}Constants§
public const VERSION = 2The format version written into the document.
public const FILE = 'catalog.json'The name the artifact is written under.
public const SCHEMA_FILE = 'catalog-schema.json'The name the schema describing the artifact is written under.
Methods§
public function name(): stringThe name the command line selects this reporter by.
Returns
stringTest cases 1
public function description(): stringWhat the reporter produces.
Returns
stringTest cases 1
public function render(Catalog $catalog): CatalogArtifactsThe catalog rendered as one JSON document.
Parameters
$catalog | Catalog |
Returns
Test cases 5
JsonReporterTest::testRenderIsTheSameForTheSameCatalogcallsJsonReporterTest::testRenderWritesTheJsonDocumentcallsJsonReporterTest::testRenderWritesTheWholeDocumentExactlycallsJsonReporterTest::testTheDocumentMatchesTheSchemaItDeclarescallsJsonReporterTest::testTheSchemaIsWrittenBesideTheDocumentcalls
Calls 6
- function-call
json_encodeline 72 - method-call JsonReporter::toArray() line 72
- new CatalogArtifacts line 74
- class-const JsonReporter::FILE() line 76
- class-const JsonReporter::SCHEMA_FILE() line 77
- method-call JsonReporter::schema() line 77
public function schema(): stringThe schema the document declares itself against.
The schema is written beside the document rather than pointed at over the network, so a catalog that has been committed, copied or archived stays readable without asking anything else for the shape of it.
Returns
stringTest cases 2
Called from 1
Calls 3
- function-call
file_get_contentsline 92 - function-call
dirnameline 92 - class-const JsonReporter::SCHEMA_FILE() line 92
public function toArray(Catalog $catalog): CatalogDocumentThe document the catalog renders to.
Parameters
$catalog | Catalog |
Returns
Test cases 2
Called from 1
Calls 5
- method-call Catalog::sorted() line 105
- method-call JsonReporter::entryToArray() line 106
- class-const JsonReporter::SCHEMA_FILE() line 114
- class-const JsonReporter::VERSION() line 115
- method-call JsonReporter::summary() line 117
public function summary(Catalog $catalog): SummaryNodeThe counts a reader looks at first.
Parameters
$catalog | Catalog |
Returns
Test cases 1
Called from 1
Calls 2
- function-call
countline 136 - method-call Catalog::count() line 140
public function entryToArray(CatalogEntry $entry): StatementNodeOne statement rendered as a document node.
Parameters
$entry | CatalogEntry |
Returns
Test cases 1
Called from 1
Calls 5
- method-call JsonReporter::placeholderToArray() line 164
- method-call CatalogEntry::sql() line 170
- method-call CatalogEntry::isExact() line 171
- method-call CatalogEntry::resolution() line 172
- method-call CatalogEntry::searchClosed() line 173
public function placeholderToArray(Placeholder $placeholder): PlaceholderNodeOne bind parameter rendered as a document node.
Parameters
$placeholder | Placeholder |
Returns
Test cases 2
Test cases 24§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 14
JsonReporterTest::testDescriptionMentionsWhatItProducescallsJsonReporterTest::testEntryToArrayCarriesTheFindingscallsJsonReporterTest::testNameIsHowTheCommandLineSelectsItcallsJsonReporterTest::testPlaceholderToArrayCarriesTheBoundValuecallsJsonReporterTest::testPlaceholderToArrayReportsAnUnboundParametercallsJsonReporterTest::testRenderIsTheSameForTheSameCatalogcallsJsonReporterTest::testRenderWritesTheJsonDocumentcallsJsonReporterTest::testRenderWritesTheWholeDocumentExactlycallsJsonReporterTest::testSchemaIsTheShippedDocumentSchemacallsJsonReporterTest::testSummaryCountsResolvedAndDynamicStatementscallsJsonReporterTest::testTheDocumentMatchesTheSchemaItDeclarescallsJsonReporterTest::testTheSchemaIsWrittenBesideTheDocumentcallsJsonReporterTest::testToArrayCarriesTheFilesThatCouldNotBeReadcallsJsonReporterTest::testToArrayCarriesTheVersionAndTheStatementscalls
Other tests reaching this symbol 10
CatalogCommandTestcallsUsageTextTestcallsReporterInterfaceTest::testDescriptionIsAlwaysWrittencallsReporterInterfaceTest::testNameIsUniqueAcrossTheReportersThatShipcallsReporterInterfaceTest::testRenderAlwaysProducesSomethingToShowcallsReporterRegistryTest::testGetAnswersWithTheRegisteredReportercallsReporterRegistryTest::testGetRefusesAnUnknownNamecallsReporterRegistryTest::testHasReportsWhetherAReporterIsRegisteredcallsReporterRegistryTest::testNamesAreAlphabeticalcallsReporterRegistryTest::testRegisterReplacesAReporterOfTheSameNamecalls