Quick Pointcut Reference
Method execution
Syntax: execution(MemberModifiers ClassFilter[::|->]NamePattern(*))
execution(public Example->method(*))
- Every execution of public method with the name “method” in the class “Example”execution(public Example->method1|method2(*))
- Every execution of one of the methods: “method1” or “method2” in the class “Example”execution(* Example\Aspect\*->method*(*))
- Execution of public or protected methods that have “method” prefix in their names and that methods are also inside “Example\Aspect” subnamespace (only single subnamespace)execution(public **::staticMethods(*))
- Every execution of any public static method “staticMethods” in every namespace (except global one)
Annotation syntax: @execution(NamespacePattern)
@execution(Demo\Annotation\Cacheable)
- Every execution of any method that has “Demo\Annotation\Cacheable” annotation in the docBlock
Property access
Syntax: access(MemberModifiers ClassFilter->NamePattern)
access(public Example\Demo->test)
- Every access to the public property “test” in the class “Example\Demo”access(* Example\Aspect\*->fieldName)
- Every access (read and write) to a property “fieldName” (both protected and public) which belongs to a classes inside “Example\Aspect” subnamespace.access(protected **->someProtected*Property)
- Every access to the protected properties with names, that match “someProtected*Property” pattern in all classes.
Annotation syntax: @access(NamespacePattern)
@access(Demo\Annotation\Cacheable)
- Every access to the property that has “Demo\Annotation\Cacheable” annotation in the docBlock
Function execution
Syntax: execution(NamespacePattern(*))
execution(**\file_get_contents())
- Every execution of system function “file_get_contents” within all namespacesexecution(Example\Aspect\array_*(*))
- Every execution of any system function “array_*” within “Example\Aspect” namespace
Initialization
Syntax: initialization(NamespacePattern)
initialization(Demo\Example)
- Every initialization of object “Demo\Example” when “new Demo\Example()” is calledinitialization(Demo\**)
- Every initialization of object within “Demo” subnamespaces.
Syntax: staticinitialization(NamespacePattern)
staticinitialization(Demo\Example)
- First time when the class “Demo\Example” is loaded into the memory of PHPstaticinitialization(Demo\**)
- First time of loading of any class within “Demo” subnamespace into the memory of PHP
Lexical pointcuts
Syntax: within(ClassFilter)
within(Demo\Example)
- Every property access, method execution, initialization within “Demo\Example” class@within(Demo\Annotation\Loggable)
- Every property access, method execution, initialization within class that has “Demo\Annotation\Loggable” annotation in the docBlock
Logical combination
Logical negation syntax: !Pointcut
!execution(public **->*(*))
- Every execution of any method that is not public.
Logical conjunction syntax: Pointcut && Pointcut
execution(* Demo->*(*)) && execution(public **->*(*))
- Every execution of public method in the class “Demo”
Logical disjunction syntax: Pointcut || Pointcut
access(public Demo->foo) || access(public Another->bar)
- Every access to the properties “Demo->foo” or “Another->bar”
Grouping pointcuts with parenthesis syntax: (Pointcut)
(access(* Demo->*) || access(* Another->*)) && access(public **->*)