Skip to content

Commit fe9223c

Browse files
More work on removing the blacklist/whitelist terminology
1 parent dd4ddfd commit fe9223c

9 files changed

Lines changed: 50 additions & 48 deletions

File tree

.psalm/baseline.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
<code>$loader</code>
220220
</PossiblyNullPropertyAssignmentValue>
221221
<PossiblyUndefinedVariable occurrences="1">
222-
<code>$whitelistFromConfigurationFile</code>
222+
<code>$coverageFilterFromConfigurationFile</code>
223223
</PossiblyUndefinedVariable>
224224
</file>
225225
<file src="src/Util/Annotation/DocBlock.php">

ChangeLog-9.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes of the PHPUnit 9.3 release series are documented in this fil
1010
* `PHPUnit\Framework\TestCase::$backupGlobalsBlacklist` is deprecated, please use `PHPUnit\Framework\TestCase::$backupGlobalsExcludeList` instead
1111
* `PHPUnit\Framework\TestCase::$backupStaticAttributesBlacklist` is deprecated, please use `PHPUnit\Framework\TestCase::$backupStaticAttributesExcludeList` instead
1212
* `PHPUnit\Util\Blacklist` is now deprecated, please use `PHPUnit\Util\ExcludeList` instead
13+
* `--whitelist` is now deprecated, please use `--coverage-filter` instead
1314
* `<filter><whitelist>...</whitelist></filter` is now deprecated, please use `<filter>...</filter` instead
1415

1516
[9.3.0]: https://github.com/sebastianbergmann/phpunit/compare/9.2...master

src/TextUI/Arguments/Arguments.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ final class Arguments
8282
*/
8383
private $configuration;
8484

85+
/**
86+
* @var null|string[]
87+
*/
88+
private $coverageFilter;
89+
8590
/**
8691
* @var ?string
8792
*/
@@ -422,11 +427,6 @@ final class Arguments
422427
*/
423428
private $version;
424429

425-
/**
426-
* @var null|string[]
427-
*/
428-
private $whitelist;
429-
430430
/**
431431
* @var ?string
432432
*/
@@ -435,7 +435,7 @@ final class Arguments
435435
/**
436436
* @param null|int|string $columns
437437
*/
438-
public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticAttributes, ?bool $beStrictAboutChangesToGlobalState, ?bool $beStrictAboutResourceUsageDuringSmallTests, ?string $bootstrap, ?bool $cacheResult, ?string $cacheResultFile, ?bool $checkVersion, ?string $colors, $columns, ?string $configuration, ?string $coverageClover, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $debug, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $disallowTodoAnnotatedTests, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?array $extensions, ?array $unavailableExtensions, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?bool $generateConfiguration, ?array $groups, ?bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, ?bool $listGroups, ?bool $listSuites, ?bool $listTests, ?string $listTestsXml, ?string $loader, ?bool $noCoverage, ?bool $noExtensions, ?bool $noInteraction, ?bool $noLogging, ?string $printer, ?bool $processIsolation, ?int $randomOrderSeed, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?array $testdoxExcludeGroups, ?array $testdoxGroups, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, ?array $unrecognizedOptions, ?string $unrecognizedOrderBy, ?bool $useDefaultConfiguration, ?bool $verbose, ?bool $version, ?array $whitelist, ?string $xdebugFilterFile)
438+
public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticAttributes, ?bool $beStrictAboutChangesToGlobalState, ?bool $beStrictAboutResourceUsageDuringSmallTests, ?string $bootstrap, ?bool $cacheResult, ?string $cacheResultFile, ?bool $checkVersion, ?string $colors, $columns, ?string $configuration, ?string $coverageClover, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $debug, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $disallowTodoAnnotatedTests, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?array $extensions, ?array $unavailableExtensions, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?bool $generateConfiguration, ?array $groups, ?bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, ?bool $listGroups, ?bool $listSuites, ?bool $listTests, ?string $listTestsXml, ?string $loader, ?bool $noCoverage, ?bool $noExtensions, ?bool $noInteraction, ?bool $noLogging, ?string $printer, ?bool $processIsolation, ?int $randomOrderSeed, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?array $testdoxExcludeGroups, ?array $testdoxGroups, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, ?array $unrecognizedOptions, ?string $unrecognizedOrderBy, ?bool $useDefaultConfiguration, ?bool $verbose, ?bool $version, ?array $coverageFilter, ?string $xdebugFilterFile)
439439
{
440440
$this->argument = $argument;
441441
$this->atLeastVersion = $atLeastVersion;
@@ -450,6 +450,7 @@ public function __construct(?string $argument, ?string $atLeastVersion, ?bool $b
450450
$this->colors = $colors;
451451
$this->columns = $columns;
452452
$this->configuration = $configuration;
453+
$this->coverageFilter = $coverageFilter;
453454
$this->coverageClover = $coverageClover;
454455
$this->coverageCrap4J = $coverageCrap4J;
455456
$this->coverageHtml = $coverageHtml;
@@ -518,7 +519,6 @@ public function __construct(?string $argument, ?string $atLeastVersion, ?bool $b
518519
$this->useDefaultConfiguration = $useDefaultConfiguration;
519520
$this->verbose = $verbose;
520521
$this->version = $version;
521-
$this->whitelist = $whitelist;
522522
$this->xdebugFilterFile = $xdebugFilterFile;
523523
}
524524

@@ -704,6 +704,20 @@ public function configuration(): string
704704
return $this->configuration;
705705
}
706706

707+
public function hasCoverageFilter(): bool
708+
{
709+
return $this->coverageFilter !== null;
710+
}
711+
712+
public function coverageFilter(): array
713+
{
714+
if ($this->coverageFilter === null) {
715+
throw new Exception;
716+
}
717+
718+
return $this->coverageFilter;
719+
}
720+
707721
public function hasCoverageClover(): bool
708722
{
709723
return $this->coverageClover !== null;
@@ -1656,20 +1670,6 @@ public function version(): bool
16561670
return $this->version;
16571671
}
16581672

1659-
public function hasWhitelist(): bool
1660-
{
1661-
return $this->whitelist !== null;
1662-
}
1663-
1664-
public function whitelist(): array
1665-
{
1666-
if ($this->whitelist === null) {
1667-
throw new Exception;
1668-
}
1669-
1670-
return $this->whitelist;
1671-
}
1672-
16731673
public function hasXdebugFilterFile(): bool
16741674
{
16751675
return $this->xdebugFilterFile !== null;

src/TextUI/Arguments/ArgumentsBuilder.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ final class ArgumentsBuilder
3333
'colors==',
3434
'columns=',
3535
'configuration=',
36+
'coverage-filter=',
3637
'coverage-clover=',
3738
'coverage-crap4j=',
3839
'coverage-html=',
@@ -136,6 +137,7 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
136137
$colors = null;
137138
$columns = null;
138139
$configuration = null;
140+
$coverageFilter = null;
139141
$coverageClover = null;
140142
$coverageCrap4J = null;
141143
$coverageHtml = null;
@@ -204,7 +206,6 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
204206
$useDefaultConfiguration = null;
205207
$verbose = null;
206208
$version = null;
207-
$whitelist = null;
208209
$xdebugFilterFile = null;
209210

210211
if (isset($options[1][0])) {
@@ -664,12 +665,13 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
664665

665666
break;
666667

668+
case '--coverage-filter':
667669
case '--whitelist':
668-
if ($whitelist === null) {
669-
$whitelist = [];
670+
if ($coverageFilter === null) {
671+
$coverageFilter = [];
670672
}
671673

672-
$whitelist[] = $option[1];
674+
$coverageFilter[] = $option[1];
673675

674676
break;
675677

@@ -724,8 +726,8 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
724726
$unrecognizedOptions = null;
725727
}
726728

727-
if (empty($whitelist)) {
728-
$whitelist = null;
729+
if (empty($coverageFilter)) {
730+
$coverageFilter = null;
729731
}
730732

731733
return new Arguments(
@@ -810,7 +812,7 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
810812
$useDefaultConfiguration,
811813
$verbose,
812814
$version,
813-
$whitelist,
815+
$coverageFilter,
814816
$xdebugFilterFile
815817
);
816818
}

src/TextUI/Arguments/ArgumentsMapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ public function mapToLegacyArray(Arguments $arguments): array
317317
$result['reverseList'] = $arguments->reverseList();
318318
}
319319

320-
if ($arguments->hasWhitelist()) {
321-
$result['whitelist'] = $arguments->whitelist();
320+
if ($arguments->hasCoverageFilter()) {
321+
$result['coverageFilter'] = $arguments->coverageFilter();
322322
}
323323

324324
if ($arguments->hasRandomOrderSeer()) {

src/TextUI/Help.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class Help
3131
['arg' => '--coverage-php <file>', 'desc' => 'Export PHP_CodeCoverage object to file'],
3232
['arg' => '--coverage-text=<file>', 'desc' => 'Generate code coverage report in text format [default: standard output]'],
3333
['arg' => '--coverage-xml <dir>', 'desc' => 'Generate code coverage report in PHPUnit XML format'],
34-
['arg' => '--whitelist <dir>', 'desc' => 'Whitelist <dir> for code coverage analysis'],
34+
['arg' => '--coverage-filter <dir>', 'desc' => 'Include <dir> in code coverage analysis'],
3535
['arg' => '--disable-coverage-ignore', 'desc' => 'Disable annotations for ignoring code coverage'],
3636
['arg' => '--no-coverage', 'desc' => 'Ignore code coverage configuration'],
3737
['arg' => '--dump-xdebug-filter <file>', 'desc' => 'Generate script to set Xdebug code coverage filter'],

src/TextUI/TestRunner.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -471,21 +471,21 @@ public function run(TestSuite $suite, array $arguments = [], array $warnings = [
471471
}
472472

473473
if ($codeCoverageReports > 0 || isset($arguments['xdebugFilterFile'])) {
474-
$whitelistFromConfigurationFile = false;
475-
$whitelistFromOption = false;
474+
$coverageFilterFromConfigurationFile = false;
475+
$coverageFilterFromOption = false;
476476

477-
if (isset($arguments['whitelist'])) {
478-
if (!\is_array($arguments['whitelist'])) {
479-
$whitelistDirectories = [$arguments['whitelist']];
477+
if (isset($arguments['coverageFilter'])) {
478+
if (!\is_array($arguments['coverageFilter'])) {
479+
$coverageFilterDirectories = [$arguments['coverageFilter']];
480480
} else {
481-
$whitelistDirectories = $arguments['whitelist'];
481+
$coverageFilterDirectories = $arguments['coverageFilter'];
482482
}
483483

484-
foreach ($whitelistDirectories as $whitelistDirectory) {
485-
$this->codeCoverageFilter->includeDirectory($whitelistDirectory);
484+
foreach ($coverageFilterDirectories as $coverageFilterDirectory) {
485+
$this->codeCoverageFilter->includeDirectory($coverageFilterDirectory);
486486
}
487487

488-
$whitelistFromOption = true;
488+
$coverageFilterFromOption = true;
489489
}
490490

491491
if (isset($arguments['configuration'])) {
@@ -494,7 +494,7 @@ public function run(TestSuite $suite, array $arguments = [], array $warnings = [
494494
$filterConfiguration = $arguments['configuration']->filter();
495495

496496
if ($filterConfiguration->hasNonEmptyListOfFilesToBeIncludedInCodeCoverageReport()) {
497-
$whitelistFromConfigurationFile = true;
497+
$coverageFilterFromConfigurationFile = true;
498498

499499
foreach ($filterConfiguration->directories() as $directory) {
500500
$this->codeCoverageFilter->includeDirectory(
@@ -571,10 +571,10 @@ public function run(TestSuite $suite, array $arguments = [], array $warnings = [
571571
}
572572

573573
if ($this->codeCoverageFilter->isEmpty()) {
574-
if (!$whitelistFromConfigurationFile && !$whitelistFromOption) {
575-
$this->writeMessage('Error', 'No whitelist is configured, no code coverage will be generated.');
574+
if (!$coverageFilterFromConfigurationFile && !$coverageFilterFromOption) {
575+
$this->writeMessage('Error', 'No filter is configured, no code coverage will be generated.');
576576
} else {
577-
$this->writeMessage('Error', 'Incorrect whitelist config, no code coverage will be generated.');
577+
$this->writeMessage('Error', 'Incorrect filter configuration, no code coverage will be generated.');
578578
}
579579

580580
$codeCoverageReports = 0;

tests/end-to-end/cli/_files/output-cli-help-color.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
format [default: standard output]
1515
--coverage-xml <dir>  Generate code coverage report in PHPUnit
1616
XML format
17-
--whitelist <dir>  Whitelist <dir> for code coverage
18-
analysis
17+
--coverage-filter <dir>  Include <dir> in code coverage analysis
1918
--disable-coverage-ignore  Disable annotations for ignoring code
2019
coverage
2120
--no-coverage  Ignore code coverage configuration

tests/end-to-end/cli/_files/output-cli-usage.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Code Coverage Options:
1212
--coverage-php <file> Export PHP_CodeCoverage object to file
1313
--coverage-text=<file> Generate code coverage report in text format [default: standard output]
1414
--coverage-xml <dir> Generate code coverage report in PHPUnit XML format
15-
--whitelist <dir> Whitelist <dir> for code coverage analysis
15+
--coverage-filter <dir> Include <dir> in code coverage analysis
1616
--disable-coverage-ignore Disable annotations for ignoring code coverage
1717
--no-coverage Ignore code coverage configuration
1818
--dump-xdebug-filter <file> Generate script to set Xdebug code coverage filter

0 commit comments

Comments
 (0)