class GenerateProxies

Generate AOP proxy classes for registered aspects.

Runs after all service providers have been registered (so all aspects() calls have executed) and before boot() (so no targeted classes have been instantiated yet). No-ops when no aspects are registered.

Properties

static protected null|array<string, string> $sourceClassMap

The source class map used for proxy generation.

Methods

void
bootstrap(Application $app)

Bootstrap the AOP proxy generation.

array
buildClassMap()

Build a class map that includes both Composer's static class map and any PSR-4 classes referenced by exact aspect rules.

array
mergeSourceClassMap(array $classMap)

Merge Composer's current class map into the proxy source map.

static void
flushState()

Flush the captured source class map.

Details

at line 34
void bootstrap(Application $app)

Bootstrap the AOP proxy generation.

Parameters

Application $app

Return Value

void

at line 65
protected array buildClassMap()

Build a class map that includes both Composer's static class map and any PSR-4 classes referenced by exact aspect rules.

Composer's getClassMap() only contains explicitly mapped classes, not PSR-4 classes resolved at runtime. For exact class rules (no wildcards), we resolve the file path via findFile() so that PSR-4 classes are eligible for proxying.

Wildcard rules only match against the existing class map.

Return Value

array

className => filePath

at line 104
protected array mergeSourceClassMap(array $classMap)

Merge Composer's current class map into the proxy source map.

Runtime class-map overrides are legitimate source entries and may be registered after the first application boot. Generated proxy paths are excluded because they point at boot artifacts, not source files.

Parameters

array $classMap

Return Value

array

at line 128
static void flushState()

Flush the captured source class map.

Tests only. This is for tests that swap Composer's loader before proxy generation; do not register it with the global after-test subscriber because normal test cleanup runs after proxy paths have already been added to the loader. Flushing mid-worker loses accumulated findFile() resolutions for already-proxied PSR-4 classes, so those classes are skipped from regeneration until the loader is swapped or the process restarts.

Return Value

void