Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 56e4e7c

Browse files
committed
seems new way is working!
1 parent 5a9719d commit 56e4e7c

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/CommandProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class CommandProvider implements CommandProviderCapability {
1717
*/
1818
public function getCommands() {
1919
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'generated' . DIRECTORY_SEPARATOR . 'data.php';
20-
$commands = [];
21-
if (file_exists($file)) {
22-
$commands = include($file);
20+
$commands = file_exists($file) ? include($file) : [];
21+
if (is_array($commands) === false) {
22+
$commands = [];
2323
}
24-
return $commands;
24+
return array_filter((array)$commands);
2525
}
2626
}

src/DefaultDumpWriter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public function __construct(string $filename)
5050
public function writeToFile(): bool
5151
{
5252
$ret = $this->source . PHP_EOL;
53-
$ret .= '$commands = array_filter([' . PHP_EOL;
53+
$ret .= 'return [' . PHP_EOL;
5454
foreach ($this->commands as $command) {
55-
$ret .= str_repeat(' ', 4) . 'class_exists("' . $command . '") ? ' . ' new ProxyCommand(' . $command . '::class) : null,' . PHP_EOL;
55+
$ret .= str_repeat(' ', 4) . 'class_exists(' . json_encode($command) . ') ? ' . ' new ProxyCommand(' . $command . '::class) : null,' . PHP_EOL;
5656
}
57-
$ret .= ']);' . PHP_EOL;
57+
$ret .= '];' . PHP_EOL;
5858

5959
return (bool)file_put_contents($this->filename, $ret, LOCK_EX);
6060
}

src/ProxyCommand.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ class ProxyCommand extends BaseCommand
2424
*/
2525
public function __construct($composerCommandClass)
2626
{
27-
parent::__construct(null);
28-
2927
$this->realCommand = new $composerCommandClass();
3028

31-
$this->setAliases(
32-
$this->realCommand->getAliases()
33-
);
34-
$this->setDescription(
35-
$this->realCommand->getDescription()
36-
);
37-
$this->setDefinition(
38-
$this->realCommand->getDefinition()
29+
$this
30+
->setAliases(
31+
$this->realCommand->getAliases()
32+
)
33+
->setDescription(
34+
$this->realCommand->getDescription()
35+
)
36+
->setDefinition(
37+
$this->realCommand->getDefinition()
38+
);
39+
40+
parent::__construct(
41+
$this->realCommand->getName()
3942
);
4043
}
4144

0 commit comments

Comments
 (0)