1 | <?php |
||
30 | class Application extends BaseApplication implements EmbeddedComposerAwareInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var string $BUILD_NAME |
||
34 | */ |
||
35 | public static $BUILD_NAME; |
||
36 | |||
37 | /** |
||
38 | * @var string $logo |
||
39 | */ |
||
40 | public static $logo = <<<EOF |
||
41 | ______ __ _______ ______ |
||
42 | | _ \ | | | \ | _ \ |
||
43 | | |_) | | | | .--. || |_) | |
||
44 | | _ < | | | | | || / |
||
45 | | |_) | | `----.| `--` || |\ \ |
||
46 | |______/ |_______||_______/ | _| `._| |
||
47 | EOF; |
||
48 | |||
49 | /** |
||
50 | * @var ContainerInterface $container |
||
51 | */ |
||
52 | private $container; |
||
53 | |||
54 | /** |
||
55 | * @var EmbeddedComposerInterface $embeddedComposer |
||
56 | */ |
||
57 | private $embeddedComposer; |
||
58 | |||
59 | /** |
||
60 | * Are we building via shortcut |
||
61 | * |
||
62 | * @var bool $shortcut |
||
63 | */ |
||
64 | private $shortcut = false; |
||
65 | |||
66 | /** |
||
67 | * @param EmbeddedComposerInterface $embeddedComposer |
||
68 | * |
||
69 | * @return Application |
||
70 | */ |
||
71 | public static function create(EmbeddedComposerInterface $embeddedComposer) |
||
75 | |||
76 | /** |
||
77 | * @param EmbeddedComposerInterface $embeddedComposer |
||
78 | */ |
||
79 | public function __construct(EmbeddedComposerInterface $embeddedComposer) |
||
88 | |||
89 | /** |
||
90 | * Sets Environment Variables |
||
91 | */ |
||
92 | private function setEnvironmentVariables() |
||
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | private function getBldrVersion() |
||
110 | |||
111 | /** |
||
112 | * @return Command[] |
||
113 | */ |
||
114 | public function getCommands() |
||
122 | |||
123 | public function setBuildName() |
||
143 | |||
144 | /** |
||
145 | * {@inheritDoc} |
||
146 | * |
||
147 | * @codeCoverageIgnore |
||
148 | */ |
||
149 | public function getHelp() |
||
153 | |||
154 | /** |
||
155 | * {@inheritDoc} |
||
156 | */ |
||
157 | public function doRun(InputInterface $input, OutputInterface $output) |
||
178 | |||
179 | /** |
||
180 | * Builds the container with extensions |
||
181 | * |
||
182 | * @param InputInterface $input |
||
183 | * @param OutputInterface $output |
||
184 | * |
||
185 | * @throws InvalidArgumentException |
||
186 | */ |
||
187 | private function buildContainer(InputInterface $input, OutputInterface $output) |
||
198 | |||
199 | /** |
||
200 | * Falls back to "run" for a shortcut |
||
201 | * |
||
202 | * @param string $name |
||
203 | * |
||
204 | * @return Command |
||
205 | */ |
||
206 | public function find($name) |
||
216 | |||
217 | /** |
||
218 | * Resets arguments if shortcutting |
||
219 | * |
||
220 | * @return \Symfony\Component\Console\Input\InputDefinition |
||
221 | */ |
||
222 | public function getDefinition() |
||
231 | |||
232 | /** |
||
233 | * @return EmbeddedComposerInterface |
||
234 | */ |
||
235 | public function getEmbeddedComposer() |
||
239 | |||
240 | /** |
||
241 | * @return \Symfony\Component\Console\Input\InputDefinition |
||
242 | */ |
||
243 | protected function getDefaultInputDefinition() |
||
261 | |||
262 | /** |
||
263 | * Adds a container to Container Aware Commands |
||
264 | * |
||
265 | * {@inheritDoc} |
||
266 | */ |
||
267 | protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) |
||
275 | } |
||
276 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: