Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use traditional array syntax
  • Loading branch information
Gareth Ellis committed Dec 1, 2015
1 parent 1bd22e5 commit 3f99269
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Console/Helper/ProgressShellHelper.php
Expand Up @@ -81,7 +81,7 @@ public function output($args) {
* @param array $args The initialization data.
* @return void
*/
public function init(array $args = []) {
public function init(array $args = array()) {
$args += ['total' => 100, 'width' => 80];
$this->_progress = 0;
$this->_width = $args['width'];
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Console/Helper/TableShellHelper.php
Expand Up @@ -25,11 +25,11 @@ class TableShellHelper extends ShellHelper {
*
* @var array
*/
protected $_defaultConfig = [
protected $_defaultConfig = array(
'headers' => true,
'rowSeparator' => false,
'headerStyle' => 'info',
];
);

/**
* Calculate the column widths
Expand All @@ -38,7 +38,7 @@ class TableShellHelper extends ShellHelper {
* @return array
*/
protected function _calculateWidths($rows) {
$widths = [];
$widths = array();
foreach ($rows as $line) {
for ($i = 0, $len = count($line); $i < $len; $i++) {
$columnLength = mb_strlen($line[$i]);
Expand Down Expand Up @@ -73,7 +73,7 @@ protected function _rowSeparator($widths) {
* @param array $options Options to be passed.
* @return void
*/
protected function _render($row, $widths, $options = []) {
protected function _render($row, $widths, $options = array()) {
$out = '';
foreach ($row as $i => $column) {
$pad = $widths[$i] - mb_strlen($column);
Expand Down
42 changes: 21 additions & 21 deletions lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php
Expand Up @@ -41,7 +41,7 @@ public function setUp() {
* @return void
*/
public function testOutputFailure() {
$this->helper->output(['not a callback']);
$this->helper->output(array('not a callback'));
}

/**
Expand All @@ -50,10 +50,10 @@ public function testOutputFailure() {
* @return void
*/
public function testOutputSuccess() {
$this->helper->output([function ($progress) {
$this->helper->output(array(function ($progress) {
$progress->increment(20);
}]);
$expected = [
}));
$expected = array(
'',
'==============> 20%',
'',
Expand All @@ -65,7 +65,7 @@ public function testOutputSuccess() {
'',
'==========================================================================> 100%',
'',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -75,14 +75,14 @@ public function testOutputSuccess() {
* @return void
*/
public function testOutputSuccessOptions() {
$this->helper->output([
$this->helper->output(array(
'total' => 10,
'width' => 20,
'callback' => function ($progress) {
$progress->increment(2);
}
]);
$expected = [
));
$expected = array(
'',
'==> 20%',
'',
Expand All @@ -94,7 +94,7 @@ public function testOutputSuccessOptions() {
'',
'==============> 100%',
'',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -111,14 +111,14 @@ public function testIncrementAndRender() {
$this->helper->draw();
$this->helper->increment(40);
$this->helper->draw();
$expected = [
$expected = array(
'',
'==============> 20%',
'',
'============================================> 60%',
'',
'==========================================================================> 100%',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -135,14 +135,14 @@ public function testIncrementWithNegatives() {
$this->helper->draw();
$this->helper->increment(80);
$this->helper->draw();
$expected = [
$expected = array(
'',
'=============================> 40%',
'',
' 0%',
'',
'===========================================================> 80%',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -152,25 +152,25 @@ public function testIncrementWithNegatives() {
* @return void
*/
public function testIncrementWithOptions() {
$this->helper->init([
$this->helper->init(array(
'total' => 10,
'width' => 20,
]);
));
$this->helper->increment(4);
$this->helper->draw();
$this->helper->increment(4);
$this->helper->draw();
$this->helper->increment(4);
$this->helper->draw();

$expected = [
$expected = array(
'',
'=====> 40%',
'',
'===========> 80%',
'',
'==============> 100%',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -181,9 +181,9 @@ public function testIncrementWithOptions() {
* @return void
*/
public function testIncrementFloatPad() {
$this->helper->init([
$this->helper->init(array(
'total' => 50
]);
));
$this->helper->increment(7);
$this->helper->draw();
$this->helper->increment(7);
Expand All @@ -200,7 +200,7 @@ public function testIncrementFloatPad() {
$this->helper->draw();
$this->helper->increment(8);
$this->helper->draw();
$expected = [
$expected = array(
'',
'=========> 14%',
'',
Expand All @@ -217,7 +217,7 @@ public function testIncrementFloatPad() {
'==============================================================> 84%',
'',
'==========================================================================> 100%',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
}
106 changes: 53 additions & 53 deletions lib/Cake/Test/Case/Console/Helper/TableShellHelperTest.php
Expand Up @@ -40,20 +40,20 @@ public function setUp() {
* @return void
*/
public function testDefaultOutput() {
$data = [
['Header 1', 'Header', 'Long Header'],
['short', 'Longish thing', 'short'],
['Longer thing', 'short', 'Longest Value'],
];
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->output($data);
$expected = [
$expected = array(
'+--------------+---------------+---------------+',
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -63,20 +63,20 @@ public function testDefaultOutput() {
* @return void
*/
public function testOutputUtf8() {
$data = [
['Header 1', 'Head', 'Long Header'],
['short', 'ÄÄÄÜÜÜ', 'short'],
['Longer thing', 'longerish', 'Longest Value'],
];
$data = array(
array('Header 1', 'Head', 'Long Header'),
array('short', 'ÄÄÄÜÜÜ', 'short'),
array('Longer thing', 'longerish', 'Longest Value'),
);
$this->helper->output($data);
$expected = [
$expected = array(
'+--------------+-----------+---------------+',
'| <info>Header 1</info> | <info>Head</info> | <info>Long Header</info> |',
'+--------------+-----------+---------------+',
'| short | ÄÄÄÜÜÜ | short |',
'| Longer thing | longerish | Longest Value |',
'+--------------+-----------+---------------+',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -86,21 +86,21 @@ public function testOutputUtf8() {
* @return void
*/
public function testOutputWithoutHeaderStyle() {
$data = [
['Header 1', 'Header', 'Long Header'],
['short', 'Longish thing', 'short'],
['Longer thing', 'short', 'Longest Value'],
];
$this->helper->config(['headerStyle' => false]);
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('headerStyle' => false));
$this->helper->output($data);
$expected = [
$expected = array(
'+--------------+---------------+---------------+',
'| Header 1 | Header | Long Header |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -110,21 +110,21 @@ public function testOutputWithoutHeaderStyle() {
* @return void
*/
public function testOutputWithDifferentHeaderStyle() {
$data = [
['Header 1', 'Header', 'Long Header'],
['short', 'Longish thing', 'short'],
['Longer thing', 'short', 'Longest Value'],
];
$this->helper->config(['headerStyle' => 'error']);
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('headerStyle' => 'error'));
$this->helper->output($data);
$expected = [
$expected = array(
'+--------------+---------------+---------------+',
'| <error>Header 1</error> | <error>Header</error> | <error>Long Header</error> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -134,18 +134,18 @@ public function testOutputWithDifferentHeaderStyle() {
* @return void
*/
public function testOutputWithoutHeaders() {
$data = [
['short', 'Longish thing', 'short'],
['Longer thing', 'short', 'Longest Value'],
];
$this->helper->config(['headers' => false]);
$data = array(
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('headers' => false));
$this->helper->output($data);
$expected = [
$expected = array(
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -155,22 +155,22 @@ public function testOutputWithoutHeaders() {
* @return void
*/
public function testOutputWithRowSeparator() {
$data = [
['Header 1', 'Header', 'Long Header'],
['short', 'Longish thing', 'short'],
['Longer thing', 'short', 'Longest Value']
];
$this->helper->config(['rowSeparator' => true]);
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value')
);
$this->helper->config(array('rowSeparator' => true));
$this->helper->output($data);
$expected = [
$expected = array(
'+--------------+---------------+---------------+',
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'+--------------+---------------+---------------+',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}

Expand All @@ -180,22 +180,22 @@ public function testOutputWithRowSeparator() {
* @return void
*/
public function testOutputWithRowSeparatorAndHeaders() {
$data = [
['Header 1', 'Header', 'Long Header'],
['short', 'Longish thing', 'short'],
['Longer thing', 'short', 'Longest Value'],
];
$this->helper->config(['rowSeparator' => true]);
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('rowSeparator' => true));
$this->helper->output($data);
$expected = [
$expected = array(
'+--------------+---------------+---------------+',
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'+--------------+---------------+---------------+',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
];
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
}

0 comments on commit 3f99269

Please sign in to comment.