| @@ -44,15 +44,25 @@ | ||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public static function make($disableCoupon = false): ?CartCheckoutHelper |
| 47 | 47 | { |
| 48 | - static $instance = null; | |
| 48 | + if (!self::$instance) { | |
| 49 | + self::$instance = new self($disableCoupon); | |
| 50 | + } | |
| 49 | 51 | |
| 50 | - if (!$instance) { | |
| 51 | - $instance = new self($disableCoupon); | |
| 52 | - } | |
| 52 | + return self::$instance; | |
| 53 | + } | |
| 53 | 54 | |
| 54 | - return $instance; | |
| 55 | + /** | |
| 56 | + * Drop the request-scoped instance so the next make() re-initializes from | |
| 57 | + * the current request's cart. Production runs one request per process and | |
| 58 | + * never needs this; long-lived processes (the test suites) call it before | |
| 59 | + * each dispatched request so a helper bound to an earlier cart cannot leak | |
| 60 | + * into the next checkout. | |
| 61 | + */ | |
| 62 | + public static function resetInstance(): void | |
| 63 | + { | |
| 64 | + self::$instance = false; | |
| 55 | 65 | } |
| 56 | 66 | |
| 57 | 67 | |
| 58 | 68 | public function init() |