forked from sebastianbergmann/phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJob.php
138 lines (122 loc) · 3.1 KB
/
Job.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Util\PHP;
/**
* @immutable
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final readonly class Job
{
/**
* @var non-empty-string
*/
private string $code;
/**
* @var list<string>
*/
private array $phpSettings;
/**
* @var array<string, string>
*/
private array $environmentVariables;
/**
* @var list<non-empty-string>
*/
private array $arguments;
/**
* @var ?non-empty-string
*/
private ?string $input;
private bool $redirectErrors;
/**
* @param non-empty-string $code
* @param list<string> $phpSettings
* @param array<string, string> $environmentVariables
* @param list<non-empty-string> $arguments
* @param ?non-empty-string $input
*/
public function __construct(string $code, array $phpSettings = [], array $environmentVariables = [], array $arguments = [], ?string $input = null, bool $redirectErrors = false)
{
$this->code = $code;
$this->phpSettings = $phpSettings;
$this->environmentVariables = $environmentVariables;
$this->arguments = $arguments;
$this->input = $input;
$this->redirectErrors = $redirectErrors;
}
/**
* @return non-empty-string
*/
public function code(): string
{
return $this->code;
}
/**
* @return list<string>
*/
public function phpSettings(): array
{
return $this->phpSettings;
}
/**
* @phpstan-assert-if-true !empty $this->environmentVariables
*/
public function hasEnvironmentVariables(): bool
{
return $this->environmentVariables !== [];
}
/**
* @return array<string, string>
*/
public function environmentVariables(): array
{
return $this->environmentVariables;
}
/**
* @phpstan-assert-if-true !empty $this->arguments
*/
public function hasArguments(): bool
{
return $this->arguments !== [];
}
/**
* @return list<non-empty-string>
*/
public function arguments(): array
{
return $this->arguments;
}
/**
* @phpstan-assert-if-true !empty $this->input
*/
public function hasInput(): bool
{
return $this->input !== null;
}
/**
* @throws PhpProcessException
*
* @return non-empty-string
*/
public function input(): string
{
if ($this->input === null) {
throw new PhpProcessException('No input specified');
}
return $this->input;
}
public function redirectErrors(): bool
{
return $this->redirectErrors;
}
}