Skip to content

Commit

Permalink
Closes #4600
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 13, 2023
1 parent 03dd125 commit ef64f0a
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 @@ -763,10 +763,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 @@ -797,17 +793,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>baseline</code>
<code>detect</code>
Expand Down Expand Up @@ -888,11 +873,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 @@ -945,11 +925,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 @@ -31,12 +31,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 @@ -151,12 +149,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 @@ -268,11 +264,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 @@ -288,11 +279,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 @@ -831,7 +817,6 @@ public function fromParameters(array $parameters): Configuration
$bootstrap,
$cacheDirectory,
$cacheResult,
$cacheResultFile,
$checkVersion,
$colors,
$columns,
Expand All @@ -846,7 +831,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 @@ -27,7 +27,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 @@ -43,7 +42,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 @@ -125,7 +123,7 @@ final class Configuration
* @psalm-param list<non-empty-string> $arguments
* @psalm-param ?non-empty-list<non-empty-string> $testSuffixes
*/
public function __construct(array $arguments, ?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, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, 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(array $arguments, ?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, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, 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->arguments = $arguments;
$this->atLeastVersion = $atLeastVersion;
Expand All @@ -135,7 +133,6 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba
$this->bootstrap = $bootstrap;
$this->cacheDirectory = $cacheDirectory;
$this->cacheResult = $cacheResult;
$this->cacheResultFile = $cacheResultFile;
$this->checkVersion = $checkVersion;
$this->colors = $colors;
$this->columns = $columns;
Expand All @@ -151,7 +148,6 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba
$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 @@ -374,30 +370,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 @@ -683,30 +655,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 @@ -77,20 +77,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 @@ -54,7 +54,6 @@ public static function create(): self
false,
),
new CodeCoverage(
null,
CodeCoverageFilterDirectoryCollection::fromArray([]),
FileCollection::fromArray([]),
CodeCoverageFilterDirectoryCollection::fromArray([]),
Expand Down Expand Up @@ -97,7 +96,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 @@ -299,7 +299,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 @@ -308,14 +307,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 @@ -454,7 +445,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 @@ -741,12 +731,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 @@ -786,7 +770,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 ef64f0a

Please sign in to comment.