Skip to content

Commit 3ca46ba

Browse files
committed
Fixed Symfony compat problem
1 parent 57c5a7b commit 3ca46ba

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

packages/auxiliary/src/Beads/Presentation/Console/TbdApplicationFactory.php

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Cognesy\Auxiliary\Beads\Presentation\Console\Command\ShowCommand;
3333
use Cognesy\Auxiliary\Beads\Presentation\Console\Command\UpdateCommand;
3434
use Symfony\Component\Console\Application;
35+
use Symfony\Component\Console\Command\Command;
3536

3637
class TbdApplicationFactory
3738
{
@@ -44,19 +45,33 @@ public function create(): Application {
4445
$ids = new TbdIdFactory();
4546
$map = new TbdInputMapper();
4647

47-
$app->addCommand(new InitCommand(new InitAction($store)));
48-
$app->addCommand(new ListCommand(new ListAction($store), $map));
49-
$app->addCommand(new ReadyCommand(new ReadyAction($store)));
50-
$app->addCommand(new ShowCommand(new ShowAction($store)));
51-
$app->addCommand(new CreateCommand(new CreateAction($store, $ids, $clock, $map), $map));
52-
$app->addCommand(new UpdateCommand(new UpdateAction($store, $clock, $map), $map));
53-
$app->addCommand(new CloseCommand(new CloseAction($store, $clock)));
54-
$app->addCommand(new CommentCommand(new CommentAction($store, $clock)));
55-
$app->addCommand(new DepAddCommand(new DepAddAction($store, $clock, $map)));
56-
$app->addCommand(new DepRemoveCommand(new DepRemoveAction($store, $clock)));
57-
$app->addCommand(new DepTreeCommand(new DepTreeAction($store), $map));
58-
$app->addCommand(new CompactCommand(new CompactAction($store)));
48+
$commands = [
49+
new InitCommand(new InitAction($store)),
50+
new ListCommand(new ListAction($store), $map),
51+
new ReadyCommand(new ReadyAction($store)),
52+
new ShowCommand(new ShowAction($store)),
53+
new CreateCommand(new CreateAction($store, $ids, $clock, $map), $map),
54+
new UpdateCommand(new UpdateAction($store, $clock, $map), $map),
55+
new CloseCommand(new CloseAction($store, $clock)),
56+
new CommentCommand(new CommentAction($store, $clock)),
57+
new DepAddCommand(new DepAddAction($store, $clock, $map)),
58+
new DepRemoveCommand(new DepRemoveAction($store, $clock)),
59+
new DepTreeCommand(new DepTreeAction($store), $map),
60+
new CompactCommand(new CompactAction($store)),
61+
];
62+
63+
foreach ($commands as $command) {
64+
$this->registerCommand($app, $command);
65+
}
5966

6067
return $app;
6168
}
69+
70+
private function registerCommand(Application $app, Command $command): void {
71+
if (method_exists($app, 'addCommand')) {
72+
$app->addCommand($command);
73+
} else {
74+
$app->add($command);
75+
}
76+
}
6277
}

packages/doctor/tests/Feature/Docgen/GenerateLlmsCommandTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242

4343
// Create application and add command
4444
$this->application = new Application();
45-
$this->application->addCommand($this->command);
45+
if (method_exists($this->application, 'addCommand')) {
46+
$this->application->addCommand($this->command);
47+
} else {
48+
$this->application->add($this->command);
49+
}
4650
});
4751

4852
afterEach(function () {

packages/schema/src/Reflection/FunctionInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static public function fromClosure(Closure $closure) : self {
2929
$class = $reflection->getClosureScopeClass()?->getName();
3030
$functionName = $reflection->getName();
3131
return new self(match(true) {
32-
!empty($class) && !str_starts_with($functionName, '{closure') => new ReflectionMethod($class, $functionName),
32+
!empty($class) && !str_contains($functionName, '{closure') => new ReflectionMethod($class, $functionName),
3333
!empty($functionName) => $reflection,
3434
default => throw new \InvalidArgumentException('Unsupported callable type: ' . gettype($closure)),
3535
});

0 commit comments

Comments
 (0)