Skip to content

Commit

Permalink
Closes #4600
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 19, 2023
1 parent cce2009 commit d249ffa
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 187 deletions.
25 changes: 0 additions & 25 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,6 @@
</ArgumentTypeCoercion>
</file>
<file src="src/TextUI/Configuration/Cli/Configuration.php">
<DeprecatedMethod>
<code>hasCacheResultFile</code>
<code>hasCoverageCacheDirectory</code>
</DeprecatedMethod>
<InvalidNullableReturnType>
<code>bool</code>
<code>string</code>
Expand Down Expand Up @@ -677,17 +673,6 @@
</PossiblyInvalidPropertyAssignmentValue>
</file>
<file src="src/TextUI/Configuration/Merger.php">
<DeprecatedMethod>
<code>cacheDirectory</code>
<code>cacheResultFile</code>
<code>cacheResultFile</code>
<code>coverageCacheDirectory</code>
<code>coverageCacheDirectory</code>
<code>hasCacheDirectory</code>
<code>hasCacheResultFile</code>
<code>hasCacheResultFile</code>
<code>hasCoverageCacheDirectory</code>
</DeprecatedMethod>
<MissingThrowsDocblock>
<code>detect</code>
</MissingThrowsDocblock>
Expand Down Expand Up @@ -769,11 +754,6 @@
<code>$variables</code>
</PropertyTypeCoercion>
</file>
<file src="src/TextUI/Configuration/Xml/CodeCoverage/CodeCoverage.php">
<DeprecatedMethod>
<code>hasCacheDirectory</code>
</DeprecatedMethod>
</file>
<file src="src/TextUI/Configuration/Xml/Loader.php">
<ArgumentTypeCoercion>
<code><![CDATA[$bootstrap->getAttribute('class')]]></code>
Expand Down Expand Up @@ -826,11 +806,6 @@
<code>removeChild</code>
</PossiblyNullReference>
</file>
<file src="src/TextUI/Configuration/Xml/PHPUnit.php">
<DeprecatedMethod>
<code>hasCacheResultFile</code>
</DeprecatedMethod>
</file>
<file src="src/TextUI/Help.php">
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$option['desc']]]></code>
Expand Down
16 changes: 0 additions & 16 deletions src/TextUI/Configuration/Cli/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ final class Builder
'cache-result',
'do-not-cache-result',
'cache-directory=',
'cache-result-file=',
'check-version',
'colors==',
'columns=',
'configuration=',
'coverage-cache=',
'warm-coverage-cache',
'coverage-filter=',
'coverage-clover=',
Expand Down Expand Up @@ -146,12 +144,10 @@ public function fromParameters(array $parameters): Configuration
$bootstrap = null;
$cacheDirectory = null;
$cacheResult = null;
$cacheResultFile = null;
$checkVersion = false;
$colors = null;
$columns = null;
$configuration = null;
$coverageCacheDirectory = null;
$warmCoverageCache = false;
$coverageFilter = null;
$coverageClover = null;
Expand Down Expand Up @@ -264,11 +260,6 @@ public function fromParameters(array $parameters): Configuration

break;

case '--cache-result-file':
$cacheResultFile = $option[1];

break;

case '--columns':
if (is_numeric($option[1])) {
$columns = (int) $option[1];
Expand All @@ -284,11 +275,6 @@ public function fromParameters(array $parameters): Configuration

break;

case '--coverage-cache':
$coverageCacheDirectory = $option[1];

break;

case '--warm-coverage-cache':
$warmCoverageCache = true;

Expand Down Expand Up @@ -804,7 +790,6 @@ public function fromParameters(array $parameters): Configuration
$bootstrap,
$cacheDirectory,
$cacheResult,
$cacheResultFile,
$checkVersion,
$colors,
$columns,
Expand All @@ -819,7 +804,6 @@ public function fromParameters(array $parameters): Configuration
$coverageTextShowOnlySummary,
$coverageXml,
$pathCoverage,
$coverageCacheDirectory,
$warmCoverageCache,
$defaultTimeLimit,
$disableCodeCoverageIgnore,
Expand Down
54 changes: 1 addition & 53 deletions src/TextUI/Configuration/Cli/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ final class Configuration
private readonly ?string $bootstrap;
private readonly ?string $cacheDirectory;
private readonly ?bool $cacheResult;
private readonly ?string $cacheResultFile;
private readonly bool $checkVersion;
private readonly ?string $colors;
private readonly null|int|string $columns;
Expand All @@ -40,7 +39,6 @@ final class Configuration
private readonly ?bool $coverageTextShowOnlySummary;
private readonly ?string $coverageXml;
private readonly ?bool $pathCoverage;
private readonly ?string $coverageCacheDirectory;
private readonly bool $warmCoverageCache;
private readonly ?int $defaultTimeLimit;
private readonly ?bool $disableCodeCoverageIgnore;
Expand Down Expand Up @@ -118,7 +116,7 @@ final class Configuration
/**
* @psalm-param ?non-empty-list<string> $testSuffixes
*/
public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, ?string $cacheResultFile, bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configurationFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnDeprecation, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noResults, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox)
public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configurationFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnDeprecation, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noResults, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox)
{
$this->argument = $argument;
$this->atLeastVersion = $atLeastVersion;
Expand All @@ -128,7 +126,6 @@ public function __construct(?string $argument, ?string $atLeastVersion, ?bool $b
$this->bootstrap = $bootstrap;
$this->cacheDirectory = $cacheDirectory;
$this->cacheResult = $cacheResult;
$this->cacheResultFile = $cacheResultFile;
$this->checkVersion = $checkVersion;
$this->colors = $colors;
$this->columns = $columns;
Expand All @@ -144,7 +141,6 @@ public function __construct(?string $argument, ?string $atLeastVersion, ?bool $b
$this->coverageTextShowOnlySummary = $coverageTextShowOnlySummary;
$this->coverageXml = $coverageXml;
$this->pathCoverage = $pathCoverage;
$this->coverageCacheDirectory = $coverageCacheDirectory;
$this->warmCoverageCache = $warmCoverageCache;
$this->defaultTimeLimit = $defaultTimeLimit;
$this->disableCodeCoverageIgnore = $disableCodeCoverageIgnore;
Expand Down Expand Up @@ -376,30 +372,6 @@ public function cacheResult(): bool
return $this->cacheResult;
}

/**
* @psalm-assert-if-true !null $this->cacheResultFile
*
* @deprecated
*/
public function hasCacheResultFile(): bool
{
return $this->cacheResultFile !== null;
}

/**
* @throws Exception
*
* @deprecated
*/
public function cacheResultFile(): string
{
if (!$this->hasCacheResultFile()) {
throw new Exception;
}

return $this->cacheResultFile;
}

public function checkVersion(): bool
{
return $this->checkVersion;
Expand Down Expand Up @@ -685,30 +657,6 @@ public function pathCoverage(): bool
return $this->pathCoverage;
}

/**
* @psalm-assert-if-true !null $this->coverageCacheDirectory
*
* @deprecated
*/
public function hasCoverageCacheDirectory(): bool
{
return $this->coverageCacheDirectory !== null;
}

/**
* @throws Exception
*
* @deprecated
*/
public function coverageCacheDirectory(): string
{
if (!$this->hasCoverageCacheDirectory()) {
throw new Exception;
}

return $this->coverageCacheDirectory;
}

public function warmCoverageCache(): bool
{
return $this->warmCoverageCache;
Expand Down
14 changes: 1 addition & 13 deletions src/TextUI/Configuration/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,8 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
$testResultCacheFile = $cacheDirectory . DIRECTORY_SEPARATOR . 'test-results';
}

if ($coverageCacheDirectory === null) {
if ($cliConfiguration->hasCoverageCacheDirectory() && Filesystem::createDirectory($cliConfiguration->coverageCacheDirectory())) {
$coverageCacheDirectory = realpath($cliConfiguration->coverageCacheDirectory());
} elseif ($xmlConfiguration->codeCoverage()->hasCacheDirectory()) {
$coverageCacheDirectory = $xmlConfiguration->codeCoverage()->cacheDirectory()->path();
}
}

if (!isset($testResultCacheFile)) {
if ($cliConfiguration->hasCacheResultFile()) {
$testResultCacheFile = $cliConfiguration->cacheResultFile();
} elseif ($xmlConfiguration->phpunit()->hasCacheResultFile()) {
$testResultCacheFile = $xmlConfiguration->phpunit()->cacheResultFile();
} elseif ($xmlConfiguration->wasLoadedFromFile()) {
if ($xmlConfiguration->wasLoadedFromFile()) {
$testResultCacheFile = dirname(realpath($xmlConfiguration->filename())) . DIRECTORY_SEPARATOR . '.phpunit.result.cache';
} else {
$candidate = realpath($_SERVER['PHP_SELF']);
Expand Down
31 changes: 1 addition & 30 deletions src/TextUI/Configuration/Xml/CodeCoverage/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace PHPUnit\TextUI\XmlConfiguration\CodeCoverage;

use function count;
use PHPUnit\TextUI\Configuration\Directory;
use PHPUnit\TextUI\Configuration\FileCollection;
use PHPUnit\TextUI\Configuration\FilterDirectoryCollection;
use PHPUnit\TextUI\XmlConfiguration\CodeCoverage\Report\Clover;
Expand All @@ -29,7 +28,6 @@
*/
final class CodeCoverage
{
private readonly ?Directory $cacheDirectory;
private readonly FilterDirectoryCollection $directories;
private readonly FileCollection $files;
private readonly FilterDirectoryCollection $excludeDirectories;
Expand All @@ -46,9 +44,8 @@ final class CodeCoverage
private readonly ?Text $text;
private readonly ?Xml $xml;

public function __construct(?Directory $cacheDirectory, FilterDirectoryCollection $directories, FileCollection $files, FilterDirectoryCollection $excludeDirectories, FileCollection $excludeFiles, bool $pathCoverage, bool $includeUncoveredFiles, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
public function __construct(FilterDirectoryCollection $directories, FileCollection $files, FilterDirectoryCollection $excludeDirectories, FileCollection $excludeFiles, bool $pathCoverage, bool $includeUncoveredFiles, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
{
$this->cacheDirectory = $cacheDirectory;
$this->directories = $directories;
$this->files = $files;
$this->excludeDirectories = $excludeDirectories;
Expand All @@ -66,32 +63,6 @@ public function __construct(?Directory $cacheDirectory, FilterDirectoryCollectio
$this->xml = $xml;
}

/**
* @psalm-assert-if-true !null $this->cacheDirectory
*
* @deprecated
*/
public function hasCacheDirectory(): bool
{
return $this->cacheDirectory !== null;
}

/**
* @throws Exception
*
* @deprecated
*/
public function cacheDirectory(): Directory
{
if (!$this->hasCacheDirectory()) {
throw new Exception(
'No cache directory has been configured',
);
}

return $this->cacheDirectory;
}

public function hasNonEmptyListOfFilesToBeIncludedInCodeCoverageReport(): bool
{
return count($this->directories) > 0 || count($this->files) > 0;
Expand Down
2 changes: 0 additions & 2 deletions src/TextUI/Configuration/Xml/DefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public static function create(): self
false,
),
new CodeCoverage(
null,
CodeCoverageFilterDirectoryCollection::fromArray([]),
FileCollection::fromArray([]),
CodeCoverageFilterDirectoryCollection::fromArray([]),
Expand Down Expand Up @@ -95,7 +94,6 @@ public static function create(): self
new PHPUnit(
null,
true,
null,
80,
\PHPUnit\TextUI\Configuration\Configuration::COLOR_DEFAULT,
false,
Expand Down
17 changes: 0 additions & 17 deletions src/TextUI/Configuration/Xml/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ private function source(string $filename, DOMXPath $xpath): Source

private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
{
$cacheDirectory = null;
$pathCoverage = false;
$includeUncoveredFiles = true;
$ignoreDeprecatedCodeUnits = false;
Expand All @@ -295,14 +294,6 @@ private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
$element = $this->element($xpath, 'coverage');

if ($element) {
$cacheDirectory = $this->getStringAttribute($element, 'cacheDirectory');

if ($cacheDirectory !== null) {
$cacheDirectory = new Directory(
$this->toAbsolutePath($filename, $cacheDirectory),
);
}

$pathCoverage = $this->getBooleanAttribute(
$element,
'pathCoverage',
Expand Down Expand Up @@ -441,7 +432,6 @@ private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
}

return new CodeCoverage(
$cacheDirectory,
$this->readFilterDirectories($filename, $xpath, 'coverage/include/directory'),
$this->readFilterFiles($filename, $xpath, 'coverage/include/file'),
$this->readFilterDirectories($filename, $xpath, 'coverage/exclude/directory'),
Expand Down Expand Up @@ -728,12 +718,6 @@ private function phpunit(string $filename, DOMDocument $document): PHPUnit
$cacheDirectory = $this->toAbsolutePath($filename, $cacheDirectory);
}

$cacheResultFile = $this->getStringAttribute($document->documentElement, 'cacheResultFile');

if ($cacheResultFile !== null) {
$cacheResultFile = $this->toAbsolutePath($filename, $cacheResultFile);
}

$bootstrap = $this->getStringAttribute($document->documentElement, 'bootstrap');

if ($bootstrap !== null) {
Expand Down Expand Up @@ -773,7 +757,6 @@ private function phpunit(string $filename, DOMDocument $document): PHPUnit
return new PHPUnit(
$cacheDirectory,
$this->getBooleanAttribute($document->documentElement, 'cacheResult', true),
$cacheResultFile,
$this->getColumns($document),
$this->getColors($document),
$this->getBooleanAttribute($document->documentElement, 'stderr', false),
Expand Down
Loading

0 comments on commit d249ffa

Please sign in to comment.