mirror of
https://github.com/pestphp/pest.git
synced 2026-04-20 22:20:17 +02:00
feat(tia): continues to work on poc
This commit is contained in:
@ -713,6 +713,6 @@ final class Tia implements AddsOutput, AfterEachable, BeforeEachable, HandlesArg
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return property_exists($coverage, 'coverage') && $coverage->coverage === true;
|
return $coverage->coverage === true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ final readonly class Fingerprint
|
|||||||
private const int SCHEMA_VERSION = 2;
|
private const int SCHEMA_VERSION = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param non-empty-string $projectRoot
|
* @return array<string, int|string|null>
|
||||||
*/
|
*/
|
||||||
public static function compute(string $projectRoot): array
|
public static function compute(string $projectRoot): array
|
||||||
{
|
{
|
||||||
|
|||||||
@ -166,11 +166,17 @@ final class Graph
|
|||||||
return array_keys($this->edges);
|
return array_keys($this->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, int|string|null> $fingerprint
|
||||||
|
*/
|
||||||
public function setFingerprint(array $fingerprint): void
|
public function setFingerprint(array $fingerprint): void
|
||||||
{
|
{
|
||||||
$this->fingerprint = $fingerprint;
|
$this->fingerprint = $fingerprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, int|string|null>
|
||||||
|
*/
|
||||||
public function fingerprint(): array
|
public function fingerprint(): array
|
||||||
{
|
{
|
||||||
return $this->fingerprint;
|
return $this->fingerprint;
|
||||||
|
|||||||
@ -69,12 +69,20 @@ final class Recorder
|
|||||||
$this->driver = 'pcov';
|
$this->driver = 'pcov';
|
||||||
$this->driverAvailable = true;
|
$this->driverAvailable = true;
|
||||||
} elseif (function_exists('xdebug_start_code_coverage')) {
|
} elseif (function_exists('xdebug_start_code_coverage')) {
|
||||||
// Probe: Xdebug silently emits a warning and refuses to start
|
// Xdebug is loaded. Probe whether coverage mode is active by
|
||||||
// when not in coverage mode. Suppress + check for mode errors.
|
// attempting a start — it emits E_WARNING when the mode is off.
|
||||||
$ok = @\xdebug_start_code_coverage();
|
// We capture the warning via a temporary error handler.
|
||||||
|
$probeOk = true;
|
||||||
|
set_error_handler(static function () use (&$probeOk): bool {
|
||||||
|
$probeOk = false;
|
||||||
|
|
||||||
if ($ok === null || $ok) {
|
return true;
|
||||||
@\xdebug_stop_code_coverage(false);
|
});
|
||||||
|
\xdebug_start_code_coverage();
|
||||||
|
restore_error_handler();
|
||||||
|
|
||||||
|
if ($probeOk) {
|
||||||
|
\xdebug_stop_code_coverage(false);
|
||||||
$this->driver = 'xdebug';
|
$this->driver = 'xdebug';
|
||||||
$this->driverAvailable = true;
|
$this->driverAvailable = true;
|
||||||
}
|
}
|
||||||
@ -195,31 +203,23 @@ final class Recorder
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$reflection = new ReflectionClass($className);
|
||||||
$reflection = new ReflectionClass($className);
|
|
||||||
} catch (ReflectionException) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($reflection->hasProperty('__filename')) {
|
if ($reflection->hasProperty('__filename')) {
|
||||||
try {
|
$property = $reflection->getProperty('__filename');
|
||||||
$property = $reflection->getProperty('__filename');
|
|
||||||
|
|
||||||
if ($property->isStatic()) {
|
if ($property->isStatic()) {
|
||||||
$value = $property->getValue();
|
$value = $property->getValue();
|
||||||
|
|
||||||
if (is_string($value) && $value !== '') {
|
if (is_string($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (ReflectionException) {
|
|
||||||
// fall through to getFileName()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $reflection->getFileName();
|
$file = $reflection->getFileName();
|
||||||
|
|
||||||
return $file !== false && $file !== '' ? $file : null;
|
return is_string($file) ? $file : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -66,6 +66,7 @@ final class State
|
|||||||
* Turns on replay mode with the given graph + affected set.
|
* Turns on replay mode with the given graph + affected set.
|
||||||
*
|
*
|
||||||
* @param array<string, true> $affectedFiles
|
* @param array<string, true> $affectedFiles
|
||||||
|
* @param array<string, true> $previousDefects
|
||||||
*/
|
*/
|
||||||
public function activate(string $projectRoot, Graph $graph, array $affectedFiles, array $previousDefects): void
|
public function activate(string $projectRoot, Graph $graph, array $affectedFiles, array $previousDefects): void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user