1 | <?php |
||
21 | class Application extends ConsoleApplication |
||
22 | { |
||
23 | /** |
||
24 | * @var Environment |
||
25 | */ |
||
26 | protected $environment; |
||
27 | |||
28 | /** |
||
29 | * @var RunnerInterface |
||
30 | */ |
||
31 | protected $runner; |
||
32 | |||
33 | /** |
||
34 | * @var Configuration |
||
35 | */ |
||
36 | protected $configuration; |
||
37 | |||
38 | /** |
||
39 | * @param Environment $environment |
||
40 | */ |
||
41 | public function __construct(Environment $environment) |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | * |
||
52 | * @param InputInterface $input |
||
53 | * @param OutputInterface $output |
||
54 | * @return int |
||
55 | */ |
||
56 | public function run(InputInterface $input = null, OutputInterface $output = null) |
||
66 | |||
67 | /** |
||
68 | * Run the Peridot application |
||
69 | * |
||
70 | * @param InputInterface $input |
||
71 | * @param OutputInterface $output |
||
72 | * @return int |
||
73 | */ |
||
74 | public function doRun(InputInterface $input, OutputInterface $output) |
||
88 | |||
89 | /** |
||
90 | * Fetch the ArgvInput used by Peridot. If any exceptions are thrown due to |
||
91 | * a mismatch between the option or argument requested and the input definition, the |
||
92 | * exception will be rendered and Peridot will exit with an error code. |
||
93 | * |
||
94 | * @param array $argv An array of parameters from the CLI in the argv format. |
||
95 | * @return ArgvInput |
||
96 | */ |
||
97 | public function getInput(array $argv = null) |
||
106 | |||
107 | /** |
||
108 | * Return's peridot as the sole command used by Peridot |
||
109 | * |
||
110 | * @param InputInterface $input |
||
111 | * @return string |
||
112 | */ |
||
113 | public function getCommandName(InputInterface $input) |
||
117 | |||
118 | /** |
||
119 | * Load the configured DSL. |
||
120 | * |
||
121 | * @param $dsl |
||
122 | */ |
||
123 | public function loadDsl($dslPath) |
||
129 | |||
130 | /** |
||
131 | * Set the runner used by the Peridot application. |
||
132 | * |
||
133 | * @param RunnerInterface $runner |
||
134 | * @return $this |
||
135 | */ |
||
136 | public function setRunner(RunnerInterface $runner) |
||
141 | |||
142 | /** |
||
143 | * Get the RunnerInterface being used by the Peridot application. |
||
144 | * If one is not set, a default Runner will be used. |
||
145 | * |
||
146 | * @return RunnerInterface |
||
147 | */ |
||
148 | public function getRunner() |
||
159 | |||
160 | /** |
||
161 | * Return the Environment used by the Peridot application. |
||
162 | * |
||
163 | * @return Environment |
||
164 | */ |
||
165 | public function getEnvironment() |
||
169 | |||
170 | /** |
||
171 | * Return the configuration used by the Peridot application. |
||
172 | * |
||
173 | * @return Configuration |
||
174 | */ |
||
175 | public function getConfiguration() |
||
179 | |||
180 | /** |
||
181 | * Set the configuration object used by the Peridot application. |
||
182 | * |
||
183 | * @param Configuration $configuration |
||
184 | * @return $this |
||
185 | */ |
||
186 | public function setConfiguration(Configuration $configuration) |
||
191 | |||
192 | /** |
||
193 | * Return an empty application input definition. |
||
194 | * |
||
195 | * @return InputDefinition |
||
196 | */ |
||
197 | public function getDefinition() |
||
201 | |||
202 | /** |
||
203 | * Validate that a supplied configuration exists. |
||
204 | * |
||
205 | * @return void |
||
206 | */ |
||
207 | protected function validateConfiguration() |
||
214 | |||
215 | private function createCommand(Configuration $configuration, OutputInterface $output) |
||
228 | } |
||
229 |
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: