Skip to content

Commit f804aae

Browse files
committed
added type checking to console app
1 parent 35689c5 commit f804aae

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/CommandFactoryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Differ;
44

5-
use Differ\CommandLineParserInterface as CLP;
5+
use Differ\CommandLineParserInterface as CLPI;
66
use Differ\FilesDiffCommandInterface as FDCI;
77
use Differ\CommandInterface as CI;
88
use Differ\FormattersInterface as FI;
99
use Differ\DisplayCommandInterface as DCI;
1010

1111
interface CommandFactoryInterface
1212
{
13-
public function createCommand(string $commandType): CLP | FDCI | CI | FI | DCI;
13+
public function createCommand(string $commandType): CLPI|FDCI|CI|FI|DCI;
1414
}

src/CommandInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
use Differ\FilesDiffCommandInterface as FDCI;
77
use Differ\CommandInterface as CI;
88
use Differ\FormattersInterface as FI;
9+
use Differ\DisplayCommandInterface as DCI;
910

1011
interface CommandInterface
1112
{
12-
public function execute(CLP|FDCI|CI|FI $command): CI|FI;
13+
public function execute(CLP|FDCI|CI|FI|DCI $command): CI|FI;
1314
}

src/ConsoleApp.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,34 @@
33
namespace Differ;
44

55
use Differ\CommandLineParser;
6+
use Differ\CommandInterface as CI;
7+
use Differ\CommandLineParserInterface as CLPI;
8+
use Differ\FilesDiffCommandInterface as FDCI;
9+
use Differ\FormattersInterface as FI;
10+
use Differ\DisplayCommandInterface as DCI;
611

712
class ConsoleApp
813
{
9-
private CommandInterface|FilesDiffCommandInterface|FormattersInterface|DisplayCommandInterface $nextCommand;
14+
private CLPI $parseCommand;
15+
private CI|CLPI|FDCI|FI|DCI $nextCommand;
1016
private CommandFactoryInterface $commandFactory;
17+
18+
/**
19+
* @var array<string> $flowSteps
20+
*/
1121
private array $flowSteps;
12-
private CommandInterface|CommandLineParserInterface|FilesDiffCommandInterface|FormattersInterface|DisplayCommandInterface $initCommand;
22+
private CI|CLPI|FDCI|FI|DCI $initCommand;
1323

1424
public function __construct(
1525
CommandFactoryInterface $commandFactory
1626
) {
1727
$this->commandFactory = $commandFactory;
1828

19-
$parseCommand = $this->commandFactory->createCommand("parse");
20-
$this->initCommand = $parseCommand->execute($parseCommand);
29+
$this->parseCommand = $this->commandFactory->createCommand("parse");
30+
$this->initCommand = $this->parseCommand->execute($this->parseCommand);
2131
$this->flowSteps = [
2232
"difference",
23-
strtolower($parseCommand->getFormat()),
33+
strtolower($this->parseCommand->getFormat()),
2434
"show"
2535
];
2636
}

0 commit comments

Comments
 (0)