@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3/**
4 * Scope guard to hold a temporary environment. See @{class:PhabricatorEnv} for
5 * instructions on use.
6 *
7 * @task internal Internals
8 * @task override Overriding Environment Configuration
9 */
10final class PhabricatorScopedEnv extends Phobject {
11
12 private $key;
13 private $isPopped = false;
14
15/* -( Overriding Environment Configuration )------------------------------- */
16
17 /**
18 * Override a configuration key in this scope, setting it to a new value.
19 *
20 * @param string $key Key to override.
21 * @param mixed $value New value.
22 * @return $this
23 *
24 * @task override
25 */
26 public function overrideEnvConfig($key, $value) {
27 PhabricatorEnv::overrideTestEnvConfig(
28 $this->key,
29 $key,
30 $value);
31 return $this;
32 }
33
34
35/* -( Internals )---------------------------------------------------------- */
36
37
38 /**
39 * @task internal
40 */
41 public function __construct($stack_key) {
42 $this->key = $stack_key;
43 }
44
45
46 /**
47 * Release the scoped environment.
48 *
49 * @return void
50 * @task internal
51 */
52 public function __destruct() {
53 if (!$this->isPopped) {
54 PhabricatorEnv::popTestEnvironment($this->key);
55 $this->isPopped = true;
56 }
57 }
58
59}