1818
1919class PipelineProxy implements PipelineRuntimeInterface
2020{
21- /** @var callable $callback */
22- private $ callback ;
2321 /** @var list<callable> $queuedCalls */
2422 private array $ queuedCalls = [];
2523
2624 public function __construct (
27- callable $ callback ,
25+ callable $ factory ,
2826 private readonly ConsoleOutput $ output ,
2927 private readonly PipelineInterface &WalkableInterface $ pipeline ,
3028 private readonly State \StateOutput \Workflow $ state ,
3129 private readonly string $ filename ,
3230 ) {
33- $ this ->callback = $ callback ;
31+ $ this ->queuedCalls [] = static function (PipelineConsoleRuntime $ runtime ) {
32+ $ factory ($ runtime );
33+ };
3434 }
3535
3636 public function extract (
3737 ExtractorInterface $ extractor ,
3838 RejectionInterface $ rejection ,
3939 StateInterface $ state ,
4040 ): self {
41- $ this ->queuedCalls [] = function (PipelineConsoleRuntime $ runtime ) use ($ extractor , $ rejection , $ state ): void {
41+ $ this ->queuedCalls [] = static function (PipelineConsoleRuntime $ runtime ) use ($ extractor , $ rejection , $ state ): void {
4242 $ runtime ->extract ($ extractor , $ rejection , $ state );
4343 };
4444
@@ -50,7 +50,7 @@ public function transform(
5050 RejectionInterface $ rejection ,
5151 StateInterface $ state ,
5252 ): self {
53- $ this ->queuedCalls [] = function (PipelineConsoleRuntime $ runtime ) use ($ transformer , $ rejection , $ state ): void {
53+ $ this ->queuedCalls [] = static function (PipelineConsoleRuntime $ runtime ) use ($ transformer , $ rejection , $ state ): void {
5454 $ runtime ->transform ($ transformer , $ rejection , $ state );
5555 };
5656
@@ -62,7 +62,7 @@ public function load(
6262 RejectionInterface $ rejection ,
6363 StateInterface $ state ,
6464 ): self {
65- $ this ->queuedCalls [] = function (PipelineConsoleRuntime $ runtime ) use ($ loader , $ rejection , $ state ): void {
65+ $ this ->queuedCalls [] = static function (PipelineConsoleRuntime $ runtime ) use ($ loader , $ rejection , $ state ): void {
6666 $ runtime ->load ($ loader , $ rejection , $ state );
6767 };
6868
@@ -73,10 +73,8 @@ public function run(int $interval = 1000): int
7373 {
7474 $ runtime = new PipelineConsoleRuntime ($ this ->output , $ this ->pipeline , $ this ->state ->withPipeline ($ this ->filename ));
7575
76- ($ this ->callback )($ runtime );
77-
7876 foreach ($ this ->queuedCalls as $ queuedCall ) {
79- $ queuedCall ($ this -> callback );
77+ $ queuedCall ($ this );
8078 }
8179
8280 $ this ->queuedCalls = [];
0 commit comments