mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
chore: improves type coverage
This commit is contained in:
@ -90,8 +90,7 @@ final class DatasetsRepository
|
||||
*/
|
||||
public static function resolve(array $dataset, string $currentTestFile): array|null
|
||||
{
|
||||
/* @phpstan-ignore-next-line */
|
||||
if (empty($dataset)) {
|
||||
if ($dataset === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -177,25 +176,21 @@ final class DatasetsRepository
|
||||
/**
|
||||
* @return Closure|iterable<int|string, mixed>
|
||||
*/
|
||||
private static function getScopedDataset(string $name, string $currentTestFile)
|
||||
private static function getScopedDataset(string $name, string $currentTestFile): Closure|iterable
|
||||
{
|
||||
$matchingDatasets = array_filter(self::$datasets, function (string $key) use ($name, $currentTestFile) {
|
||||
$matchingDatasets = array_filter(self::$datasets, function (string $key) use ($name, $currentTestFile): bool {
|
||||
[$datasetScope, $datasetName] = explode(self::SEPARATOR, $key);
|
||||
|
||||
if ($name !== $datasetName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! str_starts_with($currentTestFile, $datasetScope)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return str_starts_with($currentTestFile, $datasetScope);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
$closestScopeDatasetKey = array_reduce(
|
||||
array_keys($matchingDatasets),
|
||||
fn ($keyA, $keyB) => $keyA !== null && strlen($keyA) > strlen($keyB) ? $keyA : $keyB
|
||||
fn ($keyA, $keyB) => $keyA !== null && strlen((string) $keyA) > strlen($keyB) ? $keyA : $keyB
|
||||
);
|
||||
|
||||
if ($closestScopeDatasetKey === null) {
|
||||
|
||||
@ -42,7 +42,7 @@ final class TestRepository
|
||||
*/
|
||||
public function getFilenames(): array
|
||||
{
|
||||
$testCases = array_filter($this->testCases, static fn (TestCaseFactory $testCase) => $testCase->methodsUsingOnly() !== []);
|
||||
$testCases = array_filter($this->testCases, static fn (TestCaseFactory $testCase): bool => $testCase->methodsUsingOnly() !== []);
|
||||
|
||||
if ($testCases === []) {
|
||||
$testCases = $this->testCases;
|
||||
|
||||
Reference in New Issue
Block a user