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

Commit

Permalink
Merge branch 'feature/php-short-array-syntax'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Jun 5, 2015
2 parents 6d52d2d + 7583bfb commit c4e5301
Show file tree
Hide file tree
Showing 16 changed files with 1,187 additions and 1,186 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $config->fixers(
'object_operator',
'php_closing_tag',
'remove_lines_between_uses',
'short_array_syntax',
'short_tag',
'standardize_not_equal',
'trailing_spaces',
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ public function getHeight()
*/
public function getSize()
{
return array(
return [
$this->getWidth(),
$this->getHeight(),
);
];
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Adapter/Posix.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Posix extends AbstractAdapter
*
* @var array
*/
protected static $ansiColorMap = array(
'fg' => array(
protected static $ansiColorMap = [
'fg' => [
Color::NORMAL => '22;39',
Color::RESET => '22;39',

Expand All @@ -60,8 +60,8 @@ class Posix extends AbstractAdapter
Color::LIGHT_MAGENTA => '1;35',
Color::LIGHT_CYAN => '1;36',
Color::LIGHT_WHITE => '1;37',
),
'bg' => array(
],
'bg' => [
Color::NORMAL => '0;49',
Color::RESET => '0;49',

Expand All @@ -82,8 +82,8 @@ class Posix extends AbstractAdapter
Color::LIGHT_MAGENTA => '45',
Color::LIGHT_CYAN => '46',
Color::LIGHT_WHITE => '47',
),
);
],
];

/**
* Last fetched TTY mode
Expand Down
2 changes: 1 addition & 1 deletion src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ public static function detectBestAdapter()
public static function __callStatic($funcName, $arguments)
{
$instance = static::getInstance();
return call_user_func_array(array($instance, $funcName), $arguments);
return call_user_func_array([$instance, $funcName], $arguments);
}
}
52 changes: 26 additions & 26 deletions src/Getopt.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Getopt
* cumulative flags are disable,
* freeform flags are disable.
*/
protected $getoptConfig = array(
protected $getoptConfig = [
self::CONFIG_RULEMODE => self::MODE_ZEND,
self::CONFIG_DASHDASH => true,
self::CONFIG_IGNORECASE => false,
Expand All @@ -127,14 +127,14 @@ class Getopt
self::CONFIG_PARAMETER_SEPARATOR => null,
self::CONFIG_FREEFORM_FLAGS => false,
self::CONFIG_NUMERIC_FLAGS => false
);
];

/**
* Stores the command-line arguments for the calling application.
*
* @var array
*/
protected $argv = array();
protected $argv = [];

/**
* Stores the name of the calling application.
Expand All @@ -148,29 +148,29 @@ class Getopt
*
* @var array
*/
protected $rules = array();
protected $rules = [];

/**
* Stores alternate spellings of legal options.
*
* @var array
*/
protected $ruleMap = array();
protected $ruleMap = [];

/**
* Stores options given by the user in the current invocation
* of the application, as well as parameters given in options.
*
* @var array
*/
protected $options = array();
protected $options = [];

/**
* Stores the command-line arguments other than options.
*
* @var array
*/
protected $remainingArgs = array();
protected $remainingArgs = [];

/**
* State of the options: parsed or not yet parsed?
Expand All @@ -184,7 +184,7 @@ class Getopt
*
* @var array
*/
protected $optionCallbacks = array();
protected $optionCallbacks = [];

/**
* The constructor takes one to three parameters.
Expand All @@ -203,7 +203,7 @@ class Getopt
* @param array $getoptConfig
* @throws Exception\InvalidArgumentException
*/
public function __construct($rules, $argv = null, $getoptConfig = array())
public function __construct($rules, $argv = null, $getoptConfig = [])
{
if (!isset($_SERVER['argv'])) {
$errorDescription = (ini_get('register_argc_argv') == false)
Expand Down Expand Up @@ -407,7 +407,7 @@ public function addRules($rules)
public function toString()
{
$this->parse();
$s = array();
$s = [];
foreach ($this->options as $flag => $value) {
$s[] = $flag . '=' . ($value === true ? 'true' : $value);
}
Expand All @@ -426,7 +426,7 @@ public function toString()
public function toArray()
{
$this->parse();
$s = array();
$s = [];
foreach ($this->options as $flag => $value) {
$s[] = $flag;
if ($value !== true) {
Expand All @@ -444,14 +444,14 @@ public function toArray()
public function toJson()
{
$this->parse();
$j = array();
$j = [];
foreach ($this->options as $flag => $value) {
$j['options'][] = array(
'option' => array(
$j['options'][] = [
'option' => [
'flag' => $flag,
'parameter' => $value
)
);
]
];
}

$json = \Zend\Json\Json::encode($j);
Expand Down Expand Up @@ -550,12 +550,12 @@ public function getUsageMessage()
{
$usage = "Usage: {$this->progname} [ options ]\n";
$maxLen = 20;
$lines = array();
$lines = [];
foreach ($this->rules as $rule) {
if (isset($rule['isFreeformFlag'])) {
continue;
}
$flags = array();
$flags = [];
if (is_array($rule['alias'])) {
foreach ($rule['alias'] as $flag) {
$flags[] = (strlen($flag) == 1 ? '-' : '--') . $flag;
Expand Down Expand Up @@ -660,8 +660,8 @@ public function parse()
}

$argv = $this->argv;
$this->options = array();
$this->remainingArgs = array();
$this->options = [];
$this->remainingArgs = [];
while (count($argv) > 0) {
if ($argv[0] == '--') {
array_shift($argv);
Expand Down Expand Up @@ -796,10 +796,10 @@ protected function _parseSingleOption($flag, &$argv)
// Magic methods in future will use this mark as real flag value
$this->ruleMap[$flag] = $flag;
$realFlag = $flag;
$this->rules[$realFlag] = array(
$this->rules[$realFlag] = [
'param' => 'optional',
'isFreeformFlag' => true
);
];
} else {
$realFlag = $this->ruleMap[$flag];
}
Expand Down Expand Up @@ -948,7 +948,7 @@ protected function _checkParameterType($flag, $param)
*/
protected function _addRulesModeGnu($rules)
{
$ruleArray = array();
$ruleArray = [];

/**
* Options may be single alphanumeric characters.
Expand All @@ -957,7 +957,7 @@ protected function _addRulesModeGnu($rules)
*/
preg_match_all('/([a-zA-Z0-9]:?)/', $rules, $ruleArray);
foreach ($ruleArray[1] as $rule) {
$r = array();
$r = [];
$flag = substr($rule, 0, 1);
if ($this->getoptConfig[self::CONFIG_IGNORECASE]) {
$flag = strtolower($flag);
Expand Down Expand Up @@ -986,7 +986,7 @@ protected function _addRulesModeZend($rules)
// this may have to translate the long parm type if there
// are any complaints that =string will not work (even though that use
// case is not documented)
if (in_array(substr($ruleCode, -2, 1), array('-', '='))) {
if (in_array(substr($ruleCode, -2, 1), ['-', '='])) {
$flagList = substr($ruleCode, 0, -2);
$delimiter = substr($ruleCode, -2, 1);
$paramType = substr($ruleCode, -1);
Expand All @@ -998,7 +998,7 @@ protected function _addRulesModeZend($rules)
$flagList = strtolower($flagList);
}
$flags = explode('|', $flagList);
$rule = array();
$rule = [];
$mainFlag = $flags[0];
foreach ($flags as $flag) {
if (empty($flag)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Prompt/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class Checkbox extends AbstractPrompt
* Checked options
* @var array
*/
private $checkedOptions = array();
private $checkedOptions = [];

/**
* If the response should be echoed to the console or not
Expand All @@ -47,7 +47,7 @@ final class Checkbox extends AbstractPrompt
* @param array|Transversable $options Allowed options
* @param bool $echo True to display selected option?
*/
public function __construct($promptText = 'Please select one option (Enter to finish) ', $options = array(), $ignoreCase = true, $echo = false)
public function __construct($promptText = 'Please select one option (Enter to finish) ', $options = [], $ignoreCase = true, $echo = false)
{
$this->promptText = (string) $promptText;

Expand All @@ -65,7 +65,7 @@ public function __construct($promptText = 'Please select one option (Enter to fi
*/
public function show()
{
$this->checkedOptions = array();
$this->checkedOptions = [];
$mask = $this->prepareMask();

do {
Expand Down
6 changes: 3 additions & 3 deletions src/Prompt/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Select extends Char
/**
* @var array
*/
protected $options = array();
protected $options = [];

/**
* Ask the user to select one of pre-defined options
Expand All @@ -39,7 +39,7 @@ class Select extends Char
*/
public function __construct(
$promptText = 'Please select one option',
$options = array(),
$options = [],
$allowEmpty = false,
$echo = false
) {
Expand Down Expand Up @@ -126,7 +126,7 @@ public function setOptions($options)
}

if (!is_array($options)) {
$this->options = array();
$this->options = [];
foreach ($options as $k => $v) {
$this->options[$k] = $v;
}
Expand Down
Loading

0 comments on commit c4e5301

Please sign in to comment.