| @@ -32,9 +32,9 @@ | ||
| 32 | 32 | * |
| 33 | 33 | * @param string $version Semver string, e.g. '1.2.0' |
| 34 | 34 | * @param callable $callback Boot callback — called only if this version wins. |
| 35 | 35 | */ |
| 36 | - public static function register(string $version, callable $callback) : void | |
| 36 | + public static function register(string $version, callable $callback): void | |
| 37 | 37 | { |
| 38 | 38 | // First-wins: do not overwrite an already-registered version. |
| 39 | 39 | if (isset(self::$candidates[$version])) { |
| 40 | 40 | return; |
| @@ -42,9 +42,9 @@ | ||
| 42 | 42 | self::$candidates[$version] = $callback; |
| 43 | 43 | // Schedule election to run after all plugins_loaded callbacks. |
| 44 | 44 | // We use priority 999 so all candidates at default priority register first. |
| 45 | 45 | if (!self::$elected) { |
| 46 | - \add_action('plugins_loaded', [self::class, 'elect'], 999); | |
| 46 | + add_action('plugins_loaded', [self::class, 'elect'], 999); | |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | /** |
| 50 | 50 | * Run after all plugins_loaded hooks. Pick highest version and invoke its callback. |
| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | /** |
| 50 | 50 | * Run after all plugins_loaded hooks. Pick highest version and invoke its callback. |
| 51 | 51 | * Idempotent — second call is a no-op. |
| 52 | 52 | */ |
| 53 | - public static function elect() : void | |
| 53 | + public static function elect(): void | |
| 54 | 54 | { |
| 55 | 55 | if (self::$elected || empty(self::$candidates)) { |
| 56 | 56 | return; |
| 57 | 57 | } |
| @@ -56,10 +56,10 @@ | ||
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | 58 | self::$elected = \true; |
| 59 | 59 | $winner = null; |
| 60 | - foreach (\array_keys(self::$candidates) as $version) { | |
| 61 | - if ($winner === null || \version_compare($version, $winner, '>')) { | |
| 60 | + foreach (array_keys(self::$candidates) as $version) { | |
| 61 | + if ($winner === null || version_compare($version, $winner, '>')) { | |
| 62 | 62 | $winner = $version; |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | if ($winner !== null && isset(self::$candidates[$winner])) { |
| @@ -68,16 +68,16 @@ | ||
| 68 | 68 | } |
| 69 | 69 | /** |
| 70 | 70 | * Return the winning version string, or null if election hasn't run. |
| 71 | 71 | */ |
| 72 | - public static function get_elected_version() : ?string | |
| 72 | + public static function get_elected_version(): ?string | |
| 73 | 73 | { |
| 74 | 74 | if (!self::$elected || empty(self::$candidates)) { |
| 75 | 75 | return null; |
| 76 | 76 | } |
| 77 | 77 | $winner = null; |
| 78 | - foreach (\array_keys(self::$candidates) as $version) { | |
| 79 | - if ($winner === null || \version_compare($version, $winner, '>')) { | |
| 78 | + foreach (array_keys(self::$candidates) as $version) { | |
| 79 | + if ($winner === null || version_compare($version, $winner, '>')) { | |
| 80 | 80 | $winner = $version; |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | return $winner; |
| @@ -84,9 +84,9 @@ | ||
| 84 | 84 | } |
| 85 | 85 | /** |
| 86 | 86 | * Reset state — only for unit tests. |
| 87 | 87 | */ |
| 88 | - public static function reset() : void | |
| 88 | + public static function reset(): void | |
| 89 | 89 | { |
| 90 | 90 | self::$candidates = []; |
| 91 | 91 | self::$elected = \false; |
| 92 | 92 | } |