Skip to content

Commit

Permalink
dropping use of parallelMap()
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswagoner committed Jan 3, 2024
1 parent edc4668 commit 4c12463
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"php": "^8.1",
"amphp/amp": "^v3.0",
"amphp/parallel": "^2.2",
"amphp/parallel-functions": "^2.0",
"illuminate/collections": "^9.30|^10.0",
"spatie/laravel-package-tools": "^1.4.3",
"symfony/finder" : "^6.0|^7.0"
Expand Down
14 changes: 6 additions & 8 deletions src/DiscoverWorkers/ParallelDiscoverWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Spatie\StructureDiscoverer\DiscoverWorkers;

use function Amp\ParallelFunctions\parallelMap;
use function Amp\Promise\wait;
use function Amp\async;
use function Amp\Future\await;

use Illuminate\Support\Collection;
use Spatie\StructureDiscoverer\Data\DiscoverProfileConfig;
use function Amp\ParallelFunctions\parallelMap;

Check failure on line 10 in src/DiscoverWorkers/ParallelDiscoverWorker.php

View workflow job for this annotation

GitHub Actions / phpstan

Used function Amp\ParallelFunctions\parallelMap not found.

class ParallelDiscoverWorker implements DiscoverWorker
{
Expand All @@ -19,12 +20,9 @@ public function run(Collection $filenames, DiscoverProfileConfig $config): array
{
$sets = $filenames->chunk($this->filesPerJob)->toArray();

$promise = parallelMap(
$sets,
fn (array $set): array => $config->structureParser->execute($set)
);

$found = wait($promise);
$found = await(array_map(function ($set) use ($config) {
return async(fn () => $config->structureParser->execute($set));
}, $sets));

return array_merge(...$found);
}
Expand Down

0 comments on commit 4c12463

Please sign in to comment.