key = last_key(self::$stack); PhabricatorEnv::setLocaleCode($code); } public function __destruct() { if ($this->destroyed) { return; } $this->destroyed = true; // Remove this locale from the stack and set the new active locale. Usually, // we're the last item on the stack, so this shortens the stack by one item // and sets the locale underneath. However, it's possible that guards are // being destroyed out of order, so we might just be removing an item // somewhere in the middle of the stack. In this case, we won't actually // change the locale, just set it to its current value again. unset(self::$stack[$this->key]); PhabricatorEnv::setLocaleCode(end(self::$stack)); } }