1 | <?php |
||
29 | abstract class AbstractCommandAdapter extends Command |
||
30 | { |
||
31 | /** |
||
32 | * @var \Webmozart\Console\Api\Command\Command |
||
33 | */ |
||
34 | private $adaptedCommand; |
||
35 | |||
36 | /** |
||
37 | * Creates the adapter. |
||
38 | * |
||
39 | * @param \Webmozart\Console\Api\Command\Command $adaptedCommand The adapted command. |
||
40 | * @param Application $application The application. |
||
41 | */ |
||
42 | 15 | public function __construct(\Webmozart\Console\Api\Command\Command $adaptedCommand, Application $application) |
|
43 | { |
||
44 | 15 | parent::setName($adaptedCommand->getName()); |
|
|
|||
45 | |||
46 | 15 | parent::__construct(); |
|
47 | |||
48 | 15 | $this->adaptedCommand = $adaptedCommand; |
|
49 | |||
50 | 15 | $config = $adaptedCommand->getConfig(); |
|
51 | |||
52 | 15 | parent::setDefinition(new ArgsFormatInputDefinition($this->adaptedCommand->getArgsFormat())); |
|
53 | 15 | parent::setApplication($application); |
|
54 | 15 | parent::setDescription($config->getDescription()); |
|
55 | 15 | parent::setHelp($config->getHelp()); |
|
56 | 15 | parent::setAliases($adaptedCommand->getAliases()); |
|
57 | |||
58 | 15 | if ($helperSet = $config->getHelperSet()) { |
|
59 | 15 | parent::setHelperSet($helperSet); |
|
60 | } |
||
61 | 15 | } |
|
62 | |||
63 | /** |
||
64 | * Returns the adapted command. |
||
65 | * |
||
66 | * @return Command The adapted command. |
||
67 | */ |
||
68 | 1 | public function getAdaptedCommand() |
|
69 | { |
||
70 | 1 | return $this->adaptedCommand; |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * Does nothing. |
||
75 | * |
||
76 | * @param Application $application The application. |
||
77 | * |
||
78 | * @return static The current instance. |
||
79 | */ |
||
80 | 13 | public function setApplication(Application $application = null) |
|
81 | { |
||
82 | 13 | return $this; |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * Does nothing. |
||
87 | * |
||
88 | * @param HelperSet $helperSet The helper set. |
||
89 | * |
||
90 | * @return static The current instance. |
||
91 | */ |
||
92 | 15 | public function setHelperSet(HelperSet $helperSet) |
|
93 | { |
||
94 | 15 | return $this; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * Does nothing. |
||
99 | * |
||
100 | * @param array|InputDefinition $definition The definition |
||
101 | * |
||
102 | * @return static The current instance. |
||
103 | */ |
||
104 | public function setDefinition($definition) |
||
108 | |||
109 | /** |
||
110 | * Does nothing. |
||
111 | * |
||
112 | * @param string $name The name. |
||
113 | * |
||
114 | * @return static The current instance. |
||
115 | */ |
||
116 | public function setName($name) |
||
120 | |||
121 | /** |
||
122 | * Does nothing. |
||
123 | * |
||
124 | * @param string $title The process title. |
||
125 | * |
||
126 | * @return static The current instance. |
||
127 | */ |
||
128 | public function setProcessTitle($title) |
||
132 | |||
133 | /** |
||
134 | * Does nothing. |
||
135 | * |
||
136 | * @param string $description The description. |
||
137 | * |
||
138 | * @return static The current instance. |
||
139 | */ |
||
140 | public function setDescription($description) |
||
144 | |||
145 | /** |
||
146 | * Does nothing. |
||
147 | * |
||
148 | * @param string $help The help. |
||
149 | * |
||
150 | * @return static The current instance. |
||
151 | */ |
||
152 | public function setHelp($help) |
||
156 | |||
157 | /** |
||
158 | * Does nothing. |
||
159 | * |
||
160 | * @param string[] $aliases The aliases. |
||
161 | * |
||
162 | * @return static The current instance. |
||
163 | */ |
||
164 | public function setAliases($aliases) |
||
168 | |||
169 | /** |
||
170 | * Does nothing. |
||
171 | * |
||
172 | * @param bool $mergeArgs |
||
173 | * |
||
174 | * @return static The current instance. |
||
175 | */ |
||
176 | 12 | public function mergeApplicationDefinition($mergeArgs = true) |
|
180 | |||
181 | /** |
||
182 | * Does nothing. |
||
183 | * |
||
184 | * @param string $name |
||
185 | * @param null $mode |
||
186 | * @param string $description |
||
187 | * @param null $default |
||
188 | * |
||
189 | * @return static The current instance. |
||
190 | */ |
||
191 | public function addArgument($name, $mode = null, $description = '', $default = null) |
||
195 | |||
196 | /** |
||
197 | * Does nothing. |
||
198 | * |
||
199 | * @param string $name |
||
200 | * @param null $shortcut |
||
201 | * @param null $mode |
||
202 | * @param string $description |
||
203 | * @param null $default |
||
204 | * |
||
205 | * @return static The current instance. |
||
206 | */ |
||
207 | public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) |
||
211 | |||
212 | /** |
||
213 | * {@inheritdoc} |
||
214 | */ |
||
215 | 15 | public function isEnabled() |
|
219 | |||
220 | /** |
||
221 | * Executes the command. |
||
222 | * |
||
223 | * @param InputInterface $input The console input. |
||
224 | * @param OutputInterface $output The console output. |
||
225 | * |
||
226 | * @return int The exit status. |
||
227 | */ |
||
228 | public function run(InputInterface $input, OutputInterface $output) |
||
237 | } |
||
238 | |||
272 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.