1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Psh\ScriptRuntime\Execution; |
4
|
|
|
|
5
|
|
|
use Shopware\Psh\Config\Template; |
6
|
|
|
use Shopware\Psh\Config\ValueProvider; |
7
|
|
|
use Symfony\Component\Process\Process; |
8
|
|
|
use Webmozart\Assert\Assert; |
9
|
|
|
use function array_merge; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Create representation of the current environment variables and constants |
13
|
|
|
*/ |
14
|
|
|
class ProcessEnvironment |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var ValueProvider[] |
18
|
|
|
*/ |
19
|
|
|
private $constants; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var ValueProvider[] |
23
|
|
|
*/ |
24
|
|
|
private $variables; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var Template[] |
28
|
|
|
*/ |
29
|
|
|
private $templates; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var ValueProvider[] |
33
|
|
|
*/ |
34
|
|
|
private $dotenvVariables; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param ValueProvider[] $constants |
38
|
|
|
* @param ValueProvider[] $variables |
39
|
|
|
* @param Template[] $templates |
40
|
|
|
* @param ValueProvider[] $dotenvVars |
41
|
|
|
*/ |
42
|
|
|
public function __construct(array $constants, array $variables, array $templates, array $dotenvVars) |
43
|
|
|
{ |
44
|
|
|
Assert::allIsInstanceOf($constants, ValueProvider::class); |
|
|
|
|
45
|
|
|
Assert::allIsInstanceOf($variables, ValueProvider::class); |
|
|
|
|
46
|
|
|
Assert::allIsInstanceOf($dotenvVars, ValueProvider::class); |
|
|
|
|
47
|
|
|
Assert::allIsInstanceOf($templates, Template::class); |
|
|
|
|
48
|
|
|
|
49
|
|
|
$this->constants = $constants; |
50
|
|
|
$this->variables = $variables; |
51
|
|
|
$this->templates = $templates; |
52
|
|
|
$this->dotenvVariables = $dotenvVars; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return ValueProvider[] |
57
|
|
|
*/ |
58
|
|
|
public function getAllValues(): array |
59
|
|
|
{ |
60
|
|
|
return array_merge( |
61
|
|
|
$this->constants, |
62
|
|
|
$this->dotenvVariables, |
63
|
|
|
$this->variables |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return Template[] |
69
|
|
|
*/ |
70
|
|
|
public function getTemplates(): array |
71
|
|
|
{ |
72
|
|
|
return $this->templates; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function createProcess(string $shellCommand): Process |
76
|
|
|
{ |
77
|
|
|
return Process::fromShellCommandline($shellCommand); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.