classCatalogCommand
final class CatalogCommand
Public API: explicitly declared with
@visibility public.The sql-catalog command.
$command = new \SqlCatalog\Cli\CatalogCommand();
$result = $command->run(['--help']);
$result->exitCode->value // => 0
str_contains($result->output, 'sql-catalog') // => trueMethods§
public function __construct(
Analyzer|null $analyzer = null,
ReporterRegistry|null $reporters = null,
)Parameters
$analyzer | Analyzer|null | The analyzer to run, or null for one with the built-in extensions |
$reporters | ReporterRegistry|null | The reporters to render with, or null for the built-in ones |
Calls 4
- new Analyzer line 42
- static-call Builtins::reporters() line 43
- new CommandLineParser line 44
- new ArtifactWriter line 45
public function run(list<string> $arguments): CommandResultRuns the command with the given arguments.
Parameters
$arguments | list<string> | The arguments, without the command name |
Returns
Test cases 8
CatalogCommandTest::testRunAnswersTheHelpcallsCatalogCommandTest::testRunCatalogsTheNamedPathOntoStandardOutputcallsCatalogCommandTest::testRunDoesNotLoadConfigurationWhenPrintingHelpcallsCatalogCommandTest::testRunLoadsCatalogSettingsAndAllowsCliOverridescallsCatalogCommandTest::testRunReportsAnInvalidCommandLinecallsCatalogCommandTest::testRunReportsAPathItCannotReadcallsCatalogCommandTest::testRunReportsConfigurationErrorscallsCatalogCommandTest::testRunReportsMissingConfigurationAsAnInvalidCommandLinecalls
Calls 5
- method-call CatalogCommand::execute() line 56
- method-call CommandLineParser::parse() line 56
- static-call CommandResult::failure() line 58
- class-const ExitCode::InvalidCommandLine() line 58
- class-const ExitCode::SourceUnreadable() line 60
public function execute(CommandLine $command): CommandResultRuns the command for an already parsed command line.
Parameters
$command | CommandLine |
Returns
Throws
InvalidConfigurationException When the requested configuration cannot be loadedInvalidCommandLineException When no path was given to analyzeSourceScanException When a path cannot be readUnknownExtensionException When an extension is not registeredUnknownReporterException When the reporter is not registeredWriteFailureException When the report cannot be writtenTest cases 2
Called from 1
Calls 5
- method-call CatalogCommand::answerQuery() line 76
- new InvalidCommandLineException line 81
- method-call CatalogCommand::configuredAnalyzer() line 84
- new AnalysisOptions line 87
- method-call CatalogCommand::report() line 92
public function configuredAnalyzer(Configuration $configuration): AnalyzerLoads the requested configuration, reporting failures as configuration errors.
Parameters
$configuration | Configuration |
Returns
Throws
InvalidConfigurationException When loading or applying the configuration failsCalled from 1
Calls 3
- method-call Analyzer::withConfiguration() line 103
- new InvalidConfigurationException line 105
- function-call
sprintfline 105
public function answerQuery(CommandLine $command): ?CommandResultThe answer to a command line that asks for information, or null when it does not.
Parameters
$command | CommandLine |
Returns
Test cases 1
Called from 1
Calls 6
- new UsageText line 114
- method-call Analyzer::extensions() line 114
- static-call CommandResult::ok() line 116
- method-call UsageText::help() line 116
- method-call UsageText::extensions() line 119
- method-call UsageText::reporters() line 122
public function report(CommandLine $command, Catalog $catalog): CommandResultRenders the catalog where the command line asked for it.
Parameters
$command | CommandLine | |
$catalog | Catalog |
Returns
Throws
UnknownReporterException When the reporter is not registeredWriteFailureException When the report cannot be writtenTest cases 1
Called from 1
Calls 5
- method-call ReporterRegistry::get() line 133
- method-call CatalogCommand::status() line 134
- new CommandResult line 137
- function-call
implodeline 137 - method-call ArtifactWriter::write() line 140
public function status(CommandLine $command, Catalog $catalog): ExitCodeWhat to tell the shell about the statements that were found.
Parameters
$command | CommandLine | |
$catalog | Catalog |
Returns
Test cases 1
Called from 1
Calls 2
- class-const ExitCode::Success() line 151
- class-const ExitCode::FindingsReported() line 155
Private surface 4§
Implementation details, listed for orientation only.
private Analyzer $analyzerprivate ReporterRegistry $reportersprivate CommandLineParser $parserprivate ArtifactWriter $writerTest cases 14§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 14
CatalogCommandTest::testAnswerQueryListsTheExtensionsAndTheReporterscallsCatalogCommandTest::testConfiguredAnalyzerOverridesModelsWithoutLeakingThemcallsCatalogCommandTest::testExecuteAppliesTheFiltercallsCatalogCommandTest::testExecuteRefusesToRunWithoutAPathcallsCatalogCommandTest::testReportWritesIntoTheDirectoryItIsGivencallsCatalogCommandTest::testRunAnswersTheHelpcallsCatalogCommandTest::testRunCatalogsTheNamedPathOntoStandardOutputcallsCatalogCommandTest::testRunDoesNotLoadConfigurationWhenPrintingHelpcallsCatalogCommandTest::testRunLoadsCatalogSettingsAndAllowsCliOverridescallsCatalogCommandTest::testRunReportsAnInvalidCommandLinecallsCatalogCommandTest::testRunReportsAPathItCannotReadcallsCatalogCommandTest::testRunReportsConfigurationErrorscallsCatalogCommandTest::testRunReportsMissingConfigurationAsAnInvalidCommandLinecallsCatalogCommandTest::testStatusReportsFindingsOnlyWhenAskedTocalls