PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.17
Yatra – Travel Booking & Tour Operator Software v3.0.17
3.0.17 3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 All 85 releases
yatra / app / Upgrades / FreeUpgradeRegistry.php

FreeUpgradeRegistry.php in Yatra – Travel Booking & Tour Operator Software 3.0.17, at app/Upgrades/FreeUpgradeRegistry.php

59 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Upgrades;
6
7 use Yatra\Upgrades\Contracts\UpgradeStepInterface;
8 use Yatra\Upgrades\Versions\Upgrade_3_0_3;
9 use Yatra\Upgrades\Versions\Upgrade_3_0_5;
10 use Yatra\Upgrades\Versions\Upgrade_3_0_17;
11
12 /**
13 * Register Free upgrade steps (add a class per release when DB/data migration is required).
14 *
15 * Each step’s {@see UpgradeStepInterface::targetVersion()} is the release that introduced the
16 * migration (e.g. 3.0.3), not necessarily the current plugin version constant; the runner still applies
17 * all applicable steps when upgrading from an older stored `yatra_version` to the current code.
18 *
19 * @return list<class-string<UpgradeStepInterface>>
20 */
21 final class FreeUpgradeRegistry
22 {
23 /**
24 * @return list<class-string<UpgradeStepInterface>>
25 */
26 public static function allSteps(): array
27 {
28 return [
29 Upgrade_3_0_3::class,
30 Upgrade_3_0_5::class,
31 Upgrade_3_0_17::class,
32 ];
33 }
34
35 /**
36 * @return list<class-string<UpgradeStepInterface>>
37 */
38 public static function stepsForHook(string $hook): array
39 {
40 $out = [];
41 foreach (self::allSteps() as $class) {
42 if (in_array($hook, $class::runOnHooks(), true)) {
43 $out[] = $class;
44 }
45 }
46
47 // version_compare() with two args returns -1 / 0 / 1 — exactly
48 // what usort wants. Passing '<=>' as the operator (legacy mistake)
49 // throws a ValueError under PHP 8+ since '<=>' isn't in the
50 // operator allowlist; pre-PHP 8 it silently returned null and
51 // usort would have produced an unstable ordering anyway.
52 usort($out, static function (string $a, string $b): int {
53 return version_compare($a::targetVersion(), $b::targetVersion());
54 });
55
56 return $out;
57 }
58 }
59