Skip to content

Commit 0fbdabd

Browse files
committed
Uses new array syntax
1 parent 752b0e6 commit 0fbdabd

22 files changed

+66
-66
lines changed

src/Drivers/MysqlDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function escapeText($value)
2828
// https://dev.mysql.com/doc/refman/5.5/en/string-literals.html
2929
// http://us3.php.net/manual/en/function.mysql-real-escape-string.php#101248
3030
return '\'' . str_replace(
31-
array('\\', "\0", "\n", "\r", "\t", "'", '"', "\x1a"),
32-
array('\\\\', '\\0', '\\n', '\\r', '\\t', "\\'", '\\"', '\\Z'),
31+
['\\', "\0", "\n", "\r", "\t", "'", '"', "\x1a"],
32+
['\\\\', '\\0', '\\n', '\\r', '\\t', "\\'", '\\"', '\\Z'],
3333
$value
3434
) . '\'';
3535
}

src/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ public static function formatValue($value, IDriver $driver)
4848
*/
4949
public static function normalizeNewLines($s)
5050
{
51-
return str_replace(array("\r\n", "\r"), "\n", $s);
51+
return str_replace(["\r\n", "\r"], "\n", $s);
5252
}
5353
}

src/SqlDocument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class SqlDocument
77
{
88
/** @var IStatement[] */
9-
private $statements = array();
9+
private $statements = [];
1010

1111

1212
/**
@@ -33,7 +33,7 @@ public function isEmpty()
3333
*/
3434
public function getSqlQueries(IDriver $driver)
3535
{
36-
$output = array();
36+
$output = [];
3737

3838
foreach ($this->statements as $statement) {
3939
$output[] = $statement->toSql($driver);

src/Statements/AddColumn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AddColumn implements IStatement
2626
* @param array
2727
* @param array [name => value]
2828
*/
29-
public function __construct($name, $type, array $parameters = NULL, array $options = array())
29+
public function __construct($name, $type, array $parameters = NULL, array $options = [])
3030
{
3131
$this->definition = new ColumnDefinition($name, $type, $parameters, $options);
3232
}

src/Statements/AddForeignKey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AddForeignKey implements IStatement
2020
* @param string
2121
* @param string[]|string
2222
*/
23-
public function __construct($name, $columns = array(), $targetTable, $targetColumns = array())
23+
public function __construct($name, $columns = [], $targetTable, $targetColumns = [])
2424
{
2525
$this->definition = new ForeignKeyDefinition($name, $columns, $targetTable, $targetColumns);
2626
}

src/Statements/AlterTable.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class AlterTable implements IStatement
1414
private $tableName;
1515

1616
/** @var IStatement[] */
17-
private $statements = array();
17+
private $statements = [];
1818

1919
/** @var string|NULL */
2020
private $comment;
2121

2222
/** @var array [name => value] */
23-
private $options = array();
23+
private $options = [];
2424

2525

2626
/**
@@ -39,7 +39,7 @@ public function __construct($tableName)
3939
* @param array [name => value]
4040
* @return AddColumn
4141
*/
42-
public function addColumn($name, $type, array $parameters = NULL, array $options = array())
42+
public function addColumn($name, $type, array $parameters = NULL, array $options = [])
4343
{
4444
return $this->statements[] = new AddColumn($name, $type, $parameters, $options);
4545
}
@@ -62,7 +62,7 @@ public function dropColumn($column)
6262
* @param array [name => value]
6363
* @return ModifyColumn
6464
*/
65-
public function modifyColumn($name, $type, array $parameters = NULL, array $options = array())
65+
public function modifyColumn($name, $type, array $parameters = NULL, array $options = [])
6666
{
6767
return $this->statements[] = new ModifyColumn($name, $type, $parameters, $options);
6868
}
@@ -96,7 +96,7 @@ public function dropIndex($index)
9696
* @param string[]|string
9797
* @return AddForeignKey
9898
*/
99-
public function addForeignKey($name, $columns = array(), $targetTable, $targetColumns = array())
99+
public function addForeignKey($name, $columns = [], $targetTable, $targetColumns = [])
100100
{
101101
return $this->statements[] = new AddForeignKey($name, $columns, $targetTable, $targetColumns);
102102
}

src/Statements/ColumnDefinition.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class ColumnDefinition implements IStatement
1818
private $type;
1919

2020
/** @var array */
21-
private $parameters = array();
21+
private $parameters = [];
2222

2323
/** @var array [name => value] */
24-
private $options = array();
24+
private $options = [];
2525

2626
/** @var bool */
2727
private $nullable = FALSE;
@@ -42,11 +42,11 @@ class ColumnDefinition implements IStatement
4242
* @param array
4343
* @param array [name => value]
4444
*/
45-
public function __construct($name, $type, array $parameters = NULL, array $options = array())
45+
public function __construct($name, $type, array $parameters = NULL, array $options = [])
4646
{
4747
$this->name = $name;
4848
$this->type = $type;
49-
$this->parameters = ($parameters !== NULL) ? $parameters : array();
49+
$this->parameters = ($parameters !== NULL) ? $parameters : [];
5050
$this->options = $options;
5151
}
5252

@@ -111,13 +111,13 @@ public function toSql(IDriver $driver)
111111
}
112112

113113
$options = $this->options;
114-
$specialOptions = array();
114+
$specialOptions = [];
115115

116116
if ($driver instanceof Drivers\MysqlDriver) {
117-
$specialOptions = array(
117+
$specialOptions = [
118118
'CHARACTER SET',
119119
'COLLATE',
120-
);
120+
];
121121
}
122122

123123
foreach ($specialOptions as $option) {

src/Statements/CreateTable.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ class CreateTable implements IStatement
1414
private $tableName;
1515

1616
/** @var array [name => ColumnDefinition] */
17-
private $columns = array();
17+
private $columns = [];
1818

1919
/** @var array [name => IndexDefinition] */
20-
private $indexes = array();
20+
private $indexes = [];
2121

2222
/** @var array [name => ForeignKeyDefinition] */
23-
private $foreignKeys = array();
23+
private $foreignKeys = [];
2424

2525
/** @var string|NULL */
2626
private $comment;
2727

2828
/** @var array [name => value] */
29-
private $options = array();
29+
private $options = [];
3030

3131

3232
/**
@@ -43,7 +43,7 @@ public function __construct($tableName)
4343
* @param string
4444
* @return ColumnDefinition
4545
*/
46-
public function addColumn($name, $type, array $parameters = NULL, array $options = array())
46+
public function addColumn($name, $type, array $parameters = NULL, array $options = [])
4747
{
4848
if (isset($this->columns[$name])) {
4949
throw new DuplicateException("Column '$name' already exists.");
@@ -75,7 +75,7 @@ public function addIndex($name, $type)
7575
* @param string[]|string
7676
* @return ForeignKeyDefinition
7777
*/
78-
public function addForeignKey($name, $columns = array(), $targetTable, $targetColumns = array())
78+
public function addForeignKey($name, $columns = [], $targetTable, $targetColumns = [])
7979
{
8080
if (isset($this->foreignKeys[$name])) {
8181
throw new DuplicateException("Foreign key '$name' already exists.");

src/Statements/ForeignKeyDefinition.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ class ForeignKeyDefinition implements IStatement
4040
* @param string
4141
* @param string[]|string
4242
*/
43-
public function __construct($name, $columns = array(), $targetTable, $targetColumns = array())
43+
public function __construct($name, $columns = [], $targetTable, $targetColumns = [])
4444
{
4545
$this->name = $name;
4646
$this->targetTable = $targetTable;
4747

4848
if (!is_array($columns)) {
49-
$columns = array($columns);
49+
$columns = [$columns];
5050
}
5151

5252
foreach ($columns as $column) {
5353
$this->columns[] = $column;
5454
}
5555

5656
if (!is_array($targetColumns)) {
57-
$targetColumns = array($targetColumns);
57+
$targetColumns = [$targetColumns];
5858
}
5959

6060
foreach ($targetColumns as $targetColumn) {
@@ -100,9 +100,9 @@ public function toSql(IDriver $driver)
100100
{
101101
$output = 'CONSTRAINT ' . $driver->escapeIdentifier($this->name);
102102
$output .= ' FOREIGN KEY (';
103-
$output .= implode(', ', array_map(array($driver, 'escapeIdentifier'), $this->columns));
103+
$output .= implode(', ', array_map([$driver, 'escapeIdentifier'], $this->columns));
104104
$output .= ') REFERENCES ' . $driver->escapeIdentifier($this->targetTable) . ' (';
105-
$output .= implode(', ', array_map(array($driver, 'escapeIdentifier'), $this->targetColumns));
105+
$output .= implode(', ', array_map([$driver, 'escapeIdentifier'], $this->targetColumns));
106106
$output .= ')';
107107
$output .= ' ON DELETE ' . $this->onDeleteAction;
108108
$output .= ' ON UPDATE ' . $this->onUpdateAction;

src/Statements/IndexDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class IndexDefinition implements IStatement
2222
private $type;
2323

2424
/** @var IndexColumnDefinition[] */
25-
private $columns = array();
25+
private $columns = [];
2626

2727

2828
/**

0 commit comments

Comments
 (0)