1 | <?php declare(strict_types = 1); |
||
20 | final class ConsoleApplication |
||
21 | { |
||
22 | /** |
||
23 | * @var SymfonyConsoleApplication |
||
24 | */ |
||
25 | private $console; |
||
26 | |||
27 | /** |
||
28 | * @var Container |
||
29 | */ |
||
30 | private $container; |
||
31 | |||
32 | /** |
||
33 | * ConsoleApplication constructor. |
||
34 | 3 | * |
|
35 | * @param Kernel $kernel |
||
36 | 3 | */ |
|
37 | public function __construct(Kernel $kernel) |
||
42 | |||
43 | /** |
||
44 | * Runs Console Application. |
||
45 | * |
||
46 | * @param InputInterface $input |
||
47 | * @param OutputInterface $output |
||
48 | 1 | * @return int |
|
49 | */ |
||
50 | 1 | public function run(InputInterface $input, OutputInterface $output): int |
|
69 | |||
70 | /** |
||
71 | * Initiates Symfony Console Application. |
||
72 | * |
||
73 | * @param string $name |
||
74 | 1 | * @param string $version |
|
75 | 1 | */ |
|
76 | private function initConsole(string $name, string $version) |
||
90 | |||
91 | /** |
||
92 | * Resolves command object from class name. |
||
93 | * |
||
94 | * @param string $commandClass |
||
95 | * @return mixed |
||
96 | */ |
||
97 | 1 | private function resolveCommand(string $commandClass) |
|
101 | |||
102 | } |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: