1818
1919class PipelineProxy implements PipelineRuntimeInterface
2020{
21- /** @var list< callable> */
21+ /** @var callable $callback */
2222 private $ callback ;
23- private array $ callbacks = [];
23+ /** @var list<callable> $queuedCalls */
24+ private array $ queuedCalls = [];
2425
2526 public function __construct (
2627 callable $ callback ,
@@ -37,7 +38,7 @@ public function extract(
3738 RejectionInterface $ rejection ,
3839 StateInterface $ state ,
3940 ): self {
40- $ this ->callbacks [] = function (PipelineConsoleRuntime $ runtime ) use ($ extractor , $ rejection , $ state ): void {
41+ $ this ->queuedCalls [] = function (PipelineConsoleRuntime $ runtime ) use ($ extractor , $ rejection , $ state ): void {
4142 $ runtime ->extract ($ extractor , $ rejection , $ state );
4243 };
4344
@@ -49,7 +50,7 @@ public function transform(
4950 RejectionInterface $ rejection ,
5051 StateInterface $ state ,
5152 ): self {
52- $ this ->callbacks [] = function (PipelineConsoleRuntime $ runtime ) use ($ transformer , $ rejection , $ state ): void {
53+ $ this ->queuedCalls [] = function (PipelineConsoleRuntime $ runtime ) use ($ transformer , $ rejection , $ state ): void {
5354 $ runtime ->transform ($ transformer , $ rejection , $ state );
5455 };
5556
@@ -61,7 +62,7 @@ public function load(
6162 RejectionInterface $ rejection ,
6263 StateInterface $ state ,
6364 ): self {
64- $ this ->callbacks [] = function (PipelineConsoleRuntime $ runtime ) use ($ loader , $ rejection , $ state ): void {
65+ $ this ->queuedCalls [] = function (PipelineConsoleRuntime $ runtime ) use ($ loader , $ rejection , $ state ): void {
6566 $ runtime ->load ($ loader , $ rejection , $ state );
6667 };
6768
@@ -74,11 +75,11 @@ public function run(int $interval = 1000): int
7475
7576 ($ this ->callback )($ runtime );
7677
77- foreach ($ this ->callbacks as $ callback ) {
78- $ callback ($ this ->callback );
78+ foreach ($ this ->queuedCalls as $ queuedCall ) {
79+ $ queuedCall ($ this ->callback );
7980 }
8081
81- $ this ->callbacks = [];
82+ $ this ->queuedCalls = [];
8283
8384 return $ runtime ->run ($ interval );
8485 }
0 commit comments