From a98e98fa0b934463dcd3f798f0ef8cf9d78fcd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Thu, 23 Nov 2023 00:28:16 +0100 Subject: [PATCH] remove amp --- src/Amp/FailureCollector.php | 39 --------------------------------- src/Console/Command/Compile.php | 24 +------------------- 2 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 src/Amp/FailureCollector.php diff --git a/src/Amp/FailureCollector.php b/src/Amp/FailureCollector.php deleted file mode 100644 index ba8f3efd1..000000000 --- a/src/Amp/FailureCollector.php +++ /dev/null @@ -1,39 +0,0 @@ - - * Théo Fidry - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace KevinGH\Box\Amp; - -use Amp\MultiReasonException; -use KevinGH\Box\NotInstantiable; -use Throwable; -use function array_map; -use function array_unique; - -final class FailureCollector -{ - use NotInstantiable; - - /** - * @return list - */ - public static function collectReasons(MultiReasonException $exception): array - { - return array_unique( - array_map( - static fn (Throwable $throwable) => $throwable->getMessage(), - $exception->getReasons(), - ), - ); - } -} diff --git a/src/Console/Command/Compile.php b/src/Console/Command/Compile.php index 11c817eb9..7c20501e5 100644 --- a/src/Console/Command/Compile.php +++ b/src/Console/Command/Compile.php @@ -14,7 +14,6 @@ namespace KevinGH\Box\Console\Command; -use Amp\MultiReasonException; use DateTimeImmutable; use DateTimeInterface; use Fidry\Console\Command\Command; @@ -26,7 +25,6 @@ use Fidry\FileSystem\FileSystem; use Fidry\FileSystem\FS; use Humbug\PhpScoper\Symbol\SymbolsRegistry; -use KevinGH\Box\Amp\FailureCollector; use KevinGH\Box\Box; use KevinGH\Box\Compactor\Compactor; use KevinGH\Box\Composer\CompilerPsrLogger; @@ -484,7 +482,7 @@ private static function addFiles(Configuration $config, Box $box, CompilerLogger $count = count($config->getFiles()); - self::addFilesWithErrorHandling($config, $box, $io); + $box->addFiles($config->getFiles(), false); $logger->log( CompilerLogger::CHEVRON_PREFIX, @@ -494,26 +492,6 @@ private static function addFiles(Configuration $config, Box $box, CompilerLogger ); } - private static function addFilesWithErrorHandling(Configuration $config, Box $box, IO $io): void - { - try { - $box->addFiles($config->getFiles(), false); - - return; - } catch (MultiReasonException $ampFailure) { - // Continue - } - - // This exception is handled a different way to give me meaningful feedback to the user - $io->error([ - 'An Amp\Parallel error occurred. To diagnostic if it is an Amp error related, you may try again with "--no-parallel".', - 'Reason(s) of the failure:', - ...FailureCollector::collectReasons($ampFailure), - ]); - - throw $ampFailure; - } - private static function registerMainScript(Configuration $config, Box $box, CompilerLogger $logger): ?string { if (false === $config->hasMainScript()) {