1 | <?php |
||
12 | final class AssistedWebContextParam implements ParamInterface |
||
13 | { |
||
14 | /** |
||
15 | * $GLOBALS for testing |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private static $globals = []; |
||
20 | |||
21 | /** |
||
22 | * @var AbstractWebContextParam |
||
23 | */ |
||
24 | private $webContextParam; |
||
25 | |||
26 | /** |
||
27 | * @var ParamInterface |
||
28 | */ |
||
29 | private $defaultParam; |
||
30 | |||
31 | 5 | public function __construct(AbstractWebContextParam $webContextParam, ParamInterface $defaultParam) |
|
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 4 | public function __invoke($varName, array $query, InjectorInterface $injector) |
|
52 | |||
53 | 5 | public static function setSuperGlobalsOnlyForTestingPurpose(array $globals) |
|
57 | } |
||
58 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: