mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Use traditional array syntax
This commit is contained in:
parent
1bd22e5277
commit
3f992695b2
6 changed files with 84 additions and 84 deletions
|
@ -81,7 +81,7 @@ class ProgressShellHelper extends ShellHelper {
|
|||
* @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'];
|
||||
|
|
|
@ -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
|
||||
|
@ -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]);
|
||||
|
@ -73,7 +73,7 @@ class TableShellHelper extends ShellHelper {
|
|||
* @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);
|
||||
|
|
|
@ -41,7 +41,7 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testOutputFailure() {
|
||||
$this->helper->output(['not a callback']);
|
||||
$this->helper->output(array('not a callback'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,10 +50,10 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testOutputSuccess() {
|
||||
$this->helper->output([function ($progress) {
|
||||
$this->helper->output(array(function ($progress) {
|
||||
$progress->increment(20);
|
||||
}]);
|
||||
$expected = [
|
||||
}));
|
||||
$expected = array(
|
||||
'',
|
||||
'==============> 20%',
|
||||
'',
|
||||
|
@ -65,7 +65,7 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
'',
|
||||
'==========================================================================> 100%',
|
||||
'',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
|
||||
|
@ -75,14 +75,14 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
* @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%',
|
||||
'',
|
||||
|
@ -94,7 +94,7 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
'',
|
||||
'==============> 100%',
|
||||
'',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
|
||||
|
@ -111,14 +111,14 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
$this->helper->draw();
|
||||
$this->helper->increment(40);
|
||||
$this->helper->draw();
|
||||
$expected = [
|
||||
$expected = array(
|
||||
'',
|
||||
'==============> 20%',
|
||||
'',
|
||||
'============================================> 60%',
|
||||
'',
|
||||
'==========================================================================> 100%',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
|
||||
|
@ -135,14 +135,14 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
$this->helper->draw();
|
||||
$this->helper->increment(80);
|
||||
$this->helper->draw();
|
||||
$expected = [
|
||||
$expected = array(
|
||||
'',
|
||||
'=============================> 40%',
|
||||
'',
|
||||
' 0%',
|
||||
'',
|
||||
'===========================================================> 80%',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
|
||||
|
@ -152,10 +152,10 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
* @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);
|
||||
|
@ -163,14 +163,14 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
$this->helper->increment(4);
|
||||
$this->helper->draw();
|
||||
|
||||
$expected = [
|
||||
$expected = array(
|
||||
'',
|
||||
'=====> 40%',
|
||||
'',
|
||||
'===========> 80%',
|
||||
'',
|
||||
'==============> 100%',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
|
||||
|
@ -181,9 +181,9 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
* @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);
|
||||
|
@ -200,7 +200,7 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
$this->helper->draw();
|
||||
$this->helper->increment(8);
|
||||
$this->helper->draw();
|
||||
$expected = [
|
||||
$expected = array(
|
||||
'',
|
||||
'=========> 14%',
|
||||
'',
|
||||
|
@ -217,7 +217,7 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
'==============================================================> 84%',
|
||||
'',
|
||||
'==========================================================================> 100%',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
}
|
|
@ -40,20 +40,20 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
* @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());
|
||||
}
|
||||
|
||||
|
@ -63,20 +63,20 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
* @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());
|
||||
}
|
||||
|
||||
|
@ -86,21 +86,21 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
* @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());
|
||||
}
|
||||
|
||||
|
@ -110,21 +110,21 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
* @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());
|
||||
}
|
||||
|
||||
|
@ -134,18 +134,18 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
* @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());
|
||||
}
|
||||
|
||||
|
@ -155,14 +155,14 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
* @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> |',
|
||||
'+--------------+---------------+---------------+',
|
||||
|
@ -170,7 +170,7 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
'+--------------+---------------+---------------+',
|
||||
'| Longer thing | short | Longest Value |',
|
||||
'+--------------+---------------+---------------+',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
|
||||
|
@ -180,14 +180,14 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
* @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> |',
|
||||
'+--------------+---------------+---------------+',
|
||||
|
@ -195,7 +195,7 @@ class TableShellHelperTest extends CakeTestCase {
|
|||
'+--------------+---------------+---------------+',
|
||||
'| Longer thing | short | Longest Value |',
|
||||
'+--------------+---------------+---------------+',
|
||||
];
|
||||
);
|
||||
$this->assertEquals($expected, $this->consoleOutput->messages());
|
||||
}
|
||||
}
|
|
@ -45,8 +45,8 @@ class ConsoleOutputStubTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testWrite() {
|
||||
$this->stub->write(["foo", "bar", "baz"]);
|
||||
$this->assertEquals(["foo", "bar", "baz"], $this->stub->messages());
|
||||
$this->stub->write(array("foo", "bar", "baz"));
|
||||
$this->assertEquals(array("foo", "bar", "baz"), $this->stub->messages());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,8 +55,8 @@ class ConsoleOutputStubTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testOverwrite() {
|
||||
$this->stub->write(["foo", "bar", "baz"]);
|
||||
$this->stub->write(array("foo", "bar", "baz"));
|
||||
$this->stub->overwrite("bat");
|
||||
$this->assertEquals(["foo", "bar", "baz", "", "bat"], $this->stub->messages());
|
||||
$this->assertEquals(array("foo", "bar", "baz", "", "bat"), $this->stub->messages());
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ class ConsoleOutputStub extends ConsoleOutput {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_out = [];
|
||||
protected $_out = array();
|
||||
|
||||
/**
|
||||
* The number of bytes written by last call to write
|
||||
|
|
Loading…
Add table
Reference in a new issue