Skip to content

Commit f7752f7

Browse files
committed
renamed Task to Command (as in Command Line Interface)
1 parent 3dc0d16 commit f7752f7

30 files changed

+646
-646
lines changed

src/Symfony/Components/CLI/Application.php

Lines changed: 126 additions & 126 deletions
Large diffs are not rendered by default.

src/Symfony/Components/CLI/Task/Task.php renamed to src/Symfony/Components/CLI/Command/Command.php

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Symfony\Components\CLI\Task;
3+
namespace Symfony\Components\CLI\Command;
44

55
use Symfony\Components\CLI\Input\Definition;
66
use Symfony\Components\CLI\Input\Option;
@@ -20,13 +20,13 @@
2020
*/
2121

2222
/**
23-
* Base class for all tasks.
23+
* Base class for all commands.
2424
*
2525
* @package symfony
2626
* @subpackage cli
2727
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
2828
*/
29-
class Task
29+
class Command
3030
{
3131
protected $name;
3232
protected $namespace;
@@ -60,12 +60,12 @@ public function __construct($name = null)
6060

6161
if (!$this->name)
6262
{
63-
throw new \LogicException('The task name cannot be empty.');
63+
throw new \LogicException('The command name cannot be empty.');
6464
}
6565
}
6666

6767
/**
68-
* Sets the application instance for this task.
68+
* Sets the application instance for this command.
6969
*
7070
* @param Application $application An Application instance
7171
*/
@@ -75,14 +75,14 @@ public function setApplication(Application $application = null)
7575
}
7676

7777
/**
78-
* Configures the current task.
78+
* Configures the current command.
7979
*/
8080
protected function configure()
8181
{
8282
}
8383

8484
/**
85-
* Executes the current task.
85+
* Executes the current command.
8686
*
8787
* @param InputInterface $input An InputInterface instance
8888
* @param OutputInterface $output An OutputInterface instance
@@ -91,7 +91,7 @@ protected function configure()
9191
*/
9292
protected function execute(InputInterface $input, OutputInterface $output)
9393
{
94-
throw new \LogicException('You must override the execute() method in the concrete task class.');
94+
throw new \LogicException('You must override the execute() method in the concrete command class.');
9595
}
9696

9797
/**
@@ -109,7 +109,7 @@ public function run(InputInterface $input, OutputInterface $output)
109109
// add the application arguments and options
110110
$this->mergeApplicationDefinition();
111111

112-
// bind the input against the task specific arguments/options
112+
// bind the input against the command specific arguments/options
113113
try
114114
{
115115
$input->bind($this->definition);
@@ -140,11 +140,11 @@ public function run(InputInterface $input, OutputInterface $output)
140140
}
141141

142142
/**
143-
* Sets the code to execute when running this task.
143+
* Sets the code to execute when running this command.
144144
*
145145
* @param \Closure $code A \Closure
146146
*
147-
* @return Task The current instance
147+
* @return Command The current instance
148148
*/
149149
public function setCode(\Closure $code)
150150
{
@@ -154,7 +154,7 @@ public function setCode(\Closure $code)
154154
}
155155

156156
/**
157-
* Merges the application definition with the task definition.
157+
* Merges the application definition with the command definition.
158158
*/
159159
protected function mergeApplicationDefinition()
160160
{
@@ -178,7 +178,7 @@ protected function mergeApplicationDefinition()
178178
*
179179
* @param array|Definition $definition An array of argument and option instances or a definition instance
180180
*
181-
* @return Task The current instance
181+
* @return Command The current instance
182182
*/
183183
public function setDefinition($definition)
184184
{
@@ -204,7 +204,7 @@ public function setDefinition($definition)
204204
* @param string $description A description text
205205
* @param mixed $default The default value (for Argument::OPTIONAL mode only)
206206
*
207-
* @return Task The current instance
207+
* @return Command The current instance
208208
*/
209209
public function addArgument($name, $mode = null, $description = '', $default = null)
210210
{
@@ -222,7 +222,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n
222222
* @param string $description A description text
223223
* @param mixed $default The default value (must be null for self::PARAMETER_REQUIRED or self::PARAMETER_NONE)
224224
*
225-
* @return Task The current instance
225+
* @return Command The current instance
226226
*/
227227
public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
228228
{
@@ -232,16 +232,16 @@ public function addOption($name, $shortcut = null, $mode = null, $description =
232232
}
233233

234234
/**
235-
* Sets the name of the task.
235+
* Sets the name of the command.
236236
*
237237
* This method can set both the namespace and the name if
238238
* you separate them by a colon (:)
239239
*
240-
* $task->setName('foo:bar');
240+
* $command->setName('foo:bar');
241241
*
242-
* @param string $name The task name
242+
* @param string $name The command name
243243
*
244-
* @return Task The current instance
244+
* @return Command The current instance
245245
*/
246246
public function setName($name)
247247
{
@@ -257,7 +257,7 @@ public function setName($name)
257257

258258
if (!$name)
259259
{
260-
throw new \InvalidArgumentException('A task name cannot be empty');
260+
throw new \InvalidArgumentException('A command name cannot be empty');
261261
}
262262

263263
$this->namespace = $namespace;
@@ -267,41 +267,41 @@ public function setName($name)
267267
}
268268

269269
/**
270-
* Returns the task namespace.
270+
* Returns the command namespace.
271271
*
272-
* @return string The task namespace
272+
* @return string The command namespace
273273
*/
274274
public function getNamespace()
275275
{
276276
return $this->namespace;
277277
}
278278

279279
/**
280-
* Returns the task name
280+
* Returns the command name
281281
*
282-
* @return string The task name
282+
* @return string The command name
283283
*/
284284
public function getName()
285285
{
286286
return $this->name;
287287
}
288288

289289
/**
290-
* Returns the fully qualified task name.
290+
* Returns the fully qualified command name.
291291
*
292-
* @return string The fully qualified task name
292+
* @return string The fully qualified command name
293293
*/
294294
public function getFullName()
295295
{
296296
return $this->getNamespace() ? $this->getNamespace().':'.$this->getName() : $this->getName();
297297
}
298298

299299
/**
300-
* Sets the description for the task.
300+
* Sets the description for the command.
301301
*
302-
* @param string $description The description for the task
302+
* @param string $description The description for the command
303303
*
304-
* @return Task The current instance
304+
* @return Command The current instance
305305
*/
306306
public function setDescription($description)
307307
{
@@ -311,21 +311,21 @@ public function setDescription($description)
311311
}
312312

313313
/**
314-
* Returns the description for the task.
314+
* Returns the description for the command.
315315
*
316-
* @return string The description for the task
316+
* @return string The description for the command
317317
*/
318318
public function getDescription()
319319
{
320320
return $this->description;
321321
}
322322

323323
/**
324-
* Sets the help for the task.
324+
* Sets the help for the command.
325325
*
326-
* @param string $help The help for the task
326+
* @param string $help The help for the command
327327
*
328-
* @return Task The current instance
328+
* @return Command The current instance
329329
*/
330330
public function setHelp($help)
331331
{
@@ -335,21 +335,21 @@ public function setHelp($help)
335335
}
336336

337337
/**
338-
* Returns the help for the task.
338+
* Returns the help for the command.
339339
*
340-
* @return string The help for the task
340+
* @return string The help for the command
341341
*/
342342
public function getHelp()
343343
{
344344
return $this->help;
345345
}
346346

347347
/**
348-
* Sets the aliases for the task.
348+
* Sets the aliases for the command.
349349
*
350-
* @param array $aliases An array of aliases for the task
350+
* @param array $aliases An array of aliases for the command
351351
*
352-
* @return Task The current instance
352+
* @return Command The current instance
353353
*/
354354
public function setAliases($aliases)
355355
{
@@ -359,17 +359,17 @@ public function setAliases($aliases)
359359
}
360360

361361
/**
362-
* Returns the aliases for the task.
362+
* Returns the aliases for the command.
363363
*
364-
* @return array An array of aliases for the task
364+
* @return array An array of aliases for the command
365365
*/
366366
public function getAliases()
367367
{
368368
return $this->aliases;
369369
}
370370

371371
/**
372-
* Returns the synopsis for the task.
372+
* Returns the synopsis for the command.
373373
*
374374
* @return string The synopsis
375375
*/
@@ -466,9 +466,9 @@ static public function askAndValidate(OutputInterface $output, $question, \Closu
466466
}
467467

468468
/**
469-
* Returns a text representation of the task.
469+
* Returns a text representation of the command.
470470
*
471-
* @return string A string representing the task
471+
* @return string A string representing the command
472472
*/
473473
public function asText()
474474
{
@@ -495,41 +495,41 @@ public function asText()
495495
}
496496

497497
/**
498-
* Returns an XML representation of the task.
498+
* Returns an XML representation of the command.
499499
*
500500
* @param Boolean $asDom Whether to return a DOM or an XML string
501501
*
502-
* @return string|DOMDocument An XML string representing the task
502+
* @return string|DOMDocument An XML string representing the command
503503
*/
504504
public function asXml($asDom = false)
505505
{
506506
$dom = new \DOMDocument('1.0', 'UTF-8');
507507
$dom->formatOutput = true;
508-
$dom->appendChild($taskXML = $dom->createElement('task'));
509-
$taskXML->setAttribute('id', $this->getFullName());
510-
$taskXML->setAttribute('namespace', $this->getNamespace() ? $this->getNamespace() : '_global');
511-
$taskXML->setAttribute('name', $this->getName());
508+
$dom->appendChild($commandXML = $dom->createElement('command'));
509+
$commandXML->setAttribute('id', $this->getFullName());
510+
$commandXML->setAttribute('namespace', $this->getNamespace() ? $this->getNamespace() : '_global');
511+
$commandXML->setAttribute('name', $this->getName());
512512

513-
$taskXML->appendChild($usageXML = $dom->createElement('usage'));
513+
$commandXML->appendChild($usageXML = $dom->createElement('usage'));
514514
$usageXML->appendChild($dom->createTextNode(sprintf($this->getSynopsis(), '')));
515515

516-
$taskXML->appendChild($descriptionXML = $dom->createElement('description'));
516+
$commandXML->appendChild($descriptionXML = $dom->createElement('description'));
517517
$descriptionXML->appendChild($dom->createTextNode(implode("\n ", explode("\n", $this->getDescription()))));
518518

519-
$taskXML->appendChild($helpXML = $dom->createElement('help'));
519+
$commandXML->appendChild($helpXML = $dom->createElement('help'));
520520
$help = $this->help;
521521
$helpXML->appendChild($dom->createTextNode(implode("\n ", explode("\n", $help))));
522522

523-
$taskXML->appendChild($aliasesXML = $dom->createElement('aliases'));
523+
$commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));
524524
foreach ($this->getAliases() as $alias)
525525
{
526526
$aliasesXML->appendChild($aliasXML = $dom->createElement('alias'));
527527
$aliasXML->appendChild($dom->createTextNode($alias));
528528
}
529529

530530
$definition = $this->definition->asXml(true);
531-
$taskXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true));
532-
$taskXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));
531+
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true));
532+
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));
533533

534534
return $asDom ? $dom : $dom->saveXml();
535535
}

0 commit comments

Comments
 (0)