Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into hotfix/translator-caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function writeLine($text = "", $color = null, $bgColor = null)
} elseif ($width == $consoleWidth) {
$this->write($text, $color, $bgColor);
} else {
$this->write($text. "\n", $color, $bgColor);
$this->write($text . "\n", $color, $bgColor);
}
}

Expand Down Expand Up @@ -136,6 +136,7 @@ public function writeAt($text, $x, $y, $color = null, $bgColor = null)
* @param int $bgColor (optional) Background color
* @param null|int $fillColor (optional) Foreground color of box fill
* @param null|int $fillBgColor (optional) Background color of box fill
* @throws Exception\BadMethodCallException if coordinates are invalid
*/
public function writeBox(
$x1,
Expand Down Expand Up @@ -608,7 +609,7 @@ public function readChar($mask = null)
$f = fopen('php://stdin','r');
do {
$char = fread($f,1);
} while ($mask === null || stristr($mask,$char));
} while ($mask === null || stristr($mask, $char));
fclose($f);
return $char;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Adapter/Posix.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getWidth()
/**
* Try to read console size from "tput" command
*/
$result = exec('tput cols',$output, $return);
$result = exec('tput cols', $output, $return);
if (!$return && is_numeric($result)) {
return $width = (int)$result;
}
Expand Down Expand Up @@ -213,6 +213,7 @@ public function setPos($x, $y)
* @param string $string
* @param int $color
* @param null|int $bgColor
* @throws Exception\BadMethodCallException
* @return string
*/
public function colorize($string, $color = null, $bgColor = null)
Expand Down Expand Up @@ -248,6 +249,7 @@ public function colorize($string, $color = null, $bgColor = null)
* Change current drawing color.
*
* @param int $color
* @throws Exception\BadMethodCallException
*/
public function setColor($color)
{
Expand All @@ -269,6 +271,7 @@ public function setColor($color)
* Change current drawing background color
*
* @param int $bgColor
* @throws Exception\BadMethodCallException
*/
public function setBgColor($bgColor)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Windows.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function readChar($mask = null)
public function readLine($maxLength = 2048)
{
$f = fopen('php://stdin','r');
$line = rtrim(fread($f,$maxLength),"\r\n");
$line = rtrim(fread($f, $maxLength),"\r\n");
fclose($f);

return $line;
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/WindowsAnsicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public function readChar($mask = null)
$result = $return = null;
exec(
'powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command "'
. '[int[]] $mask = '.join(',',$asciiMask).';'
. '[int[]] $mask = '.join(',', $asciiMask).';'
. 'do {'
. '$key = $Host.UI.RawUI.ReadKey(\'NoEcho,IncludeKeyDown\').VirtualKeyCode;'
. '} while( !($mask -contains $key) );'
Expand All @@ -276,7 +276,7 @@ public function readChar($mask = null)

$char = !empty($result) ? trim(implode('', $result)) : null;

if (!$return && $char && ($mask === null || in_array($char,$asciiMask))) {
if (!$return && $char && ($mask === null || in_array($char, $asciiMask))) {
// We have obtained an ASCII code, check if it is a carriage
// return and normalize it as needed
if ($char == 13) {
Expand Down
6 changes: 4 additions & 2 deletions src/Getopt.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class Getopt
* @param array $rules
* @param array $argv
* @param array $getoptConfig
* @throws Exception\InvalidArgumentException
*/
public function __construct($rules, $argv = null, $getoptConfig = array())
{
Expand Down Expand Up @@ -312,7 +313,7 @@ public function __unset($key)
* These are appended to those defined when the constructor was called.
*
* @param array $argv
* @throws \Zend\Console\Exception\ExceptionInterface When not given an array as parameter
* @throws \Zend\Console\Exception\InvalidArgumentException When not given an array as parameter
* @return \Zend\Console\Getopt Provides a fluent interface
*/
public function addArguments($argv)
Expand All @@ -330,7 +331,7 @@ public function addArguments($argv)
* These replace any currently defined.
*
* @param array $argv
* @throws \Zend\Console\Exception\ExceptionInterface When not given an array as parameter
* @throws \Zend\Console\Exception\InvalidArgumentException When not given an array as parameter
* @return \Zend\Console\Getopt Provides a fluent interface
*/
public function setArguments($argv)
Expand Down Expand Up @@ -802,6 +803,7 @@ protected function _parseSingleOption($flag, &$argv)
* or no one numeric option handlers is defined
*
* @param int $value
* @throws Exception\RuntimeException
* @return void
*/
protected function _setNumericOptionValue($value)
Expand Down
4 changes: 2 additions & 2 deletions src/Prompt/Char.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function show()
$mask .= strtoupper($mask); // uppercase and append
$mask = str_split($mask); // convert to array
$mask = array_unique($mask); // remove duplicates
$mask = implode("",$mask); // convert back to string
$mask = implode("", $mask); // convert back to string
}

do {
Expand All @@ -121,7 +121,7 @@ public function show()
/**
* Check if it is an allowed char
*/
if (stristr($this->allowedChars,$char) !== false) {
if (stristr($this->allowedChars, $char) !== false) {
if ($this->echo) {
echo trim($char)."\n";
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/Prompt/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function show()
public function setNoChar($noChar)
{
$this->noChar = $noChar;
$this->setAllowedChars($this->yesChar.$this->noChar);
$this->setAllowedChars($this->yesChar . $this->noChar);
}

/**
Expand All @@ -102,7 +102,7 @@ public function getNoChar()
public function setYesChar($yesChar)
{
$this->yesChar = $yesChar;
$this->setAllowedChars($this->yesChar.$this->noChar);
$this->setAllowedChars($this->yesChar . $this->noChar);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Prompt/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public function show()
$this->getConsole()->writeLine("$number is not a number\n");
$valid = false;
} elseif (!$this->allowFloat && (round($number) != $number) ) {
$this->getConsole()->writeLine("Please enter a non-floating number, i.e. ".round($number)."\n");
$this->getConsole()->writeLine("Please enter a non-floating number, i.e. " . round($number) . "\n");
$valid = false;
} elseif ($this->max !== null && $number > $this->max) {
$this->getConsole()->writeLine("Please enter a number not greater than ".$this->max."\n");
$this->getConsole()->writeLine("Please enter a number not greater than " . $this->max . "\n");
$valid = false;
} elseif ($this->min !== null && $number < $this->min) {
$this->getConsole()->writeLine("Please enter a number not smaller than ".$this->min."\n");
$this->getConsole()->writeLine("Please enter a number not smaller than " . $this->min . "\n");
$valid = false;
}
} while (!$valid);
Expand Down
2 changes: 2 additions & 0 deletions src/Prompt/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Select extends Char
* @param array $options Allowed options
* @param bool $allowEmpty Allow empty (no) selection?
* @param bool $echo True to display selected option?
* @throws Exception\BadMethodCallException if no options available
*/
public function __construct(
$promptText = 'Please select one option',
Expand Down Expand Up @@ -121,6 +122,7 @@ public function show()
* Set allowed options
*
* @param array|\Traversable $options
* @throws Exception\BadMethodCallException
*/
public function setOptions($options)
{
Expand Down
7 changes: 4 additions & 3 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

use Zend\Stdlib\Message;
use Zend\Stdlib\Parameters;
use Zend\Stdlib\ParametersInterface;
use Zend\Stdlib\RequestInterface;

/**
Expand All @@ -39,7 +38,9 @@ class Request extends Message implements RequestInterface
/**
* Create a new CLI request
*
* @param array|null $args Console arguments. If not supplied, $_SERVER['argv'] will be used
* @param array|null $args Console arguments. If not supplied, $_SERVER['argv'] will be used
* @param array|null $env Environment data. If not supplied, $_ENV will be used
* @throws Exception\RuntimeException
*/
public function __construct(array $args = null, array $env = null)
{
Expand Down Expand Up @@ -162,7 +163,7 @@ public function env()
*/
public function toString()
{
return trim(implode(' ',$this->params()->toArray()));
return trim(implode(' ', $this->params()->toArray()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/GetoptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public function testEqualsCharacterInLongOptionsValue()

$opts = new Getopt(
array('foo=s' => 'Option One (string)'),
array('--foo='.$fooValue)
array('--foo=' . $fooValue)
);
$this->assertEquals($fooValue, $opts->foo);
}
Expand Down

0 comments on commit b3f7029

Please sign in to comment.