1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Phel\Config; |
6
|
|
|
|
7
|
|
|
use JsonSerializable; |
8
|
|
|
|
9
|
|
|
final class PhelConfig implements JsonSerializable |
10
|
|
|
{ |
11
|
|
|
public const SRC_DIRS = 'src-dirs'; |
12
|
|
|
|
13
|
|
|
public const TEST_DIRS = 'test-dirs'; |
14
|
|
|
|
15
|
|
|
public const VENDOR_DIR = 'vendor-dir'; |
16
|
|
|
|
17
|
|
|
public const BUILD_CONFIG = 'out'; |
18
|
|
|
|
19
|
|
|
public const ERROR_LOG_FILE = 'error-log-file'; |
20
|
|
|
|
21
|
|
|
public const EXPORT_CONFIG = 'export'; |
22
|
|
|
|
23
|
|
|
public const IGNORE_WHEN_BUILDING = 'ignore-when-building'; |
24
|
|
|
|
25
|
|
|
public const NO_CACHE_WHEN_BUILDING = 'no-cache-when-building'; |
26
|
|
|
|
27
|
|
|
public const KEEP_GENERATED_TEMP_FILES = 'keep-generated-temp-files'; |
28
|
|
|
|
29
|
|
|
public const TEMP_DIR = 'temp-dir'; |
30
|
|
|
|
31
|
|
|
public const FORMAT_DIRS = 'format-dirs'; |
32
|
|
|
|
33
|
|
|
/** @var list<string> */ |
|
|
|
|
34
|
|
|
private array $srcDirs = ['src']; |
35
|
|
|
|
36
|
|
|
/** @var list<string> */ |
37
|
|
|
private array $testDirs = ['tests']; |
38
|
|
|
|
39
|
|
|
private string $vendorDir = 'vendor'; |
40
|
|
|
|
41
|
|
|
private string $errorLogFile = '/tmp/phel-error.log'; |
42
|
|
|
|
43
|
|
|
private PhelExportConfig $exportConfig; |
44
|
|
|
|
45
|
|
|
private PhelBuildConfig $buildConfig; |
46
|
|
|
|
47
|
|
|
/** @var list<string> */ |
48
|
|
|
private array $ignoreWhenBuilding = ['ignore-when-building.phel']; |
49
|
|
|
|
50
|
|
|
/** @var list<string> */ |
51
|
|
|
private array $noCacheWhenBuilding = []; |
52
|
|
|
|
53
|
|
|
private bool $keepGeneratedTempFiles = false; |
54
|
|
|
|
55
|
|
|
private string $tempDir; |
56
|
|
|
|
57
|
|
|
/** @var list<string> */ |
58
|
|
|
private array $formatDirs = ['src', 'tests']; |
59
|
|
|
|
60
|
8 |
|
public function __construct() |
61
|
|
|
{ |
62
|
8 |
|
$this->exportConfig = new PhelExportConfig(); |
63
|
8 |
|
$this->buildConfig = new PhelBuildConfig(); |
64
|
8 |
|
$this->tempDir = sys_get_temp_dir() . '/phel'; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param list<string> $list |
69
|
|
|
*/ |
70
|
7 |
|
public function setSrcDirs(array $list): self |
71
|
|
|
{ |
72
|
7 |
|
$this->srcDirs = $list; |
|
|
|
|
73
|
|
|
|
74
|
7 |
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param list<string> $list |
79
|
|
|
*/ |
80
|
1 |
|
public function setTestDirs(array $list): self |
81
|
|
|
{ |
82
|
1 |
|
$this->testDirs = $list; |
|
|
|
|
83
|
|
|
|
84
|
1 |
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
5 |
|
public function setVendorDir(string $dir): self |
88
|
|
|
{ |
89
|
5 |
|
$this->vendorDir = $dir; |
90
|
|
|
|
91
|
5 |
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
1 |
|
public function setExportConfig(PhelExportConfig $exportConfig): self |
95
|
|
|
{ |
96
|
1 |
|
$this->exportConfig = $exportConfig; |
97
|
|
|
|
98
|
1 |
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
1 |
|
public function setErrorLogFile(string $filepath): self |
102
|
|
|
{ |
103
|
1 |
|
$this->errorLogFile = $filepath; |
104
|
|
|
|
105
|
1 |
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @deprecated use `setBuildConfig(PhelBuildConfig)` |
110
|
|
|
*/ |
111
|
|
|
public function setOut(PhelBuildConfig $buildConfig): self |
112
|
|
|
{ |
113
|
|
|
return $this->setBuildConfig($buildConfig); |
114
|
|
|
} |
115
|
|
|
|
116
|
5 |
|
public function setBuildConfig(PhelBuildConfig $buildConfig): self |
117
|
|
|
{ |
118
|
5 |
|
$this->buildConfig = $buildConfig; |
119
|
|
|
|
120
|
5 |
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param list<string> $list |
125
|
|
|
*/ |
126
|
5 |
|
public function setIgnoreWhenBuilding(array $list): self |
127
|
|
|
{ |
128
|
5 |
|
$this->ignoreWhenBuilding = $list; |
|
|
|
|
129
|
|
|
|
130
|
5 |
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
1 |
|
public function setKeepGeneratedTempFiles(bool $flag): self |
134
|
|
|
{ |
135
|
1 |
|
$this->keepGeneratedTempFiles = $flag; |
136
|
|
|
|
137
|
1 |
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
1 |
|
public function setTempDir(string $dir): self |
141
|
|
|
{ |
142
|
1 |
|
$this->tempDir = rtrim($dir, DIRECTORY_SEPARATOR); |
143
|
|
|
|
144
|
1 |
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param list<string> $list |
149
|
|
|
*/ |
150
|
1 |
|
public function setFormatDirs(array $list): self |
151
|
|
|
{ |
152
|
1 |
|
$this->formatDirs = $list; |
|
|
|
|
153
|
|
|
|
154
|
1 |
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param list<string> $list |
159
|
|
|
*/ |
160
|
4 |
|
public function setNoCacheWhenBuilding(array $list): self |
161
|
|
|
{ |
162
|
4 |
|
$this->noCacheWhenBuilding = $list; |
|
|
|
|
163
|
4 |
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
8 |
|
public function jsonSerialize(): array |
167
|
|
|
{ |
168
|
8 |
|
return [ |
169
|
8 |
|
self::SRC_DIRS => $this->srcDirs, |
170
|
8 |
|
self::TEST_DIRS => $this->testDirs, |
171
|
8 |
|
self::VENDOR_DIR => $this->vendorDir, |
172
|
8 |
|
self::ERROR_LOG_FILE => $this->errorLogFile, |
173
|
8 |
|
self::BUILD_CONFIG => $this->buildConfig->jsonSerialize(), |
174
|
8 |
|
self::EXPORT_CONFIG => $this->exportConfig->jsonSerialize(), |
175
|
8 |
|
self::IGNORE_WHEN_BUILDING => $this->ignoreWhenBuilding, |
176
|
8 |
|
self::NO_CACHE_WHEN_BUILDING => $this->noCacheWhenBuilding, |
177
|
8 |
|
self::KEEP_GENERATED_TEMP_FILES => $this->keepGeneratedTempFiles, |
178
|
8 |
|
self::TEMP_DIR => $this->tempDir, |
179
|
8 |
|
self::FORMAT_DIRS => $this->formatDirs, |
180
|
8 |
|
]; |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths