Simplify EventDispatcher methods and remove redundant descriptions - #722
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors flight\core\EventDispatcher to reduce redundant PHPDoc, modernize type annotations, and simplify listener management and dispatch logic.
Changes:
- Simplified listener registration and cleanup logic (
??=,array_filter+array_values, unconditionalunset). - Updated PHPDoc array type annotations to short-form (
callable[],string[]) and trimmed redundant method descriptions. - Refactored
trigger()loop to a more direct invocation style with early-exit onfalse.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
This pull request refactors the
EventDispatcherclass to simplify and modernize its implementation, primarily by removing redundant comments, improving type annotations, and streamlining logic for managing event listeners.Code cleanup and modernization:
array<int, callable>withcallable[]) and used the null coalescing assignment operator (??=) for initializing event listener arrays.Logic improvements:
triggermethod to use direct variadic calls and early exit onfalsereturn, improving readability and performance.hasListenersmethod to include an explicit array check and count, ensuring more robust listener detection.removeListenerby usingarray_filterwith a static closure and early return if no listeners exist.