Skip to content

Commit

Permalink
fix(better-wp-hooks): allow null as first arg for mapped filters
Browse files Browse the repository at this point in the history
Fix: #158
  • Loading branch information
calvinalkan committed Dec 6, 2022
1 parent 86a4e9f commit 47e505a
Show file tree
Hide file tree
Showing 2 changed files with 356 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Snicco\Component\BetterWPHooks\WPHookAPI;
use Snicco\Component\EventDispatcher\EventDispatcher;

use function array_key_exists;
use function array_key_first;
use function count;
use function in_array;
Expand Down Expand Up @@ -175,10 +176,10 @@ private function dispatchMappedFilter(string $event_class): callable
return function (...$args_from_wordpress_hooks) use ($event_class) {
$event = $this->event_factory->make($event_class, $args_from_wordpress_hooks);

if (! isset($args_from_wordpress_hooks[0])) {
if (! array_key_exists(0,$args_from_wordpress_hooks)) {
// @codeCoverageIgnoreStart
throw new RuntimeException(
sprintf('Event mapper received invalid arguments from WP for mapped hook [%s].', $event_class)
sprintf('Event mapper received invalid arguments from WP for mapped hook [%s].', $event_class),
);
// @codeCoverageIgnoreEnd
}
Expand Down

0 comments on commit 47e505a

Please sign in to comment.