Skip to content

Commit

Permalink
fix: Ensured parsed priority is int
Browse files Browse the repository at this point in the history
  • Loading branch information
seebeen committed Mar 15, 2024
1 parent 5215e7a commit d618aab
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Decorators/Base_Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ public function __construct(
* @return int
*/
private function parse_priority( array|int|string $prio ): int {
return match ( true ) {
is_numeric( $prio ) => (int) $prio,
is_array( $prio ) => call_user_func( $prio ),
is_callable( $prio ) => $prio(),
is_string( $prio ) => apply_filters( $prio, 10, $this->tag ),
$prio = match ( true ) {
\is_numeric( $prio ) => (int) $prio,
\is_array( $prio ) => \call_user_func( $prio ),
\is_callable( $prio ) => $prio(),
\is_string( $prio ) => \apply_filters( $prio, 10, $this->tag ),
default => 10,
};
} ?? 10;

return (int) $prio;
}

/**
Expand Down Expand Up @@ -95,8 +97,8 @@ private function add_to_registry( mixed ...$args ) {

static::$registry[ $class ][ $method ] ??= array();
static::$registry[ $class ][ $method ][] = array(
'tag' => $this->tag,
'priority' => $this->priority,
'tag' => $this->tag,
);
}
}

0 comments on commit d618aab

Please sign in to comment.