Skip to content

Commit 93d7375

Browse files
committed
Inline symplify/easy-parallel into src/Parallel
The symplify/easy-parallel package is deprecated. Move its classes into Rector\Parallel namespace under src/Parallel and drop the dependency. The transitive deps it provided (fidry/cpu-core-counter, react/child-process) are now required directly. Claude-Session: https://claude.ai/code/session_01PMRRBcHZHHSXHYNMFbNAnF
1 parent c1c61c4 commit 93d7375

20 files changed

Lines changed: 446 additions & 20 deletions

‎composer.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
"composer/xdebug-handler": "^3.0.5",
2020
"doctrine/inflector": "^2.1",
2121
"entropy/entropy": "^0.4.12",
22+
"fidry/cpu-core-counter": "^1.1",
2223
"nette/utils": "^4.1.4",
2324
"nikic/php-parser": "^5.8",
2425
"ondram/ci-detector": "^4.2",
2526
"phpstan/phpdoc-parser": "^2.3.3",
2627
"phpstan/phpstan": "^2.2.6",
28+
"react/child-process": "^0.6.5",
2729
"react/event-loop": "^1.6",
2830
"react/promise": "^3.3",
2931
"react/socket": "^1.17",
@@ -37,7 +39,6 @@
3739
"symfony/filesystem": "^8.1",
3840
"symfony/finder": "^8.1",
3941
"symfony/process": "^8.1",
40-
"symplify/easy-parallel": "^11.2.2",
4142
"symplify/rule-doc-generator-contracts": "^11.2",
4243
"webmozart/assert": "^2.4"
4344
},

‎src/Application/ApplicationFileProcessor.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Rector\Configuration\Parameter\SimpleParameterProvider;
1313
use Rector\FileSystem\FilesFinder;
1414
use Rector\Parallel\Application\ParallelFileProcessor;
15+
use Rector\Parallel\CpuCoreCountProvider;
16+
use Rector\Parallel\Exception\ParallelShouldNotHappenException;
17+
use Rector\Parallel\ScheduleFactory;
1518
use Rector\PhpParser\Parser\ParserErrors;
1619
use Rector\Reporting\MissConfigurationReporter;
1720
use Rector\Skipper\Skipper\UsedSkipCollector;
@@ -25,9 +28,6 @@
2528
use Rector\ValueObject\Reporting\FileDiff;
2629
use Symfony\Component\Console\Input\InputInterface;
2730
use Symfony\Component\Console\Style\SymfonyStyle;
28-
use Symplify\EasyParallel\CpuCoreCountProvider;
29-
use Symplify\EasyParallel\Exception\ParallelShouldNotHappenException;
30-
use Symplify\EasyParallel\ScheduleFactory;
3131
use Throwable;
3232

3333
final class ApplicationFileProcessor

‎src/ChangesReporting/ValueObject/RectorWithLineChange.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace Rector\ChangesReporting\ValueObject;
66

77
use Rector\Contract\Rector\RectorInterface;
8+
use Rector\Parallel\Contract\SerializableInterface;
89
use Rector\PostRector\Contract\Rector\PostRectorInterface;
9-
use Symplify\EasyParallel\Contract\SerializableInterface;
1010
use Webmozart\Assert\Assert;
1111

1212
final readonly class RectorWithLineChange implements SerializableInterface

‎src/Console/Command/WorkerCommand.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Rector\Configuration\ConfigurationRuleFilter;
1616
use Rector\Configuration\Option;
1717
use Rector\Console\ProcessConfigureDecorator;
18+
use Rector\Parallel\Enum\Action;
19+
use Rector\Parallel\Enum\ReactCommand;
20+
use Rector\Parallel\Enum\ReactEvent;
1821
use Rector\Parallel\ValueObject\Bridge;
1922
use Rector\StaticReflection\DynamicSourceLocatorDecorator;
2023
use Rector\Util\MemoryLimiter;
@@ -23,9 +26,6 @@
2326
use Symfony\Component\Console\Command\Command;
2427
use Symfony\Component\Console\Input\InputInterface;
2528
use Symfony\Component\Console\Output\OutputInterface;
26-
use Symplify\EasyParallel\Enum\Action;
27-
use Symplify\EasyParallel\Enum\ReactCommand;
28-
use Symplify\EasyParallel\Enum\ReactEvent;
2929
use Throwable;
3030
use Webmozart\Assert\Assert;
3131

@@ -154,7 +154,7 @@ private function runWorker(
154154
);
155155

156156
/**
157-
* this invokes all listeners listening $decoder->on(...) @see \Symplify\EasyParallel\Enum\ReactEvent::DATA
157+
* this invokes all listeners listening $decoder->on(...) @see \Rector\Parallel\Enum\ReactEvent::DATA
158158
*/
159159
$encoder->write([
160160
ReactCommand::ACTION => Action::RESULT,

‎src/Parallel/Application/ParallelFileProcessor.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
use Rector\Configuration\Parameter\SimpleParameterProvider;
1515
use Rector\Console\Command\ProcessCommand;
1616
use Rector\Parallel\Command\WorkerCommandLineFactory;
17+
use Rector\Parallel\Enum\Action;
18+
use Rector\Parallel\Enum\Content;
19+
use Rector\Parallel\Enum\ReactCommand;
20+
use Rector\Parallel\Enum\ReactEvent;
1721
use Rector\Parallel\ValueObject\Bridge;
22+
use Rector\Parallel\ValueObject\ParallelProcess;
23+
use Rector\Parallel\ValueObject\ProcessPool;
24+
use Rector\Parallel\ValueObject\Schedule;
1825
use Rector\ValueObject\Error\SystemError;
1926
use Rector\ValueObject\ProcessResult;
2027
use Rector\ValueObject\Reporting\FileDiff;
2128
use Symfony\Component\Console\Command\Command;
2229
use Symfony\Component\Console\Input\InputInterface;
23-
use Symplify\EasyParallel\Enum\Action;
24-
use Symplify\EasyParallel\Enum\Content;
25-
use Symplify\EasyParallel\Enum\ReactCommand;
26-
use Symplify\EasyParallel\Enum\ReactEvent;
27-
use Symplify\EasyParallel\ValueObject\ParallelProcess;
28-
use Symplify\EasyParallel\ValueObject\ProcessPool;
29-
use Symplify\EasyParallel\ValueObject\Schedule;
3030
use Throwable;
3131

3232
/**

‎src/Parallel/Command/WorkerCommandLineFactory.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
use Rector\ChangesReporting\Output\JsonOutputFormatter;
88
use Rector\Configuration\Option;
99
use Rector\FileSystem\FilePathHelper;
10+
use Rector\Parallel\Exception\ParallelShouldNotHappenException;
11+
use Rector\Parallel\Reflection\CommandFromReflectionFactory;
1012
use Symfony\Component\Console\Command\Command;
1113
use Symfony\Component\Console\Input\InputInterface;
12-
use Symplify\EasyParallel\Exception\ParallelShouldNotHappenException;
13-
use Symplify\EasyParallel\Reflection\CommandFromReflectionFactory;
1414

1515
/**
1616
* @see \Rector\Tests\Parallel\Command\WorkerCommandLineFactoryTest
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Parallel\Contract;
6+
7+
use JsonSerializable;
8+
9+
interface SerializableInterface extends JsonSerializable
10+
{
11+
/**
12+
* @param array<string, mixed> $json
13+
*/
14+
public static function decode(array $json): self;
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Parallel;
6+
7+
use Fidry\CpuCoreCounter\CpuCoreCounter;
8+
use Fidry\CpuCoreCounter\NumberOfCpuCoreNotFound;
9+
10+
final class CpuCoreCountProvider
11+
{
12+
private const int DEFAULT_CORE_COUNT = 2;
13+
14+
public function provide(): int
15+
{
16+
try {
17+
return (new CpuCoreCounter())->getCount();
18+
} catch (NumberOfCpuCoreNotFound) {
19+
return self::DEFAULT_CORE_COUNT;
20+
}
21+
}
22+
}

‎src/Parallel/Enum/Action.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Parallel\Enum;
6+
7+
final class Action
8+
{
9+
public const string HELLO = 'hello';
10+
11+
public const string MAIN = 'main';
12+
13+
public const string RESULT = 'result';
14+
}

‎src/Parallel/Enum/Content.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Parallel\Enum;
6+
7+
final class Content
8+
{
9+
public const string RESULT = 'result';
10+
11+
public const string FILES = 'files';
12+
}

0 commit comments

Comments
 (0)