mirror of
https://github.com/pestphp/pest.git
synced 2026-04-24 07:57:29 +02:00
wip
This commit is contained in:
@ -39,7 +39,7 @@ use Symfony\Component\Process\Process;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class BaselineSync
|
||||
final readonly class BaselineSync
|
||||
{
|
||||
/**
|
||||
* Conventional workflow filename teams publish from. Not configurable
|
||||
@ -63,8 +63,8 @@ final class BaselineSync
|
||||
private const string COVERAGE_ASSET = Tia::KEY_COVERAGE_CACHE;
|
||||
|
||||
public function __construct(
|
||||
private readonly State $state,
|
||||
private readonly OutputInterface $output,
|
||||
private State $state,
|
||||
private OutputInterface $output,
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
||||
@ -38,7 +38,7 @@ final readonly class ChangedFiles
|
||||
* that git still reports as modified but whose content is bit-identical
|
||||
* to the previous TIA invocation.
|
||||
*
|
||||
* @param array<int, string> $files project-relative paths.
|
||||
* @param array<int, string> $files project-relative paths.
|
||||
* @param array<string, string> $lastRunTree path → content hash from last run.
|
||||
* @return array<int, string>
|
||||
*/
|
||||
@ -101,7 +101,7 @@ final readonly class ChangedFiles
|
||||
* detect which files are actually different.
|
||||
*
|
||||
* @param array<int, string> $files
|
||||
* @return array<string, string> path → xxh128 content hash
|
||||
* @return array<string, string> path → xxh128 content hash
|
||||
*/
|
||||
public function snapshotTree(array $files): array
|
||||
{
|
||||
|
||||
@ -46,7 +46,7 @@ final class CoverageMerger
|
||||
{
|
||||
$state = self::state();
|
||||
|
||||
if ($state === null || ! $state->exists(Tia::KEY_COVERAGE_MARKER)) {
|
||||
if (! $state instanceof State || ! $state->exists(Tia::KEY_COVERAGE_MARKER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ final class CoverageMerger
|
||||
// verbatim (as serialised bytes) for next time.
|
||||
$current = self::requireCoverage($reportPath);
|
||||
|
||||
if ($current !== null) {
|
||||
if ($current instanceof CodeCoverage) {
|
||||
$state->write(Tia::KEY_COVERAGE_CACHE, serialize($current));
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ final class CoverageMerger
|
||||
$cached = self::unserializeCoverage($cachedBytes);
|
||||
$current = self::requireCoverage($reportPath);
|
||||
|
||||
if ($cached === null || $current === null) {
|
||||
if (! $cached instanceof CodeCoverage || ! $current instanceof CodeCoverage) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ final class CoverageMerger
|
||||
// can `require` it, and to the state cache for the next run.
|
||||
@file_put_contents(
|
||||
$reportPath,
|
||||
"<?php return unserialize(".var_export($serialised, true).");\n",
|
||||
'<?php return unserialize('.var_export($serialised, true).");\n",
|
||||
);
|
||||
$state->write(Tia::KEY_COVERAGE_CACHE, $serialised);
|
||||
}
|
||||
@ -108,10 +108,12 @@ final class CoverageMerger
|
||||
|
||||
foreach ($lineCoverage as $file => $lines) {
|
||||
foreach ($lines as $line => $ids) {
|
||||
if ($ids === null || $ids === []) {
|
||||
if ($ids === null) {
|
||||
continue;
|
||||
}
|
||||
if ($ids === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filtered = array_values(array_diff($ids, $currentIds));
|
||||
|
||||
if ($filtered !== $ids) {
|
||||
@ -175,7 +177,6 @@ final class CoverageMerger
|
||||
private static function unserializeCoverage(string $bytes): ?CodeCoverage
|
||||
{
|
||||
try {
|
||||
/** @var mixed $value */
|
||||
$value = @unserialize($bytes);
|
||||
} catch (Throwable) {
|
||||
return null;
|
||||
|
||||
@ -17,14 +17,14 @@ use Pest\Plugins\Tia\Contracts\State;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class FileState implements State
|
||||
final readonly class FileState implements State
|
||||
{
|
||||
/**
|
||||
* Configured root. May not exist on disk yet; resolved + created on
|
||||
* the first write. Keeping the raw string lets the instance be built
|
||||
* before Pest's temp dir has been materialised.
|
||||
*/
|
||||
private readonly string $rootDir;
|
||||
private string $rootDir;
|
||||
|
||||
public function __construct(string $rootDir)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user