classCatalogIndex
final class CatalogIndex
The catalog grouped along every route a reader can take to a statement.
A reader rarely wants the whole catalog. They want the statements on one table, the ones a class issues, the ones in a file, or the ones a function writes with values it does not control. Each of those is a grouping of the same entries, and the groupings are built once here so every page addresses the same statement through the same keys.
Methods§
public function __construct(Catalog $catalog)Groups a catalog, in the order the report lists statements.
Parameters
$catalog | Catalog |
Calls 3
- method-call Catalog::sorted() line 39
- method-call Catalog::problems() line 40
- method-call Catalog::source() line 41
public function entries(): list<CatalogEntry>public function byTable(): array<string, list<CatalogEntry>>The statements naming each table, most named first.
Returns
array<string, list<CatalogEntry>>Test cases 2
Called from 3
- method-call SqlCatalog\Reporter\Html\CatalogIndex::alongside() packages/sql-catalog/src/Reporter/Html/CatalogIndex.php:255
- method-call SqlCatalog\Reporter\Html\Page\TablePage::anchors() packages/sql-catalog/src/Reporter/Html/Page/TablePage.php:202
- method-call SqlCatalog\Reporter\Html\ReportSite::__construct() packages/sql-catalog/src/Reporter/Html/ReportSite.php:85
public function byFunction(): array<string, list<CatalogEntry>>The statements each function issues, in the order the functions are met.
Returns
array<string, list<CatalogEntry>>Test cases 1
public function byClass(): array<string, list<CatalogEntry>>The statements each class issues through its methods, in name order.
Returns
array<string, list<CatalogEntry>>Test cases 2
Called from 1
Calls 2
- static-call Scope::of() line 101
- function-call
ksortline 106
public function byNamespace(): array<string, list<CatalogEntry>>The statements issued under each namespace, the global one first.
Returns
array<string, list<CatalogEntry>>Test cases 2
Calls 2
- static-call Scope::of() line 120
- function-call
ksortline 122
public function byFile(): array<string, list<CatalogEntry>>The statements written in each file, in path order.
Returns
array<string, list<CatalogEntry>>Test cases 2
Called from 2
Calls 1
- function-call
ksortline 138
public function byDirectory(): array<string, list<string>>The files under each directory, in path order.
Returns
array<string, list<string>>Test cases 2
Calls 4
- function-call
array_keysline 151 - method-call CatalogIndex::byFile() line 151
- function-call
strrposline 152 - function-call
substrline 153
public function byRule(): array<string, list<CatalogEntry>>The statements each rule reported on, most reported first.
Returns
array<string, list<CatalogEntry>>Test cases 1
public function usage(list<CatalogEntry> $entries): array{reads: int, writes: int, schema: int, other: int, attention: int}How a set of statements uses what it names.
Parameters
$entries | list<CatalogEntry> |
Returns
array{reads: int, writes: int, schema: int, other: int, attention: int}Test cases 1
Calls 2
- method-call CatalogIndex::usageOf() line 189
- class-const Severity::Medium() line 190
public function usageOf(CatalogEntry $entry): 'reads'|'writes'|'schema'|'other'Which use a statement is counted as.
Parameters
$entry | CatalogEntry |
Returns
'reads'|'writes'|'schema'|'other'Test cases 2
public function tablesOf(list<CatalogEntry> $entries): array<string, int>How often each table is named by a set of statements, most named first.
Parameters
$entries | list<CatalogEntry> |
Returns
array<string, int>Test cases 1
Calls 1
- method-call CatalogIndex::mostFirst() line 228
public function functionsOf(list<CatalogEntry> $entries): array<string, int>How many statements each function issues among a set, most first.
Parameters
$entries | list<CatalogEntry> |
Returns
array<string, int>Test cases 1
Calls 1
- method-call CatalogIndex::mostFirst() line 244
public function alongside(string $table): array<string, int>The tables named alongside one table, most often first.
Parameters
$table | string |
Returns
array<string, int>Test cases 1
Called from 1
Calls 2
- method-call CatalogIndex::byTable() line 255
- method-call CatalogIndex::mostFirst() line 263
public function hotspots(): list<array{function: string, file: string, high: int, medium: int}>The functions issuing statements that need attention, worst first.
Returns
list<array{function: string, file: string, high: int, medium: int}>Test cases 2
Calls 3
- class-const Severity::Medium() line 276
- class-const Severity::High() line 280
- function-call
usortline 283
public function mostFirst(array<string, int> $counts): array<string, int>Counts sorted highest first, ties in name order.
Parameters
$counts | array<string, int> |
Returns
array<string, int>Test cases 1
Called from 3
- method-call SqlCatalog\Reporter\Html\CatalogIndex::tablesOf() packages/sql-catalog/src/Reporter/Html/CatalogIndex.php:228
- method-call SqlCatalog\Reporter\Html\CatalogIndex::functionsOf() packages/sql-catalog/src/Reporter/Html/CatalogIndex.php:244
- method-call SqlCatalog\Reporter\Html\CatalogIndex::alongside() packages/sql-catalog/src/Reporter/Html/CatalogIndex.php:263
Calls 1
- function-call
uksortline 297
Private surface 2§
Implementation details, listed for orientation only.
private list<CatalogEntry> $entriesprivate array<string, list<CatalogEntry>> $unreadFiles = []Test cases 38§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 20
CatalogIndexTest::testAlongsideCountsTheTablesNamedWithOnecallsCatalogIndexTest::testByClassAndByNamespaceOrderNamesWithoutRegardToCasecallsCatalogIndexTest::testByClassGroupsMethodsUnderTheirClasscallsCatalogIndexTest::testByDirectoryGroupsFilesUnderTheirDirectorycallsCatalogIndexTest::testByFileIncludesUnreadFilesOnlyWhenTheirSourceCanBeShowncallsCatalogIndexTest::testByFileIsInPathOrdercallsCatalogIndexTest::testByFunctionKeepsTheOrderFunctionsAreMetcallsCatalogIndexTest::testByNamespaceListsTheGlobalNamespaceFirstcallsCatalogIndexTest::testByRuleListsTheMostReportedRuleFirstcallsCatalogIndexTest::testByTableBreaksTiesByNamecallsCatalogIndexTest::testByTableListsTheMostNamedTableFirstcallsCatalogIndexTest::testEntriesAreInReportingOrdercallsCatalogIndexTest::testFunctionsOfCountsMostFirstcallsCatalogIndexTest::testHotspotsKeepCountingPastAStatementNothingWasReportedOncallsCatalogIndexTest::testHotspotsRankFunctionsByWhatWasReportedcallsCatalogIndexTest::testMostFirstBreaksTiesByNamecallsCatalogIndexTest::testTablesOfCountsMostNamedFirstcallsCatalogIndexTest::testUsageCountsReadsWritesSchemaAndAttentioncallsCatalogIndexTest::testUsageOfCountsTruncateAsASchemaChangecallsCatalogIndexTest::testUsageOfTellsAReadFromAnotherStatementThatChangesNoRowcalls
Other tests reaching this symbol 18
ReporterInterfaceTestcallsHtmlReporterTestcallsClassPageTestcallsFileIndexPageTestcallsFilePageTestcallsFindingPageTestcallsNamespacePageTestcallsOverviewPageTestcallsStatementIndexPageTestcallsStatementPageTestcallsTableIndexPageTestcallsTablePageTest::testAnchorsFollowTheSectionsPresentcallsPageShellTestcallsReportSiteTestcallsSearchIndexTestcallsSourceCodeTestcallsStatementListTestcallsStatementRowTestcalls
Relations§
Instantiated in 1
Method calls 6
- method-call SqlCatalog\Reporter\Html\Page\TablePage::anchors() packages/sql-catalog/src/Reporter/Html/Page/TablePage.php:198
- method-call SqlCatalog\Reporter\Html\Page\TablePage::anchors() packages/sql-catalog/src/Reporter/Html/Page/TablePage.php:202
- method-call SqlCatalog\Reporter\Html\Page\TablePage::anchors() packages/sql-catalog/src/Reporter/Html/Page/TablePage.php:203
- method-call SqlCatalog\Reporter\Html\ReportSite::__construct() packages/sql-catalog/src/Reporter/Html/ReportSite.php:85
- method-call SqlCatalog\Reporter\Html\ReportSite::__construct() packages/sql-catalog/src/Reporter/Html/ReportSite.php:86
- method-call SqlCatalog\Reporter\Html\ReportSite::__construct() packages/sql-catalog/src/Reporter/Html/ReportSite.php:87
Type declarations 3
- type SqlCatalog\Reporter\Html\Page\TablePage packages/sql-catalog/src/Reporter/Html/Page/TablePage.php:195
- type SqlCatalog\Reporter\Html\ReportSite packages/sql-catalog/src/Reporter/Html/ReportSite.php:55
- type SqlCatalog\Reporter\Html\ReportSite packages/sql-catalog/src/Reporter/Html/ReportSite.php:101