[BC Break] Drop support for the "dynamic" pointcut type#583
Merged
Conversation
The dynamic(...) pointcut was the only pointcut requiring runtime matching, forcing extra machinery through the whole pointcut layer: the KIND_DYNAMIC flag, the runtime-wrapping DynamicInvocationMatcherInterceptor and the $instanceOrScope/$arguments parameters threaded through Pointcut::matches() in every implementation. The same behavior is achievable with a traditional execution pointcut for the __call/__callStatic magic methods plus a method-name check inside the advice, as now shown by the updated DynamicMethodsAspect demo. * Remove MagicMethodDynamicPointcut and DynamicInvocationMatcherInterceptor * Remove the "dynamic" lexer token and the dynamicExecutionPointcut grammar rule, regenerate the LALR parse table * Remove Pointcut::KIND_DYNAMIC and the $instanceOrScope/$arguments parameters of Pointcut::matches() from the interface and all implementations * Simplify GenericPointcutAdvisor::getAdvice() to a plain advice getter * Convert the DynamicMethodsAspect demo to traditional execution pointcuts as a migration example * Document the BC break in the CHANGELOG Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
lisachenko
force-pushed
the
chore/drop-dynamic-pointcut-type
branch
from
July 18, 2026 21:54
e144291 to
053e0b6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the
dynamic(...)pointcut type for 4.0.0. It was the only pointcut requiring runtime matching, and it forced extra machinery through the whole pointcut layer:Pointcut::KIND_DYNAMICflag,DynamicInvocationMatcherInterceptor,$instanceOrScope/$argumentsparameters threaded throughPointcut::matches()in every implementation.The same behavior is achievable with a traditional
execution()pointcut for the__call/__callStaticmagic methods plus a method-name check inside the advice.BC Break / Migration
Instead of:
#[Before('dynamic(public Demo\Example\DynamicMethodsDemo->save*(*))')]use a traditional execution pointcut on the magic method and filter by the real method name (first invocation argument) inside the advice:
(and
execution(public Foo::__callStatic(*))for the static counterpart). TheDynamicMethodsAspectdemo has been converted to this pattern as a live migration example, producing identical output. The BC break is documented in the CHANGELOG.Changes
MagicMethodDynamicPointcut,DynamicInvocationMatcherInterceptorand their testsdynamiclexer token and thedynamicExecutionPointcutgrammar rule; regenerated the LALR parse table via the Dissect analyzerPointcut::KIND_DYNAMICand the$instanceOrScope/$argumentsparameters ofPointcut::matches()— clean 2-arg signature across the interface and all 11 implementations; interface docblock now describes static matching onlyGenericPointcutAdvisor::getAdvice()simplified to a plain gettersrc/Aop/AGENTS.mdUnrelated names using "dynamic" in the instance-vs-static sense (
DynamicMethodInvocation,isDynamic(), the dynamic-traits demo) are intentionally untouched.Testing
vendor/bin/phpunit: all 2471 tests passvendor/bin/phpstan analyse --memory-limit=1G: no errorsdynamic(...)now throwsUnexpectedTokenException; all other pointcut syntaxes still parse?showcase=dynamic-interceptorwith cleared cache):saveById/findintercepted,loadfiltered out — identical observable behavior to the olddynamic()pointcut🤖 Generated with Claude Code