[2.0] Reverted wrong committed files
This commit is contained in:
parent
038e6cadfb
commit
b8208211ff
@ -201,7 +201,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotation ::= "@" AnnotationName ["(" [Values] ")"]
|
||||
* Annotation ::= "@" AnnotationName [ "(" [Values] ")" ]
|
||||
* AnnotationName ::= QualifiedName | SimpleName
|
||||
* QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName
|
||||
* NameSpacePart ::= identifier
|
||||
@ -262,7 +262,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* Values ::= Array | Value {"," Value}*
|
||||
* Values ::= Value {"," Value}*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -320,7 +320,7 @@ class Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* PlainValue ::= integer | string | float | boolean | Array | Annotation
|
||||
* PlainValue ::= integer | string | float | Array | Annotation
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -410,7 +410,7 @@ class Parser
|
||||
|
||||
/**
|
||||
* ArrayEntry ::= Value | KeyValuePair
|
||||
* KeyValuePair ::= Key "=" PlainValue
|
||||
* KeyValuePair ::= Key "=" Value
|
||||
* Key ::= string | integer
|
||||
*
|
||||
* @return array
|
||||
@ -429,7 +429,7 @@ class Parser
|
||||
$key = $this->_lexer->token['value'];
|
||||
$this->match('=');
|
||||
|
||||
return array($key => $this->PlainValue());
|
||||
return array($key => $this->Value());
|
||||
}
|
||||
|
||||
return array($this->Value());
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Tools\Cli\Printers;
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
use Doctrine\ORM\Tools\Cli\Style;
|
||||
|
||||
/**
|
||||
@ -38,11 +38,6 @@ use Doctrine\ORM\Tools\Cli\Style;
|
||||
*/
|
||||
abstract class AbstractPrinter
|
||||
{
|
||||
/**
|
||||
* Defines the tab length
|
||||
*/
|
||||
const TAB_LENGTH = 8;
|
||||
|
||||
/**
|
||||
* @var resource Output Stream
|
||||
*/
|
||||
@ -66,7 +61,7 @@ abstract class AbstractPrinter
|
||||
public function __construct($stream = STDOUT)
|
||||
{
|
||||
$this->_stream = $stream;
|
||||
$this->setMaxColumnSize(0);
|
||||
$this->_maxColumnSize = 80;
|
||||
|
||||
$this->_initStyles();
|
||||
}
|
||||
@ -79,14 +74,10 @@ abstract class AbstractPrinter
|
||||
{
|
||||
// Defines base styles
|
||||
$this->addStyles(array(
|
||||
'HEADER' => new Style(),
|
||||
'ERROR' => new Style(),
|
||||
'WARNING' => new Style(),
|
||||
'KEYWORD' => new Style(),
|
||||
'REQ_ARG' => new Style(),
|
||||
'OPT_ARG' => new Style(),
|
||||
'INFO' => new Style(),
|
||||
'COMMENT' => new Style(),
|
||||
'HEADER' => new Style(),
|
||||
'NONE' => new Style(),
|
||||
));
|
||||
}
|
||||
@ -143,13 +134,11 @@ abstract class AbstractPrinter
|
||||
/**
|
||||
* Sets the maximum column size (defines the CLI margin).
|
||||
*
|
||||
* @param integer $maxColumnSize The maximum column size for a message.
|
||||
* Must be higher than 25 and assigns default
|
||||
* value (if invalid) to 80 columns.
|
||||
* @param integer $maxColumnSize The maximum column size for a message
|
||||
*/
|
||||
public function setMaxColumnSize($maxColumnSize)
|
||||
{
|
||||
$this->_maxColumnSize = ($maxColumnSize > 25) ? $maxColumnSize : 80;
|
||||
$this->_maxColumnSize = $maxColumnSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,136 +165,6 @@ abstract class AbstractPrinter
|
||||
return $this->write($message . PHP_EOL, $style);
|
||||
}
|
||||
|
||||
public function writeTaskDocumentation($taskName, $arguments = array(), $description, $options = array())
|
||||
{
|
||||
// Writting task name
|
||||
$this->write('Task: ', 'HEADER')->writeln($taskName, 'KEYWORD');
|
||||
|
||||
// Synopsis
|
||||
$this->writeln('Synopsis:', 'HEADER');
|
||||
$this->writeSynopsis($taskName, $arguments);
|
||||
|
||||
// We need to split the description according to maximum column size
|
||||
$this->writeln('Description:', 'HEADER');
|
||||
$this->writeDescription($description);
|
||||
|
||||
// Find largest length option name (it is mandatory for tab spacing)
|
||||
$lengths = array_map(create_function('$v', 'return strlen($v["name"]);'), $options);
|
||||
sort($lengths, SORT_NUMERIC);
|
||||
|
||||
$highestLength = end($lengths);
|
||||
$maxTabs = ceil($highestLength / self::TAB_LENGTH);
|
||||
|
||||
// Options (required + optional arguments)
|
||||
$this->writeln('Options:', 'HEADER');
|
||||
|
||||
for ($i = 0, $len = count($options); $i < $len; $i++) {
|
||||
$this->writeOption($options[$i], $maxTabs, $highestLength);
|
||||
|
||||
if ($i != $len - 1) {
|
||||
$this->write(PHP_EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function writeSynopsis($taskName, $arguments = array())
|
||||
{
|
||||
// Required arguments
|
||||
$requiredArguments = '';
|
||||
|
||||
if (isset($arguments['required'])) {
|
||||
$requiredArguments = ' ' . ((is_array($arguments['required']))
|
||||
? implode(' ', $arguments['required']) : $arguments['required']);
|
||||
}
|
||||
|
||||
// Optional arguments
|
||||
$optionalArguments = '';
|
||||
|
||||
if (isset($arguments['optional'])) {
|
||||
$optionalArguments = ' ' . ((is_array($arguments['optional']))
|
||||
? implode(' ', $arguments['optional']) : $arguments['optional']);
|
||||
}
|
||||
|
||||
$this->write($taskName, 'KEYWORD');
|
||||
|
||||
if (($l = strlen($taskName . $requiredArguments)) > $this->_maxColumnSize) {
|
||||
$this->write(PHP_EOL);
|
||||
}
|
||||
|
||||
$this->write(' ' . $requiredArguments, 'REQ_ARG');
|
||||
|
||||
if (($l + strlen($optionalArguments)) > $this->_maxColumnSize) {
|
||||
$this->write(PHP_EOL);
|
||||
}
|
||||
|
||||
$this->write(' ' . $optionalArguments, 'OPT_ARG');
|
||||
|
||||
$this->write(PHP_EOL);
|
||||
}
|
||||
|
||||
protected function writeDescription($description)
|
||||
{
|
||||
$descriptionLength = strlen($description);
|
||||
$startPos = 0;
|
||||
$maxSize = $endPos = $this->_maxColumnSize;
|
||||
|
||||
// Description
|
||||
while ($startPos < $descriptionLength) {
|
||||
$descriptionPart = trim(substr($description, $startPos, $endPos + 1));
|
||||
$endPos = (($l = strlen($descriptionPart)) > $maxSize)
|
||||
? strrpos($descriptionPart, ' ') : $l;
|
||||
$endPos = ($endPos === false) ? strlen($description) : $endPos + 1;
|
||||
|
||||
// Write description line
|
||||
$this->writeln(trim(substr($description, $startPos, $endPos)));
|
||||
|
||||
$startPos += $endPos;
|
||||
$endPos = $maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
protected function writeOption($option, $maxTabs, $highestLength)
|
||||
{
|
||||
// Option name
|
||||
$this->write(
|
||||
$option['name'],
|
||||
(isset($option['required']) && $option['required']) ? 'REQ_ARG' : 'OPT_ARG'
|
||||
);
|
||||
|
||||
// Tab spacing
|
||||
$optionLength = strlen($option['name']);
|
||||
$tabs = floor($optionLength / self::TAB_LENGTH);
|
||||
$decrementer = 0;
|
||||
|
||||
//echo '[' .$tabs. ']';
|
||||
|
||||
if (($optionLength % self::TAB_LENGTH != 0)) {
|
||||
$decrementer = 1;
|
||||
//$tabs--;
|
||||
}
|
||||
|
||||
$this->write(str_repeat(" ", ($maxTabs - $tabs) * self::TAB_LENGTH));
|
||||
|
||||
// Description
|
||||
$descriptionLength = strlen($option['description']);
|
||||
|
||||
$startPos = 0;
|
||||
$maxSize = $endPos = $this->_maxColumnSize - ($maxTabs * self::TAB_LENGTH);
|
||||
|
||||
while ($startPos < $descriptionLength) {
|
||||
$descriptionPart = trim(substr($option['description'], $startPos, $endPos + 1));
|
||||
$endPos = (($l = strlen($descriptionPart)) >= $maxSize)
|
||||
? strrpos($descriptionPart, ' ') : $l;
|
||||
$endPos = ($endPos === false) ? strlen($option['description']) : $endPos + 1;
|
||||
$descriptionLine = (($startPos != 0) ? str_repeat(" ", $maxTabs * self::TAB_LENGTH) : '')
|
||||
. trim(substr($option['description'], $startPos, $endPos));
|
||||
$this->writeln($descriptionLine);
|
||||
|
||||
$startPos += $endPos;
|
||||
$endPos = $maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given message with the defined style.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user