Skip to content

Commit 09b1f70

Browse files
committed
[minor] move setting Invokable::$io to initialize method
1 parent d6ebf15 commit 09b1f70

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Invokable.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ public function addArgumentFactory(?string $type, callable $factory): self
4040
return $this;
4141
}
4242

43+
protected function initialize(InputInterface $input, OutputInterface $output): void
44+
{
45+
$this->io = ($this->argumentFactories[IO::class] ?? static fn() => new IO($input, $output))($input, $output);
46+
}
47+
4348
protected function execute(InputInterface $input, OutputInterface $output): int
4449
{
4550
self::invokeParameters();
4651

47-
$this->io = ($this->argumentFactories[IO::class] ?? static fn() => new IO($input, $output))($input, $output);
48-
4952
$parameters = \array_merge(
5053
\array_map(
5154
static function(callable $factory, ?string $type) use ($input, $output) {
@@ -57,10 +60,10 @@ static function(callable $factory, ?string $type) use ($input, $output) {
5760
\array_keys($this->argumentFactories)
5861
),
5962
[
60-
Parameter::untyped($this->io),
63+
Parameter::untyped($this->io()),
6164
Parameter::typed(InputInterface::class, $input, Argument::EXACT),
6265
Parameter::typed(OutputInterface::class, $output, Argument::EXACT),
63-
Parameter::typed(IO::class, $this->io, Argument::COVARIANCE),
66+
Parameter::typed(IO::class, $this->io(), Argument::COVARIANCE),
6467
Parameter::typed(IO::class, Parameter::factory(fn($class) => new $class($input, $output))),
6568
]
6669
);

0 commit comments

Comments
 (0)