Class Scanner
Scan configured application and plugin paths for PHP attributes.
Constants
-
MAX_FILE_SIZE ¶
10 * 1024 * 1024Maximum file size in bytes (10MB).
Method Summary
-
__construct() public
Configure attribute parsing and source paths.
-
buildFinder() protected
Build file iterators, narrowing source-only scans while retaining root-relative globs.
-
getLoadedPlugins() protected
Get loaded plugins that should be scanned.
Returns a consistent list of all loaded plugins regardless of execution context (CLI vs web). This ensures attribute discovery is atomic and cache is consistent.
Excludes only:
- Unknown plugins (configured but not installed)
- Debug-only plugins when debug mode is disabled
Includes CLI-only plugins even in web context to maintain cache consistency. Also includes plugins loaded dynamically via the Plugin class that may not be in the static configuration.
-
getScannedFiles() public
Get the list of files that were scanned.
-
resolveBasePaths() protected
Resolve canonical base paths, merging aliases while preserving plugin information.
-
scanAll() public
Scan all configured paths and yield discovered attributes.
Expands relative paths against APP root and all loaded plugin paths.
Method Detail
__construct() ¶ public
__construct(Cake\AttributeResolver\Parser $parser, array<string> $paths = [], array<string> $excludePaths = [], string|null $basePath = null)
Configure attribute parsing and source paths.
Parameters
-
Cake\AttributeResolver\Parser$parser Attribute parser
-
array<string>$paths optional Relative glob patterns to scan (e.g., ['src/*\/.php'])
-
array<string>$excludePaths optional Directory names or path filters to exclude
-
string|null$basePath optional Base directory path (defaults to ROOT + all plugins)
buildFinder() ¶ protected
buildFinder(): Iterator<SplFileInfo>
Build file iterators, narrowing source-only scans while retaining root-relative globs.
Returns
Iterator<SplFileInfo>getLoadedPlugins() ¶ protected
getLoadedPlugins(): array<array{path: string, plugin: string}>
Get loaded plugins that should be scanned.
Returns a consistent list of all loaded plugins regardless of execution context (CLI vs web). This ensures attribute discovery is atomic and cache is consistent.
Excludes only:
- Unknown plugins (configured but not installed)
- Debug-only plugins when debug mode is disabled
Includes CLI-only plugins even in web context to maintain cache consistency. Also includes plugins loaded dynamically via the Plugin class that may not be in the static configuration.
Returns
array<array{path: string, plugin: string}>getScannedFiles() ¶ public
getScannedFiles(): array<string>
Get the list of files that were scanned.
Returns
array<string>resolveBasePaths() ¶ protected
resolveBasePaths(): array<array{path: string, plugin: (string|null)}>
Resolve canonical base paths, merging aliases while preserving plugin information.
Returns
array<array{path: string, plugin: (string|null)}>scanAll() ¶ public
scanAll(): Generator<Cake\AttributeResolver\ValueObject\AttributeInfo>
Scan all configured paths and yield discovered attributes.
Expands relative paths against APP root and all loaded plugin paths.
Returns
Generator<Cake\AttributeResolver\ValueObject\AttributeInfo>