|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the humbug/php-scoper package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright (c) 2017 Théo FIDRY <[email protected]>, |
|
9
|
|
|
* Pádraic Brady <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
12
|
|
|
* file that was distributed with this source code. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Humbug\PhpScoper; |
|
16
|
|
|
|
|
17
|
|
|
final class Configuration |
|
18
|
|
|
{ |
|
19
|
|
|
private ?string $path; |
|
20
|
|
|
private string $prefix; |
|
21
|
|
|
private array $filesWithContents; |
|
22
|
|
|
private array $patchers; |
|
23
|
|
|
private Whitelist $whitelist; |
|
24
|
|
|
private array $whitelistedFiles; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param string|null $path Absolute path to the configuration file loaded. |
|
28
|
|
|
* @param string $prefix The prefix applied. |
|
29
|
|
|
* @param array<string, array{string, string}> $filesWithContents Array of tuple with the |
|
|
|
|
|
|
30
|
|
|
* first argument being the file path and the second |
|
31
|
|
|
* its contents |
|
32
|
|
|
* @param callable[] $patchers List of closures which can alter the content of |
|
33
|
|
|
* the files being scoped. |
|
34
|
|
|
* @param Whitelist $whitelist List of classes that will not be scoped. |
|
35
|
|
|
* returning a boolean which if `true` means the |
|
36
|
|
|
* class should be scoped |
|
37
|
|
|
* (i.e. is ignored) or scoped otherwise. |
|
38
|
|
|
* @param string[] $whitelistedFiles List of absolute paths of files to completely |
|
39
|
|
|
* ignore |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct( |
|
42
|
|
|
?string $path, |
|
43
|
|
|
string $prefix, |
|
44
|
|
|
array $filesWithContents, |
|
45
|
|
|
array $patchers, |
|
46
|
|
|
Whitelist $whitelist, |
|
47
|
|
|
array $whitelistedFiles |
|
48
|
|
|
) { |
|
49
|
|
|
$this->path = $path; |
|
50
|
|
|
$this->prefix = $prefix; |
|
51
|
|
|
$this->filesWithContents = $filesWithContents; |
|
52
|
|
|
$this->patchers = $patchers; |
|
53
|
|
|
$this->whitelist = $whitelist; |
|
54
|
|
|
$this->whitelistedFiles = $whitelistedFiles; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getPath(): ?string |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->path; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getPrefix(): string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->prefix; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return array<string, array{string, string}> |
|
|
|
|
|
|
69
|
|
|
*/ |
|
70
|
|
|
public function getFilesWithContents(): array |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->filesWithContents; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return callable[] |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getPatchers(): array |
|
79
|
3 |
|
{ |
|
80
|
|
|
return $this->patchers; |
|
81
|
3 |
|
} |
|
82
|
1 |
|
|
|
83
|
|
|
public function getWhitelist(): Whitelist |
|
84
|
2 |
|
{ |
|
85
|
|
|
return $this->whitelist; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return string[] |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getWhitelistedFiles(): array |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->whitelistedFiles; |
|
94
|
2 |
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|