Skip to content

Commit

Permalink
Merge branch '10.5' into 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 12, 2024
2 parents feb50cf + 3299d8c commit fd568ea
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 38 deletions.
2 changes: 0 additions & 2 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,6 @@
<code><![CDATA[listTestsXml]]></code>
<code><![CDATA[logEventsText]]></code>
<code><![CDATA[logEventsText]]></code>
<code><![CDATA[logEventsText]]></code>
<code><![CDATA[logEventsVerboseText]]></code>
<code><![CDATA[logEventsVerboseText]]></code>
<code><![CDATA[logEventsVerboseText]]></code>
<code><![CDATA[logfileJunit]]></code>
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/TestSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function addTestSuite(ReflectionClass $testClass, array $groups = []): vo
*/
public function addTestFile(string $filename, array $groups = []): void
{
if (is_file($filename) && str_ends_with($filename, '.phpt')) {
if (str_ends_with($filename, '.phpt') && is_file($filename)) {
try {
$this->addTest(new PhptTestCase($filename));
} catch (RunnerException $e) {
Expand Down
7 changes: 4 additions & 3 deletions src/Runner/Baseline/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ public function equals(self $other): bool
*/
private static function calculateHash(string $file, int $line): string
{
if (!is_file($file)) {
$lines = @file($file, FILE_IGNORE_NEW_LINES);

if ($lines === false && !is_file($file)) {
throw new FileDoesNotExistException($file);
}

$lines = file($file, FILE_IGNORE_NEW_LINES);
$key = $line - 1;
$key = $line - 1;

if (!isset($lines[$key])) {
throw new FileDoesNotHaveLineException($file, $line);
Expand Down
12 changes: 5 additions & 7 deletions src/Runner/PhptTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,13 @@ private function cleanupForCoverage(): RawCodeCoverageData
$coverage = RawCodeCoverageData::fromXdebugWithoutPathCoverage([]);
$files = $this->getCoverageFiles();

if (is_file($files['coverage'])) {
$buffer = @file_get_contents($files['coverage']);
$buffer = @file_get_contents($files['coverage']);

if ($buffer !== false) {
$coverage = @unserialize($buffer);
if ($buffer !== false) {
$coverage = @unserialize($buffer);

if ($coverage === false) {
$coverage = RawCodeCoverageData::fromXdebugWithoutPathCoverage([]);
}
if ($coverage === false) {
$coverage = RawCodeCoverageData::fromXdebugWithoutPathCoverage([]);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/Runner/ResultCache/DefaultResultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use function file_put_contents;
use function is_array;
use function is_dir;
use function is_file;
use function json_decode;
use function json_encode;
use PHPUnit\Framework\TestStatus\TestStatus;
Expand Down Expand Up @@ -86,12 +85,14 @@ public function time(string $id): float

public function load(): void
{
if (!is_file($this->cacheFilename)) {
$contents = @file_get_contents($this->cacheFilename);

if ($contents === false) {
return;
}

$data = json_decode(
file_get_contents($this->cacheFilename),
$contents,
true,
);

Expand Down
9 changes: 2 additions & 7 deletions src/TextUI/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace PHPUnit\TextUI;

use const PHP_EOL;
use function is_file;
use function is_readable;
use function printf;
use function realpath;
Expand Down Expand Up @@ -510,9 +509,7 @@ private function writeRandomSeedInformation(Printer $printer, Configuration $con
private function registerLogfileWriters(Configuration $configuration): void
{
if ($configuration->hasLogEventsText()) {
if (is_file($configuration->logEventsText())) {
unlink($configuration->logEventsText());
}
@unlink($configuration->logEventsText());

EventFacade::instance()->registerTracer(
new EventLogger(
Expand All @@ -523,9 +520,7 @@ private function registerLogfileWriters(Configuration $configuration): void
}

if ($configuration->hasLogEventsVerboseText()) {
if (is_file($configuration->logEventsVerboseText())) {
unlink($configuration->logEventsVerboseText());
}
@unlink($configuration->logEventsVerboseText());

EventFacade::instance()->registerTracer(
new EventLogger(
Expand Down
2 changes: 1 addition & 1 deletion src/TextUI/Configuration/Cli/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public function fromParameters(array $parameters): Configuration
case '--use-baseline':
$useBaseline = $option[1];

if (!is_file($useBaseline) && basename($useBaseline) === $useBaseline) {
if (basename($useBaseline) === $useBaseline && !is_file($useBaseline)) {
$useBaseline = getcwd() . DIRECTORY_SEPARATOR . $useBaseline;
}

Expand Down
14 changes: 7 additions & 7 deletions src/TextUI/Configuration/TestSuiteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ public function build(Configuration $configuration): TestSuite
*/
private function testSuiteFromPath(string $path, array $suffixes, ?TestSuite $suite = null): TestSuite
{
if (str_ends_with($path, '.phpt') && is_file($path)) {
$suite = $suite ?: TestSuite::empty($path);
$suite->addTestFile($path);

return $suite;
}

if (is_dir($path)) {
$files = (new FileIteratorFacade)->getFilesAsArray($path, $suffixes);

Expand All @@ -100,13 +107,6 @@ private function testSuiteFromPath(string $path, array $suffixes, ?TestSuite $su
return $suite;
}

if (is_file($path) && str_ends_with($path, '.phpt')) {
$suite = $suite ?: TestSuite::empty($path);
$suite->addTestFile($path);

return $suite;
}

try {
$testClass = (new TestSuiteLoader)->load($path);
} catch (Exception $e) {
Expand Down
6 changes: 3 additions & 3 deletions src/Util/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ private static function shouldPrintFrame(array $frame, false|string $prefix, Exc
$script = '';
}

return is_file($file) &&
return $fileIsNotPrefixed &&
$file !== $script &&
self::fileIsExcluded($file, $excludeList) &&
$fileIsNotPrefixed &&
$file !== $script;
is_file($file);
}

private static function fileIsExcluded(string $file, ExcludeList $excludeList): bool
Expand Down
8 changes: 4 additions & 4 deletions src/Util/PHP/AbstractPhpProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use function array_merge;
use function assert;
use function escapeshellarg;
use function file_exists;
use function file_get_contents;
use function ini_get_all;
use function restore_error_handler;
Expand Down Expand Up @@ -137,12 +136,13 @@ public function runTestJob(string $job, Test $test, string $processResultFile):
{
$_result = $this->runJob($job);

$processResult = '';
$processResult = @file_get_contents($processResultFile);

if (file_exists($processResultFile)) {
$processResult = file_get_contents($processResultFile);
if ($processResult !== false) {

@unlink($processResultFile);
} else {
$processResult = '';
}

$this->processChildResult(
Expand Down

0 comments on commit fd568ea

Please sign in to comment.