-
-
Notifications
You must be signed in to change notification settings - Fork 462
feat(scope): add getGlobalEventProcessors method #1990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(scope): add getGlobalEventProcessors method #1990
Conversation
Add a public getter method for global event processors to enable testing and introspection of registered processors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a public getter method getGlobalEventProcessors() to the Scope class to enable testing and introspection of registered global event processors. The change also refactors the applyToEvent() method to use this new getter for consistency.
Key Changes:
- Added public static method
getGlobalEventProcessors()that returns the array of global event processors - Refactored
applyToEvent()to use the new getter method instead of directly accessing the static property
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Get the global event processors {@see Scope::applyToEvent}. | ||
| */ | ||
| public static function getGlobalEventProcessors(): array | ||
| { | ||
| return self::$globalEventProcessors; | ||
| } | ||
|
|
||
| /** |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type annotation is incomplete. The method should include a psalm-var annotation to match the type annotation on the property definition (lines 91-93). This is important for static analysis tools to understand that the returned array contains callables with a specific signature.
Consider adding the psalm annotation:
@psalm-return array<callable(Event, EventHint): ?Event>
| return self::$globalEventProcessors; | ||
| } | ||
|
|
||
| /** |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new public method getGlobalEventProcessors() lacks test coverage. Since this codebase has comprehensive test coverage for the Scope class (as seen in tests/State/ScopeTest.php), this new public API should include tests to verify it returns the correct array of global event processors, especially after calling addGlobalEventProcessor().
|
Additional note for long-lived framework environments: In long-running, persistent frameworks (such as Swoole, RoadRunner, or similar setups), it is possible to leverage AOP at appropriate lifecycle boundaries (e.g. request start/end, coroutine creation) to capture a snapshot of This approach provides several benefits:
Exposing |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
getGlobalEventProcessors()static method toScopeclassapplyToEvent()to use the new getter method for consistencyChanges
src/State/Scope.php:getGlobalEventProcessors()that returns the array of global event processorsapplyToEvent()to callself::getGlobalEventProcessors()instead of directly accessingself::$globalEventProcessorsMotivation
This change provides a public API for accessing the global event processors, which is useful for:
Test plan