Skip to content

Simplify EventDispatcher methods and remove redundant descriptions - #722

Merged
n0nag0n merged 12 commits into
masterfrom
eventdispatcher-rework
Aug 17, 2026
Merged

Simplify EventDispatcher methods and remove redundant descriptions#722
n0nag0n merged 12 commits into
masterfrom
eventdispatcher-rework

Conversation

@fadrian06

Copy link
Copy Markdown
Contributor

This pull request refactors the EventDispatcher class 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:

  • Removed redundant PHPDoc comments and simplified type annotations for properties and methods, making the codebase cleaner and easier to maintain.
  • Updated array type hints (e.g., replaced array<int, callable> with callable[]) and used the null coalescing assignment operator (??=) for initializing event listener arrays.

Logic improvements:

  • Refactored the trigger method to use direct variadic calls and early exit on false return, improving readability and performance.
  • Improved the hasListeners method to include an explicit array check and count, ensuring more robust listener detection.
  • Simplified listener removal logic in removeListener by using array_filter with a static closure and early return if no listeners exist.

Copilot AI lite review requested due to automatic review settings August 16, 2026 06:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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, unconditional unset).
  • 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 on false.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread flight/core/EventDispatcher.php
Comment thread flight/core/EventDispatcher.php
@n0nag0n
n0nag0n merged commit 5372672 into master Aug 17, 2026
22 checks passed
@n0nag0n
n0nag0n deleted the eventdispatcher-rework branch August 17, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants