Skip to content

Commit 7106c5e

Browse files
authored
Rename "whitelisted files" to "excluded files" (#611)
1 parent 371c66d commit 7106c5e

File tree

13 files changed

+44
-43
lines changed

13 files changed

+44
-43
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ potentially very difficult to debug due to dissimilar or unsupported package ver
3737
- [Prefix](docs/configuration.md#prefix)
3838
- [Finders and paths](docs/configuration.md#finders-and-paths)
3939
- [Patchers](docs/configuration.md#patchers)
40-
- [Whitelisted files](docs/configuration.md#whitelisted-files)
40+
- [Excluded files](docs/configuration.md#excluded-files)
4141
- [Excluded Symbols](docs/configuration.md#excluded-symbols)
4242
- [Exposed Symbols](docs/configuration.md#exposed-symbols)
4343
- [Exposing classes](docs/configuration.md#exposing-classes)

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- [Prefix](#prefix)
44
- [Finders and paths](#finders-and-paths)
55
- [Patchers](#patchers)
6-
- [Whitelisted files](#whitelisted-files)
6+
- [Excluded files](#excluded-files)
77
- [Excluded Symbols](#excluded-symbols)
88
- [Exposed Symbols](#exposed-symbols)
99
- [Exposing classes](#exposing-classes)
@@ -169,7 +169,7 @@ return [
169169
```
170170

171171

172-
### Whitelisted files
172+
### Excluded files
173173

174174
For the files listed in `files-whitelist`, their content will be left
175175
untouched during the scoping process.

fixtures/set020-infection/scoper.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
);
2828

2929
return [
30-
'files-whitelist' => [
30+
'exclude-files' => [
3131
...$polyfillsBootstraps,
3232
...$polyfillsStubs,
3333
],

fixtures/set021-composer2/scoper.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
'whitelist' => [
2929
'Symfony\\Polyfill\\*',
3030
],
31-
'files-whitelist' => [
31+
'exclude-files' => [
3232
...$polyfillsBootstraps,
3333
...$polyfillsStubs,
3434
],

scoper.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
Finder::class,
7474
'Symfony\\Polyfill\\*',
7575
],
76-
'files-whitelist' => [
76+
'exclude-files' => [
7777
...$jetBrainStubs,
7878
...$polyfillsBootstraps,
7979
...$polyfillsStubs,

src/Configuration/Configuration.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ final class Configuration
2626
private ?string $path;
2727
private string $prefix;
2828
private array $filesWithContents;
29-
private array $whitelistedFilesWithContents;
29+
private array $excludedFilesWithContents;
3030
private Patcher $patcher;
3131
private SymbolsConfiguration $symbolsConfiguration;
3232

3333
/**
34-
* @param string|null $path Absolute path to the configuration file loaded.
35-
* @param string $prefix The prefix applied.
36-
* @param array<string, array{string, string}> $filesWithContents Array of tuple with the
34+
* @param string|null $path Absolute path to the configuration file loaded.
35+
* @param string $prefix The prefix applied.
36+
* @param array<string, array{string, string}> $filesWithContents Array of tuple with the
3737
* first argument being the file path and the second
3838
* its contents
39-
* @param array<string, array{string, string}> $whitelistedFilesWithContents Array of tuple
39+
* @param array<string, array{string, string}> $excludedFilesWithContents Array of tuple
4040
* with the first argument being the file path and
4141
* the second its contents
4242
* @param SymbolsConfiguration $symbolsConfiguration
@@ -45,7 +45,7 @@ public function __construct(
4545
?string $path,
4646
string $prefix,
4747
array $filesWithContents,
48-
array $whitelistedFilesWithContents,
48+
array $excludedFilesWithContents,
4949
Patcher $patcher,
5050
SymbolsConfiguration $symbolsConfiguration
5151
) {
@@ -56,7 +56,7 @@ public function __construct(
5656
$this->filesWithContents = $filesWithContents;
5757
$this->patcher = $patcher;
5858
$this->symbolsConfiguration = $symbolsConfiguration;
59-
$this->whitelistedFilesWithContents = $whitelistedFilesWithContents;
59+
$this->excludedFilesWithContents = $excludedFilesWithContents;
6060
}
6161

6262
public function getPath(): ?string
@@ -90,9 +90,9 @@ public function getSymbolsConfiguration(): SymbolsConfiguration
9090
/**
9191
* @return array<string, array{string, string}>
9292
*/
93-
public function getWhitelistedFilesWithContents(): array
93+
public function getExcludedFilesWithContents(): array
9494
{
95-
return $this->whitelistedFilesWithContents;
95+
return $this->excludedFilesWithContents;
9696
}
9797

9898
private static function validatePrefix(string $prefix): void

src/Configuration/ConfigurationFactory.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ public function create(?string $path = null, array $paths = []): Configuration
8282

8383
$prefix = self::retrievePrefix($config);
8484

85-
$whitelistedFiles = null === $path
85+
$excludedFiles = null === $path
8686
? []
87-
: $this->retrieveWhitelistedFiles(
87+
: $this->retrieveExcludedFiles(
8888
dirname($path),
8989
$config,
9090
);
@@ -104,7 +104,7 @@ public function create(?string $path = null, array $paths = []): Configuration
104104
$path,
105105
$prefix,
106106
$filesWithContents,
107-
self::retrieveFilesWithContents($whitelistedFiles),
107+
self::retrieveFilesWithContents($excludedFiles),
108108
new PatcherChain($patchers),
109109
$symbolsConfiguration,
110110
);
@@ -130,7 +130,7 @@ public function createWithPaths(Configuration $config, array $paths): Configurat
130130
$config->getFilesWithContents(),
131131
$filesWithContents,
132132
),
133-
$config->getWhitelistedFilesWithContents(),
133+
$config->getExcludedFilesWithContents(),
134134
$config->getPatcher(),
135135
$config->getSymbolsConfiguration(),
136136
);
@@ -144,7 +144,7 @@ public function createWithPrefix(Configuration $config, string $prefix): Configu
144144
$config->getPath(),
145145
$prefix,
146146
$config->getFilesWithContents(),
147-
$config->getWhitelistedFilesWithContents(),
147+
$config->getExcludedFilesWithContents(),
148148
$config->getPatcher(),
149149
$config->getSymbolsConfiguration(),
150150
);
@@ -269,28 +269,28 @@ private static function retrievePatchers(array $config): array
269269
/**
270270
* @return string[] Absolute paths
271271
*/
272-
private function retrieveWhitelistedFiles(string $dirPath, array $config): array
272+
private function retrieveExcludedFiles(string $dirPath, array $config): array
273273
{
274-
if (!array_key_exists(ConfigurationKeys::WHITELISTED_FILES_KEYWORD, $config)) {
274+
if (!array_key_exists(ConfigurationKeys::EXCLUDED_FILES_KEYWORD, $config)) {
275275
return [];
276276
}
277277

278-
$whitelistedFiles = $config[ConfigurationKeys::WHITELISTED_FILES_KEYWORD];
278+
$excludedFiles = $config[ConfigurationKeys::EXCLUDED_FILES_KEYWORD];
279279

280-
if (!is_array($whitelistedFiles)) {
280+
if (!is_array($excludedFiles)) {
281281
throw new InvalidArgumentException(
282282
sprintf(
283-
'Expected whitelisted files to be an array of strings, found "%s" instead.',
284-
gettype($whitelistedFiles),
283+
'Expected excluded files to be an array of strings, found "%s" instead.',
284+
gettype($excludedFiles),
285285
),
286286
);
287287
}
288288

289-
foreach ($whitelistedFiles as $index => $file) {
289+
foreach ($excludedFiles as $index => $file) {
290290
if (!is_string($file)) {
291291
throw new InvalidArgumentException(
292292
sprintf(
293-
'Expected whitelisted files to be an array of string, the "%d" element is not.',
293+
'Expected excluded files to be an array of string, the "%d" element is not.',
294294
$index,
295295
),
296296
);
@@ -300,10 +300,10 @@ private function retrieveWhitelistedFiles(string $dirPath, array $config): array
300300
$file = $dirPath.DIRECTORY_SEPARATOR.$file;
301301
}
302302

303-
$whitelistedFiles[$index] = realpath($file);
303+
$excludedFiles[$index] = realpath($file);
304304
}
305305

306-
return array_filter($whitelistedFiles);
306+
return array_filter($excludedFiles);
307307
}
308308

309309
/**

src/Configuration/ConfigurationKeys.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
final class ConfigurationKeys
99
{
1010
public const PREFIX_KEYWORD = 'prefix';
11-
public const WHITELISTED_FILES_KEYWORD = 'files-whitelist';
11+
public const EXCLUDED_FILES_KEYWORD = 'exclude-files';
1212
public const FINDER_KEYWORD = 'finders';
1313
public const PATCHERS_KEYWORD = 'patchers';
1414
public const WHITELIST_KEYWORD = 'whitelist';
@@ -29,7 +29,7 @@ final class ConfigurationKeys
2929

3030
public const KEYWORDS = [
3131
self::PREFIX_KEYWORD,
32-
self::WHITELISTED_FILES_KEYWORD,
32+
self::EXCLUDED_FILES_KEYWORD,
3333
self::FINDER_KEYWORD,
3434
self::PATCHERS_KEYWORD,
3535
self::WHITELIST_KEYWORD,

src/Console/ConsoleScoper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ private function scopeFiles(
143143
private static function getFiles(Configuration $config, string $outputDir): array
144144
{
145145
$filesWithContent = $config->getFilesWithContents();
146-
$whitelistedFilesWithContent = $config->getWhitelistedFilesWithContents();
146+
$excludedFilesWithContents = $config->getExcludedFilesWithContents();
147147

148148
$commonPath = get_common_path(
149149
[
150150
...array_keys($filesWithContent),
151-
...array_keys($whitelistedFilesWithContent),
151+
...array_keys($excludedFilesWithContents),
152152
],
153153
);
154154

@@ -165,7 +165,7 @@ private static function getFiles(Configuration $config, string $outputDir): arra
165165
),
166166
array_map(
167167
$mapFiles,
168-
$whitelistedFilesWithContent,
168+
$excludedFilesWithContents,
169169
),
170170
];
171171
}

src/scoper.inc.php.tpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ return [
4545
]),
4646
],
4747

48-
// Whitelists a list of files. Unlike the other whitelist related features, this one is about completely leaving
49-
// a file untouched.
48+
// List of excluded files, i.e. files for which the content will be left untouched.
5049
// Paths are relative to the configuration file unless if they are already absolute
51-
'files-whitelist' => [
50+
//
51+
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#patchers
52+
'exclude-files' => [
5253
'src/a-whitelisted-file.php',
5354
],
5455

tests/Configuration/ConfigurationFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function test_it_can_be_created_without_a_file(): void
4545
{
4646
$configuration = $this->configFactory->create();
4747

48-
self::assertSame([], $configuration->getWhitelistedFilesWithContents());
48+
self::assertSame([], $configuration->getExcludedFilesWithContents());
4949
self::assertEquals(
5050
SymbolsConfiguration::create(),
5151
$configuration->getSymbolsConfiguration(),
@@ -88,7 +88,7 @@ public function test_it_can_create_a_complete_configuration(): void
8888
8989
return [
9090
'prefix' => 'MyPrefix',
91-
'files-whitelist' => ['file1', 'file2'],
91+
'exclude-files' => ['file1', 'file2'],
9292
'patchers' => [],
9393
'finders' => [],
9494
@@ -131,7 +131,7 @@ public function test_it_can_create_a_complete_configuration(): void
131131
'',
132132
],
133133
],
134-
$configuration->getWhitelistedFilesWithContents(),
134+
$configuration->getExcludedFilesWithContents(),
135135
);
136136
self::assertEquals(
137137
new PatcherChain([

vendor-hotfix/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2838,7 +2838,7 @@ static function (string $path) use ($basePath): string {
28382838
return make_path_relative($path, $basePath);
28392839
},
28402840
array_keys(
2841-
$phpScoperConfig->getWhitelistedFilesWithContents(),
2841+
$phpScoperConfig->getExcludedFilesWithContents(),
28422842
),
28432843
)
28442844
)

vendor-hotfix/SimpleScoper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(
4848
$scoperConfig->getPath(),
4949
$scoperConfig->getPrefix(),
5050
$scoperConfig->getFilesWithContents(),
51-
$scoperConfig->getWhitelistedFilesWithContents(),
51+
$scoperConfig->getExcludedFilesWithContents(),
5252
self::createSerializablePatchers($scoperConfig->getPatcher()),
5353
$scoperConfig->getSymbolsConfiguration(),
5454
);

0 commit comments

Comments
 (0)