From b828ddcec7134350f0333f141b317eae4fa25b39 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Mon, 4 May 2026 07:38:50 -0300 Subject: [PATCH] chore: style --- src/Plugins/Tia.php | 4 ++-- src/Plugins/Tia/Graph.php | 8 +------- src/Plugins/Tia/JsModuleGraph.php | 8 +------- src/Plugins/Tia/TableExtractor.php | 10 +--------- src/Plugins/Tia/TestPaths.php | 10 +--------- src/Plugins/Tia/WatchPatterns.php | 24 +++--------------------- src/Restarters/XdebugRestarter.php | 2 +- 7 files changed, 10 insertions(+), 56 deletions(-) diff --git a/src/Plugins/Tia.php b/src/Plugins/Tia.php index 6e6a83d8..581081af 100644 --- a/src/Plugins/Tia.php +++ b/src/Plugins/Tia.php @@ -624,7 +624,7 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable private function handleParent(array $arguments, string $projectRoot, bool $forceRebuild): array { $this->watchPatterns->useDefaults($projectRoot); - $this->branch = (new ChangedFiles($projectRoot))->currentBranch() ?? 'main'; + $this->branch = new ChangedFiles($projectRoot)->currentBranch() ?? 'main'; $fingerprint = Fingerprint::compute($projectRoot); $this->startFingerprint = $fingerprint; @@ -687,7 +687,7 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable */ private function handleWorker(array $arguments, string $projectRoot, bool $recordingGlobal, bool $replayingGlobal): array { - $this->branch = (new ChangedFiles($projectRoot))->currentBranch() ?? 'main'; + $this->branch = new ChangedFiles($projectRoot)->currentBranch() ?? 'main'; if ($replayingGlobal) { $this->installWorkerReplay($projectRoot); diff --git a/src/Plugins/Tia/Graph.php b/src/Plugins/Tia/Graph.php index 415e5291..a6371386 100644 --- a/src/Plugins/Tia/Graph.php +++ b/src/Plugins/Tia/Graph.php @@ -1289,13 +1289,7 @@ final class Graph /** @param array> $edges */ private function anyTestUses(array $edges, string $component): bool { - foreach ($edges as $components) { - if (in_array($component, $components, true)) { - return true; - } - } - - return false; + return array_any($edges, fn ($components): bool => in_array($component, $components, true)); } public function pruneMissingTests(): void diff --git a/src/Plugins/Tia/JsModuleGraph.php b/src/Plugins/Tia/JsModuleGraph.php index d0e117fa..a0d891ac 100644 --- a/src/Plugins/Tia/JsModuleGraph.php +++ b/src/Plugins/Tia/JsModuleGraph.php @@ -386,12 +386,6 @@ final class JsModuleGraph private static function hasViteConfig(string $projectRoot): bool { - foreach (self::VITE_CONFIG_NAMES as $name) { - if (is_file($projectRoot.DIRECTORY_SEPARATOR.$name)) { - return true; - } - } - - return false; + return array_any(self::VITE_CONFIG_NAMES, fn ($name): bool => is_file($projectRoot.DIRECTORY_SEPARATOR.$name)); } } diff --git a/src/Plugins/Tia/TableExtractor.php b/src/Plugins/Tia/TableExtractor.php index e16240cc..e9eb4982 100644 --- a/src/Plugins/Tia/TableExtractor.php +++ b/src/Plugins/Tia/TableExtractor.php @@ -23,15 +23,7 @@ final class TableExtractor } $prefix = strtolower(substr($trimmed, 0, 6)); - - $matched = false; - foreach (self::DML_PREFIXES as $dml) { - if (str_starts_with($prefix, $dml)) { - $matched = true; - - break; - } - } + $matched = array_any(self::DML_PREFIXES, fn ($dml): bool => str_starts_with($prefix, (string) $dml)); if (! $matched) { return []; diff --git a/src/Plugins/Tia/TestPaths.php b/src/Plugins/Tia/TestPaths.php index 23ecd7bd..58bf8ac2 100644 --- a/src/Plugins/Tia/TestPaths.php +++ b/src/Plugins/Tia/TestPaths.php @@ -94,15 +94,7 @@ final readonly class TestPaths if (in_array($relativePath, $this->files, true)) { return true; } - - $matchesSuffix = false; - foreach ($this->suffixes as $suffix) { - if (str_ends_with($relativePath, $suffix)) { - $matchesSuffix = true; - - break; - } - } + $matchesSuffix = array_any($this->suffixes, fn ($suffix): bool => str_ends_with($relativePath, (string) $suffix)); if (! $matchesSuffix) { return false; diff --git a/src/Plugins/Tia/WatchPatterns.php b/src/Plugins/Tia/WatchPatterns.php index 6b300857..e7025bdc 100644 --- a/src/Plugins/Tia/WatchPatterns.php +++ b/src/Plugins/Tia/WatchPatterns.php @@ -253,35 +253,17 @@ final class WatchPatterns private function patternTargetsDotfiles(string $pattern): bool { - foreach (explode('/', str_replace('\\', '/', $pattern)) as $segment) { - if ($segment !== '' && $segment[0] === '.') { - return true; - } - } - - return false; + return array_any(explode('/', str_replace('\\', '/', $pattern)), fn ($segment): bool => $segment !== '' && $segment[0] === '.'); } private function touchesVcs(string $file): bool { - foreach (explode('/', $file) as $segment) { - if (in_array($segment, self::VCS_DIRS, true)) { - return true; - } - } - - return false; + return array_any(explode('/', $file), fn ($segment): bool => in_array($segment, self::VCS_DIRS, true)); } private function touchesDotfile(string $file): bool { - foreach (explode('/', $file) as $segment) { - if ($segment !== '' && $segment[0] === '.') { - return true; - } - } - - return false; + return array_any(explode('/', $file), fn ($segment): bool => $segment !== '' && $segment[0] === '.'); } private function excludeMatches(string $exclude, string $file): bool diff --git a/src/Restarters/XdebugRestarter.php b/src/Restarters/XdebugRestarter.php index a0db5bbe..6696f8bf 100644 --- a/src/Restarters/XdebugRestarter.php +++ b/src/Restarters/XdebugRestarter.php @@ -37,7 +37,7 @@ final class XdebugRestarter implements Restarter return; } - (new XdebugHandler('pest'))->check(); + new XdebugHandler('pest')->check(); } private function xdebugIsCoverageOnly(): bool