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). Closes aspect and class map registration even when no proxies need to be generated.

Properties

static protected ClassLoader|null $proxyLoader
static protected array<string, string> $proxySources

The canonical source file of each generated proxy, keyed by canonical proxy file path.

Methods

void
bootstrap(Application $app)

Bootstrap the AOP proxy generation.

void
generate(string $proxyDir)

Generate and register proxies in the given directory before their targets load.

static array
proxySources()

Get the canonical source file of each generated proxy, keyed by canonical proxy file path.

void
ensureLoadedProxyCoversRules(string $class)

Reject already-loaded targets whose code cannot apply the registered aspects.

array
buildClassMap()

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

static void
flushState()

Flush all static state.

Details

at line 46
void bootstrap(Application $app)

Bootstrap the AOP proxy generation.

Parameters

Application $app

Return Value

void

at line 61
void generate(string $proxyDir)

Generate and register proxies in the given directory before their targets load.

Loaded classes cannot be replaced in the running process.

Parameters

string $proxyDir

Return Value

void

at line 113
static array proxySources()

Get the canonical source file of each generated proxy, keyed by canonical proxy file path.

Stack frames report the proxy file, so code that classifies frames by path (such as application versus vendor code) should classify the source instead.

Return Value

array

at line 121
protected void ensureLoadedProxyCoversRules(string $class)

Reject already-loaded targets whose code cannot apply the registered aspects.

Parameters

string $class

Return Value

void

at line 181
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 215
static void flushState()

Flush all static state.

Return Value

void