Commit b2167985 authored by guilhermeblanco's avatar guilhermeblanco

[2.0][DDC-274] Fixing Coding Standards for CLI tool.

parent 50c4e509
...@@ -18,14 +18,14 @@ if (file_exists($configFile)) { ...@@ -18,14 +18,14 @@ if (file_exists($configFile)) {
require $configFile; require $configFile;
foreach ($GLOBALS as $configCandidate) { foreach ($GLOBALS as $configCandidate) {
if ($configCandidate instanceof \Doctrine\Common\Cli\Configuration) { if ($configCandidate instanceof \Doctrine\Common\CLI\Configuration) {
$configuration = $configCandidate; $configuration = $configCandidate;
break; break;
} }
} }
} }
$configuration = ($configuration) ?: new \Doctrine\Common\Cli\Configuration(); $configuration = ($configuration) ?: new \Doctrine\Common\CLI\Configuration();
$cli = new \Doctrine\Common\Cli\CliController($configuration); $cli = new \Doctrine\Common\CLI\CLIController($configuration);
$cli->run($_SERVER['argv']); $cli->run($_SERVER['argv']);
\ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
use Doctrine\Common\Util\Inflector; use Doctrine\Common\Util\Inflector;
...@@ -73,7 +73,7 @@ abstract class AbstractNamespace ...@@ -73,7 +73,7 @@ abstract class AbstractNamespace
$name = self::formatName($name); $name = self::formatName($name);
if ($this->hasNamespace($name)) { if ($this->hasNamespace($name)) {
throw CliException::cannotOverrideNamespace($name); throw CLIException::cannotOverrideNamespace($name);
} }
return $this->overrideNamespace($name); return $this->overrideNamespace($name);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
/** /**
* Generic CLI Controller of Tasks execution * Generic CLI Controller of Tasks execution
...@@ -27,7 +27,7 @@ namespace Doctrine\Common\Cli; ...@@ -27,7 +27,7 @@ namespace Doctrine\Common\Cli;
* To include a new Task support, create a task: * To include a new Task support, create a task:
* *
* [php] * [php]
* class MyProject\Tools\Cli\Tasks\MyTask extends Doctrine\ORM\Tools\Cli\Tasks\AbstractTask * class MyProject\Tools\CLI\Tasks\MyTask extends Doctrine\ORM\Tools\CLI\Tasks\AbstractTask
* { * {
* public function run(); * public function run();
* public function basicHelp(); * public function basicHelp();
...@@ -38,9 +38,9 @@ namespace Doctrine\Common\Cli; ...@@ -38,9 +38,9 @@ namespace Doctrine\Common\Cli;
* And then, load the namespace assoaicated an include the support to it in your command-line script: * And then, load the namespace assoaicated an include the support to it in your command-line script:
* *
* [php] * [php]
* $cli = new Doctrine\Common\Cli\CliController(); * $cli = new Doctrine\Common\CLI\CLIController();
* $cliNS = $cli->getNamespace('custom'); * $cliNS = $cli->getNamespace('custom');
* $cliNS->addTask('myTask', 'MyProject\Tools\Cli\Tasks\MyTask'); * $cliNS->addTask('myTask', 'MyProject\Tools\CLI\Tasks\MyTask');
* *
* To execute, just type any classify-able name: * To execute, just type any classify-able name:
* *
...@@ -55,7 +55,7 @@ namespace Doctrine\Common\Cli; ...@@ -55,7 +55,7 @@ namespace Doctrine\Common\Cli;
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class CliController extends AbstractNamespace class CLIController extends AbstractNamespace
{ {
/** /**
* The CLI processor of tasks * The CLI processor of tasks
...@@ -69,12 +69,12 @@ class CliController extends AbstractNamespace ...@@ -69,12 +69,12 @@ class CliController extends AbstractNamespace
$this->setConfiguration($config); $this->setConfiguration($config);
// Include core namespaces of tasks // Include core namespaces of tasks
$ns = 'Doctrine\Common\Cli\Tasks'; $ns = 'Doctrine\Common\CLI\Tasks';
$this->addNamespace('Core') $this->addNamespace('Core')
->addTask('help', $ns . '\HelpTask') ->addTask('help', $ns . '\HelpTask')
->addTask('version', $ns . '\VersionTask'); ->addTask('version', $ns . '\VersionTask');
$ns = 'Doctrine\ORM\Tools\Cli\Tasks'; $ns = 'Doctrine\ORM\Tools\CLI\Tasks';
$this->addNamespace('Orm') $this->addNamespace('Orm')
->addTask('clear-cache', $ns . '\ClearCacheTask') ->addTask('clear-cache', $ns . '\ClearCacheTask')
->addTask('convert-mapping', $ns . '\ConvertMappingTask') ->addTask('convert-mapping', $ns . '\ConvertMappingTask')
...@@ -87,7 +87,7 @@ class CliController extends AbstractNamespace ...@@ -87,7 +87,7 @@ class CliController extends AbstractNamespace
->addTask('generate-entities', $ns . '\GenerateEntitiesTask') ->addTask('generate-entities', $ns . '\GenerateEntitiesTask')
->addTask('generate-repositories', $ns . '\GenerateRepositoriesTask'); ->addTask('generate-repositories', $ns . '\GenerateRepositoriesTask');
$ns = 'Doctrine\DBAL\Tools\Cli\Tasks'; $ns = 'Doctrine\DBAL\Tools\CLI\Tasks';
$this->addNamespace('Dbal') $this->addNamespace('Dbal')
->addTask('run-sql', $ns . '\RunSqlTask') ->addTask('run-sql', $ns . '\RunSqlTask')
->addTask('version', $ns . '\VersionTask'); ->addTask('version', $ns . '\VersionTask');
...@@ -98,12 +98,12 @@ class CliController extends AbstractNamespace ...@@ -98,12 +98,12 @@ class CliController extends AbstractNamespace
* Example of inclusion support to a single task: * Example of inclusion support to a single task:
* *
* [php] * [php]
* $cli->addTask('my-custom-task', 'MyProject\Cli\Tasks\MyCustomTask'); * $cli->addTask('my-custom-task', 'MyProject\CLI\Tasks\MyCustomTask');
* *
* @param string $name CLI Task name * @param string $name CLI Task name
* @param string $class CLI Task class (FQCN - Fully Qualified Class Name) * @param string $class CLI Task class (FQCN - Fully Qualified Class Name)
* *
* @return CliController This object instance * @return CLIController This object instance
*/ */
public function addTask($name, $class) public function addTask($name, $class)
{ {
...@@ -294,7 +294,7 @@ class CliController extends AbstractNamespace ...@@ -294,7 +294,7 @@ class CliController extends AbstractNamespace
// If the given namespace returned "null", throw exception // If the given namespace returned "null", throw exception
if ($taskNamespace === null) { if ($taskNamespace === null) {
throw CliException::namespaceDoesNotExist($namespaceName, $currentNamespacePath); throw CLIException::namespaceDoesNotExist($namespaceName, $currentNamespacePath);
} }
$currentNamespacePath = (( ! empty($currentNamespacePath)) ? ':' : '') $currentNamespacePath = (( ! empty($currentNamespacePath)) ? ':' : '')
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
/** /**
* CLI Exception class * CLI Exception class
...@@ -33,7 +33,7 @@ namespace Doctrine\Common\Cli; ...@@ -33,7 +33,7 @@ namespace Doctrine\Common\Cli;
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class CliException extends \Doctrine\Common\CommonException class CLIException extends \Exception
{ {
public static function namespaceDoesNotExist($namespaceName, $namespacePath = '') public static function namespaceDoesNotExist($namespaceName, $namespacePath = '')
{ {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
/** /**
* CLI Configuration class * CLI Configuration class
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
/** /**
* CLI Option definition * CLI Option definition
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
use Doctrine\Common\Cli\Printers\AbstractPrinter; use Doctrine\Common\CLI\Printers\AbstractPrinter;
/** /**
* CLI Option Group definition * CLI Option Group definition
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli\Printers; namespace Doctrine\Common\CLI\Printers;
use Doctrine\Common\Cli\Style; use Doctrine\Common\CLI\Style;
/** /**
* CLI Output Printer. * CLI Output Printer.
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli\Printers; namespace Doctrine\Common\CLI\Printers;
use Doctrine\Common\Cli\Style; use Doctrine\Common\CLI\Style;
/** /**
* CLI Output Printer for ANSI Color terminal * CLI Output Printer for ANSI Color terminal
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli\Printers; namespace Doctrine\Common\CLI\Printers;
use Doctrine\Common\Cli\Style; use Doctrine\Common\CLI\Style;
/** /**
* CLI Output Printer for Normal terminal * CLI Output Printer for Normal terminal
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
/** /**
* CLI Output Style * CLI Output Style
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
use Doctrine\Common\Cli\Printers\AbstractPrinter, use Doctrine\Common\CLI\Printers\AbstractPrinter,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\Common\Cli\Option; Doctrine\Common\CLI\Option;
/** /**
* CLI Task documentation * CLI Task documentation
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\CLI;
/** /**
* CLI Namespace class * CLI Namespace class
...@@ -81,7 +81,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -81,7 +81,7 @@ class TaskNamespace extends AbstractNamespace
return new $taskClass($this); return new $taskClass($this);
} }
throw CliException::taskDoesNotExist($name, $this->getFullName()); throw CLIException::taskDoesNotExist($name, $this->getFullName());
} }
/** /**
...@@ -129,7 +129,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -129,7 +129,7 @@ class TaskNamespace extends AbstractNamespace
$name = self::formatName($name); $name = self::formatName($name);
if ($this->hasTask($name)) { if ($this->hasTask($name)) {
throw CliException::cannotOverrideTask($name); throw CLIException::cannotOverrideTask($name);
} }
return $this->overrideTask($name, $class); return $this->overrideTask($name, $class);
...@@ -228,7 +228,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -228,7 +228,7 @@ class TaskNamespace extends AbstractNamespace
} else if ($task->validate()) { } else if ($task->validate()) {
$task->run(); $task->run();
} }
} catch (CliException $e) { } catch (CLIException $e) {
$message = $this->getFullName() . ':' . $name . ' => ' . $e->getMessage(); $message = $this->getFullName() . ':' . $name . ' => ' . $e->getMessage();
$printer = $this->getPrinter(); $printer = $this->getPrinter();
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli\Tasks; namespace Doctrine\Common\CLI\Tasks;
use Doctrine\Common\Cli\AbstractNamespace, use Doctrine\Common\CLI\AbstractNamespace,
Doctrine\Common\Cli\TaskDocumentation; Doctrine\Common\CLI\TaskDocumentation;
/** /**
* Base class for CLI Tasks. * Base class for CLI Tasks.
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli\Tasks; namespace Doctrine\Common\CLI\Tasks;
use Doctrine\Common\Cli\CliException; use Doctrine\Common\CLI\CLIException;
/** /**
* CLI Task to display available commands help * CLI Task to display available commands help
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli\Tasks; namespace Doctrine\Common\CLI\Tasks;
use Doctrine\Common\Version; use Doctrine\Common\Version;
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\DBAL\Tools\Cli\Tasks; namespace Doctrine\DBAL\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CLIException,
Doctrine\Common\Util\Debug, Doctrine\Common\Util\Debug,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup; Doctrine\Common\CLI\OptionGroup;
/** /**
* Task for executing arbitrary SQL that can come from a file or directly from * Task for executing arbitrary SQL that can come from a file or directly from
...@@ -78,13 +78,13 @@ class RunSqlTask extends AbstractTask ...@@ -78,13 +78,13 @@ class RunSqlTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ($em === null) { if ($em === null) {
throw new CliException( throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager." "Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
); );
} }
if ( ! (isset($arguments['sql']) ^ isset($arguments['file']))) { if ( ! (isset($arguments['sql']) ^ isset($arguments['file']))) {
throw new CliException('One of --sql or --file required, and only one.'); throw new CLIException('One of --sql or --file required, and only one.');
} }
return true; return true;
...@@ -107,9 +107,9 @@ class RunSqlTask extends AbstractTask ...@@ -107,9 +107,9 @@ class RunSqlTask extends AbstractTask
foreach ($fileNames as $fileName) { foreach ($fileNames as $fileName) {
if ( ! file_exists($fileName)) { if ( ! file_exists($fileName)) {
throw new CliException(sprintf('The SQL file [%s] does not exist.', $fileName)); throw new CLIException(sprintf('The SQL file [%s] does not exist.', $fileName));
} else if ( ! is_readable($fileName)) { } else if ( ! is_readable($fileName)) {
throw new CliException(sprintf('The SQL file [%s] does not have read permissions.', $fileName)); throw new CLIException(sprintf('The SQL file [%s] does not have read permissions.', $fileName));
} }
$printer->write('Processing file [' . $fileName . ']... '); $printer->write('Processing file [' . $fileName . ']... ');
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\DBAL\Tools\Cli\Tasks; namespace Doctrine\DBAL\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Version; Doctrine\Common\Version;
/** /**
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CliException,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\Common\Cache\AbstractDriver; Doctrine\Common\Cache\AbstractDriver;
/** /**
...@@ -79,7 +79,7 @@ class ClearCacheTask extends AbstractTask ...@@ -79,7 +79,7 @@ class ClearCacheTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ($em === null) { if ($em === null) {
throw new CliException( throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager." "Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
); );
} }
...@@ -90,7 +90,7 @@ class ClearCacheTask extends AbstractTask ...@@ -90,7 +90,7 @@ class ClearCacheTask extends AbstractTask
(isset($arguments['query']) || isset($arguments['metadata'])) && (isset($arguments['id']) || (isset($arguments['query']) || isset($arguments['metadata'])) && (isset($arguments['id']) ||
isset($arguments['regex']) || isset($arguments['prefix']) || isset($arguments['suffix'])) isset($arguments['regex']) || isset($arguments['prefix']) || isset($arguments['suffix']))
) { ) {
throw new CliException( throw new CLIException(
'When clearing the query or metadata cache do not ' . 'When clearing the query or metadata cache do not ' .
'specify any --id, --regex, --prefix or --suffix.' 'specify any --id, --regex, --prefix or --suffix.'
); );
...@@ -148,7 +148,7 @@ class ClearCacheTask extends AbstractTask ...@@ -148,7 +148,7 @@ class ClearCacheTask extends AbstractTask
$printer = $this->getPrinter(); $printer = $this->getPrinter();
if ( ! $cacheDriver) { if ( ! $cacheDriver) {
throw new CliException('No driver has been configured for the ' . $type . ' cache.'); throw new CLIException('No driver has been configured for the ' . $type . ' cache.');
} }
if ($id) { if ($id) {
...@@ -197,7 +197,7 @@ class ClearCacheTask extends AbstractTask ...@@ -197,7 +197,7 @@ class ClearCacheTask extends AbstractTask
$printer->writeln(' - ' . $id); $printer->writeln(' - ' . $id);
} }
} else { } else {
throw new CliException('No ' . $type . ' cache entries found.'); throw new CLIException('No ' . $type . ' cache entries found.');
} }
$printer->write(PHP_EOL); $printer->write(PHP_EOL);
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\ORM\Tools\Export\ClassMetadataExporter, Doctrine\ORM\Tools\Export\ClassMetadataExporter,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CliException,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\ORM\Tools\ConvertDoctrine1Schema, Doctrine\ORM\Tools\ConvertDoctrine1Schema,
Doctrine\ORM\Tools\EntityGenerator; Doctrine\ORM\Tools\EntityGenerator;
...@@ -70,7 +70,7 @@ class ConvertDoctrine1SchemaTask extends AbstractTask ...@@ -70,7 +70,7 @@ class ConvertDoctrine1SchemaTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ( ! isset($arguments['from']) || ! isset($arguments['to']) || ! isset($arguments['dest'])) { if ( ! isset($arguments['from']) || ! isset($arguments['to']) || ! isset($arguments['dest'])) {
throw new CliException('You must specify a value for --from, --to and --dest'); throw new CLIException('You must specify a value for --from, --to and --dest');
} }
return true; return true;
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CliException,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\ORM\Tools\Export\ClassMetadataExporter, Doctrine\ORM\Tools\Export\ClassMetadataExporter,
Doctrine\ORM\Mapping\Driver\DriverChain, Doctrine\ORM\Mapping\Driver\DriverChain,
Doctrine\ORM\Mapping\Driver\AnnotationDriver, Doctrine\ORM\Mapping\Driver\AnnotationDriver,
...@@ -78,13 +78,13 @@ class ConvertMappingTask extends AbstractTask ...@@ -78,13 +78,13 @@ class ConvertMappingTask extends AbstractTask
} }
if (!(isset($arguments['from']) && isset($arguments['to']) && isset($arguments['dest']))) { if (!(isset($arguments['from']) && isset($arguments['to']) && isset($arguments['dest']))) {
throw new CliException( throw new CLIException(
'You must include a value for all three options: --from, --to and --dest.' 'You must include a value for all three options: --from, --to and --dest.'
); );
} }
if (strtolower($arguments['to']) != 'annotation' && isset($arguments['extend'])) { if (strtolower($arguments['to']) != 'annotation' && isset($arguments['extend'])) {
throw new CliException( throw new CLIException(
'You can only use the --extend argument when converting to annotations.' 'You can only use the --extend argument when converting to annotations.'
); );
} }
...@@ -94,7 +94,7 @@ class ConvertMappingTask extends AbstractTask ...@@ -94,7 +94,7 @@ class ConvertMappingTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ($em === null) { if ($em === null) {
throw new CliException( throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager." "Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
); );
} }
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException; Doctrine\Common\CLI\CLIException;
/** /**
* CLI Task to ensure that Doctrine is properly configured for a production environment. * CLI Task to ensure that Doctrine is properly configured for a production environment.
...@@ -57,7 +57,7 @@ class EnsureProductionSettingsTask extends AbstractTask ...@@ -57,7 +57,7 @@ class EnsureProductionSettingsTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ($em === null) { if ($em === null) {
throw new CliException( throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager." "Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
); );
} }
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CLIException,
Doctrine\ORM\Tools\EntityGenerator, Doctrine\ORM\Tools\EntityGenerator,
Doctrine\ORM\Tools\ClassMetadataReader; Doctrine\ORM\Tools\ClassMetadataReader;
...@@ -67,7 +67,7 @@ class GenerateEntitiesTask extends AbstractTask ...@@ -67,7 +67,7 @@ class GenerateEntitiesTask extends AbstractTask
$arguments = $this->getArguments(); $arguments = $this->getArguments();
if ( ! isset($arguments['from']) || ! isset($arguments['dest'])) { if ( ! isset($arguments['from']) || ! isset($arguments['dest'])) {
throw new CliException('You must specify a value for --from and --dest'); throw new CLIException('You must specify a value for --from and --dest');
} }
return true; return true;
...@@ -110,7 +110,7 @@ class GenerateEntitiesTask extends AbstractTask ...@@ -110,7 +110,7 @@ class GenerateEntitiesTask extends AbstractTask
$entityGenerator->generate($metadatas, $dest); $entityGenerator->generate($metadatas, $dest);
$printer->writeln(''); $printer->write(PHP_EOL);
$printer->writeln( $printer->writeln(
sprintf('Entity classes generated to "%s"', sprintf('Entity classes generated to "%s"',
$printer->format($dest, 'KEYWORD') $printer->format($dest, 'KEYWORD')
......
<?php <?php
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CLIException,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup; Doctrine\Common\CLI\OptionGroup;
/** /**
* Task to (re)generate the proxy classes used by doctrine. * Task to (re)generate the proxy classes used by doctrine.
...@@ -50,7 +50,7 @@ class GenerateProxiesTask extends AbstractTask ...@@ -50,7 +50,7 @@ class GenerateProxiesTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ($em === null) { if ($em === null) {
throw new CliException( throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager." "Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
); );
} }
...@@ -61,7 +61,7 @@ class GenerateProxiesTask extends AbstractTask ...@@ -61,7 +61,7 @@ class GenerateProxiesTask extends AbstractTask
if (isset($arguments['class-dir'])) { if (isset($arguments['class-dir'])) {
$metadataDriver->addPaths((array) $arguments['class-dir']); $metadataDriver->addPaths((array) $arguments['class-dir']);
} else { } else {
throw new CliException( throw new CLIException(
'The supplied configuration uses the annotation metadata driver. ' . 'The supplied configuration uses the annotation metadata driver. ' .
"The 'class-dir' argument is required for this driver." "The 'class-dir' argument is required for this driver."
); );
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CLIException,
Doctrine\ORM\Tools\ClassMetadataReader; Doctrine\ORM\Tools\ClassMetadataReader;
/** /**
...@@ -84,7 +84,7 @@ class <className> extends EntityRepository ...@@ -84,7 +84,7 @@ class <className> extends EntityRepository
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ( ! isset($arguments['from']) || ! isset($arguments['dest'])) { if ( ! isset($arguments['from']) || ! isset($arguments['dest'])) {
throw new CliException('You must specify a value for --from and --dest'); throw new CLIException('You must specify a value for --from and --dest');
} }
return true; return true;
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CLIException,
Doctrine\Common\Util\Debug, Doctrine\Common\Util\Debug,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\ORM\Query; Doctrine\ORM\Query;
/** /**
...@@ -90,29 +90,29 @@ class RunDqlTask extends AbstractTask ...@@ -90,29 +90,29 @@ class RunDqlTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ($em === null) { if ($em === null) {
throw new CliException( throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager." "Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
); );
} }
if ( ! isset($arguments['dql'])) { if ( ! isset($arguments['dql'])) {
throw new CliException('Argument --dql must be defined.'); throw new CLIException('Argument --dql must be defined.');
} }
if (isset($arguments['hydrate'])) { if (isset($arguments['hydrate'])) {
$hydrationModeName = 'Doctrine\ORM\Query::HYDRATE_' . strtoupper(str_replace('-', '_', $arguments['hydrate'])); $hydrationModeName = 'Doctrine\ORM\Query::HYDRATE_' . strtoupper(str_replace('-', '_', $arguments['hydrate']));
if ( ! defined($hydrationModeName)) { if ( ! defined($hydrationModeName)) {
throw new CliException("Argument --hydrate must be either 'object', 'array', 'scalar' or 'single-scalar'."); throw new CLIException("Argument --hydrate must be either 'object', 'array', 'scalar' or 'single-scalar'.");
} }
} }
if (isset($arguments['first-result']) && ! ctype_digit($arguments['first-result'])) { if (isset($arguments['first-result']) && ! ctype_digit($arguments['first-result'])) {
throw new CliException('Argument --first-result must be an integer value.'); throw new CLIException('Argument --first-result must be an integer value.');
} }
if (isset($arguments['max-results']) && ! ctype_digit($arguments['max-results'])) { if (isset($arguments['max-results']) && ! ctype_digit($arguments['max-results'])) {
throw new CliException('Argument --max-results must be an integer value.'); throw new CLIException('Argument --max-results must be an integer value.');
} }
return true; return true;
......
<?php <?php
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException, Doctrine\Common\CLI\CLIException,
Doctrine\Common\Cli\Option, Doctrine\Common\CLI\Option,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\ORM\Tools\SchemaTool, Doctrine\ORM\Tools\SchemaTool,
Doctrine\Common\Annotations\AnnotationReader, Doctrine\Common\Annotations\AnnotationReader,
Doctrine\ORM\Mapping\Driver\AnnotationDriver, Doctrine\ORM\Mapping\Driver\AnnotationDriver,
...@@ -105,7 +105,7 @@ class SchemaToolTask extends AbstractTask ...@@ -105,7 +105,7 @@ class SchemaToolTask extends AbstractTask
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
if ($em === null) { if ($em === null) {
throw new CliException( throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager." "Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
); );
} }
...@@ -125,17 +125,17 @@ class SchemaToolTask extends AbstractTask ...@@ -125,17 +125,17 @@ class SchemaToolTask extends AbstractTask
$isCompleteUpdate = isset($arguments['complete-update']) && $arguments['complete-update']; $isCompleteUpdate = isset($arguments['complete-update']) && $arguments['complete-update'];
if ($isUpdate && ($isCreate || $isDrop || $isCompleteUpdate)) { if ($isUpdate && ($isCreate || $isDrop || $isCompleteUpdate)) {
throw new CliException( throw new CLIException(
'You cannot use --update with --create, --drop or --complete-update.' 'You cannot use --update with --create, --drop or --complete-update.'
); );
} }
if ($isCompleteUpdate && ($isCreate || $isDrop || $isUpdate)) { if ($isCompleteUpdate && ($isCreate || $isDrop || $isUpdate)) {
throw new CliException('You cannot use --complete-update with --create, --drop or --update.'); throw new CLIException('You cannot use --complete-update with --create, --drop or --update.');
} }
if ( ! ($isCreate || $isDrop || $isUpdate || $isCompleteUpdate)) { if ( ! ($isCreate || $isDrop || $isUpdate || $isCompleteUpdate)) {
throw new CliException( throw new CLIException(
'You must specify at a minimum one of the options: ' . 'You must specify at a minimum one of the options: ' .
'--create, --drop, --update, --re-create or --complete-update.' '--create, --drop, --update, --re-create or --complete-update.'
); );
...@@ -147,7 +147,7 @@ class SchemaToolTask extends AbstractTask ...@@ -147,7 +147,7 @@ class SchemaToolTask extends AbstractTask
if (isset($arguments['class-dir'])) { if (isset($arguments['class-dir'])) {
$metadataDriver->addPaths((array) $arguments['class-dir']); $metadataDriver->addPaths((array) $arguments['class-dir']);
} else { } else {
throw new CliException( throw new CLIException(
'The supplied configuration uses the annotation metadata driver. ' . 'The supplied configuration uses the annotation metadata driver. ' .
"The 'class-dir' argument is required for this driver." "The 'class-dir' argument is required for this driver."
); );
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\CLI\Tasks;
use Doctrine\Common\Cli\Tasks\AbstractTask, use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Version; Doctrine\Common\Version;
/** /**
......
...@@ -29,7 +29,7 @@ class AllTests ...@@ -29,7 +29,7 @@ class AllTests
$suite->addTest(Collections\AllTests::suite()); $suite->addTest(Collections\AllTests::suite());
$suite->addTest(Annotations\AllTests::suite()); $suite->addTest(Annotations\AllTests::suite());
$suite->addTest(Cache\AllTests::suite()); $suite->addTest(Cache\AllTests::suite());
$suite->addTest(Cli\AllTests::suite()); $suite->addTest(CLI\AllTests::suite());
return $suite; return $suite;
} }
......
<?php <?php
namespace Doctrine\Tests\Common\Cli; namespace Doctrine\Tests\Common\CLI;
if (!defined('PHPUnit_MAIN_METHOD')) { if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Common_Cli_AllTests::main'); define('PHPUnit_MAIN_METHOD', 'Common_Cli_AllTests::main');
...@@ -19,16 +19,16 @@ class AllTests ...@@ -19,16 +19,16 @@ class AllTests
{ {
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Common CLI Tests'); $suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Common CLI Tests');
$suite->addTestSuite('Doctrine\Tests\Common\Cli\ConfigurationTest'); $suite->addTestSuite('Doctrine\Tests\Common\CLI\ConfigurationTest');
$suite->addTestSuite('Doctrine\Tests\Common\Cli\OptionTest'); $suite->addTestSuite('Doctrine\Tests\Common\CLI\OptionTest');
$suite->addTestSuite('Doctrine\Tests\Common\Cli\OptionGroupTest'); $suite->addTestSuite('Doctrine\Tests\Common\CLI\OptionGroupTest');
$suite->addTestSuite('Doctrine\Tests\Common\Cli\StyleTest'); $suite->addTestSuite('Doctrine\Tests\Common\CLI\StyleTest');
//$suite->addTestSuite('Doctrine\Tests\Common\Cli\CliControllerTest'); //$suite->addTestSuite('Doctrine\Tests\Common\CLI\CLIControllerTest');
return $suite; return $suite;
} }
} }
if (PHPUnit_MAIN_METHOD == 'Common_Cli_AllTests::main') { if (PHPUnit_MAIN_METHOD == 'Common_CLI_AllTests::main') {
AllTests::main(); AllTests::main();
} }
\ No newline at end of file
<?php <?php
namespace Doctrine\Tests\Common\Cli; namespace Doctrine\Tests\Common\CLI;
use Doctrine\Tests\Mocks\TaskMock; use Doctrine\Tests\Mocks\TaskMock;
use Doctrine\Common\Cli\Configuration; use Doctrine\Common\CLI\Configuration;
use Doctrine\Common\Cli\CliController; use Doctrine\Common\CLI\CliController;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
/** /**
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
*/ */
class CliControllerTest extends \Doctrine\Tests\DoctrineTestCase class CLIControllerTest extends \Doctrine\Tests\DoctrineTestCase
{ {
private $cli; private $cli;
/** /**
* Sets up a CliController instance with a task referencing the TaskMock * Sets up a CLIController instance with a task referencing the TaskMock
* class. Instances of that class created by the CliController can be * class. Instances of that class created by the CLIController can be
* inspected for correctness. * inspected for correctness.
*/ */
function setUp() function setUp()
{ {
$config = $this->getMock('\Doctrine\Common\Cli\Configuration'); $config = $this->getMock('\Doctrine\Common\CLI\Configuration');
$printer = $this->getMockForAbstractClass('\Doctrine\Common\Cli\Printers\AbstractPrinter'); $printer = $this->getMockForAbstractClass('\Doctrine\Common\CLI\Printers\AbstractPrinter');
$this->cli = new CliController($config, $printer); $this->cli = new CLIController($config, $printer);
TaskMock::$instances = array(); TaskMock::$instances = array();
...@@ -36,7 +36,7 @@ class CliControllerTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -36,7 +36,7 @@ class CliControllerTest extends \Doctrine\Tests\DoctrineTestCase
* Data provider with a bunch of task-mock calls with different arguments * Data provider with a bunch of task-mock calls with different arguments
* and their expected parsed format. * and their expected parsed format.
*/ */
static public function dataCliControllerArguments() static public function dataCLIControllerArguments()
{ {
return array( return array(
array( array(
...@@ -69,9 +69,9 @@ class CliControllerTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -69,9 +69,9 @@ class CliControllerTest extends \Doctrine\Tests\DoctrineTestCase
/** /**
* Checks whether the arguments coming from the data provider are correctly * Checks whether the arguments coming from the data provider are correctly
* parsed by the CliController and passed to the task to be run. * parsed by the CLIController and passed to the task to be run.
* *
* @dataProvider dataCliControllerArguments * @dataProvider dataCLIControllerArguments
* @param array $rawArgs * @param array $rawArgs
* @param array $parsedArgs * @param array $parsedArgs
* @param string $message * @param string $message
......
<?php <?php
namespace Doctrine\Tests\Common\Cli; namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\Cli\Configuration; use Doctrine\Common\CLI\Configuration;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
......
<?php <?php
namespace Doctrine\Tests\Common\Cli; namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\Cli\Printers\NormalPrinter, use Doctrine\Common\CLI\Printers\NormalPrinter,
Doctrine\Common\Cli\OptionGroup, Doctrine\Common\CLI\OptionGroup,
Doctrine\Common\Cli\Option; Doctrine\Common\CLI\Option;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
......
<?php <?php
namespace Doctrine\Tests\Common\Cli; namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\Cli\Option; use Doctrine\Common\CLI\Option;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
......
<?php <?php
namespace Doctrine\Tests\Common\Cli; namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\Cli\Style; use Doctrine\Common\CLI\Style;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
......
...@@ -37,5 +37,5 @@ $connectionOptions = array( ...@@ -37,5 +37,5 @@ $connectionOptions = array(
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
$configuration = new \Doctrine\Common\Cli\Configuration(); $configuration = new \Doctrine\Common\CLI\Configuration();
$configuration->setAttribute('em', $em); $configuration->setAttribute('em', $em);
\ No newline at end of file
...@@ -8,5 +8,5 @@ $classLoader->register(); ...@@ -8,5 +8,5 @@ $classLoader->register();
// Variable $configuration is defined inside cli-config.php // Variable $configuration is defined inside cli-config.php
require __DIR__ . '/cli-config.php'; require __DIR__ . '/cli-config.php';
$cli = new \Doctrine\Common\Cli\CliController($configuration); $cli = new \Doctrine\Common\CLI\CLIController($configuration);
$cli->run($_SERVER['argv']); $cli->run($_SERVER['argv']);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment