Skip to content
This repository was archived by the owner on Dec 7, 2018. It is now read-only.

Commit d4755af

Browse files
Fix CS/WS issues
1 parent 0826e56 commit d4755af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+521
-520
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.idea
2+
/.php_cs.cache
23
/composer.lock
34
/build
45
/vendor

src/AbstractTester.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ abstract class AbstractTester implements Tester
4545
*/
4646
public function __construct()
4747
{
48-
$this->setUpOperation = Factory::CLEAN_INSERT();
48+
$this->setUpOperation = Factory::CLEAN_INSERT();
4949
$this->tearDownOperation = Factory::NONE();
5050
}
5151

src/Constraint/DataSetIsEqual.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function failureDescription($other)
8383
*/
8484
public function toString()
8585
{
86-
return sprintf(
86+
return \sprintf(
8787
'is equal to expected %s', $this->value->__toString()
8888
);
8989
}

src/Constraint/TableIsEqual.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function failureDescription($other)
8383
*/
8484
public function toString()
8585
{
86-
return sprintf(
86+
return \sprintf(
8787
'is equal to expected %s', $this->value->__toString()
8888
);
8989
}

src/Constraint/TableRowCount.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct($tableName, $value)
3737
{
3838
parent::__construct();
3939
$this->tableName = $tableName;
40-
$this->value = $value;
40+
$this->value = $value;
4141
}
4242

4343
/**
@@ -62,6 +62,6 @@ protected function matches($other)
6262
*/
6363
public function toString()
6464
{
65-
return sprintf('is equal to expected row count %d', $this->value);
65+
return \sprintf('is equal to expected row count %d', $this->value);
6666
}
6767
}

src/DataSet/AbstractDataSet.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ public function getReverseIterator()
9898
*/
9999
public function matches(IDataSet $other)
100100
{
101-
$thisTableNames = $this->getTableNames();
101+
$thisTableNames = $this->getTableNames();
102102
$otherTableNames = $other->getTableNames();
103103

104-
sort($thisTableNames);
105-
sort($otherTableNames);
104+
\sort($thisTableNames);
105+
\sort($otherTableNames);
106106

107107
if ($thisTableNames != $otherTableNames) {
108108
return false;

src/DataSet/AbstractTable.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getTableMetaData()
6464
*/
6565
public function getRowCount()
6666
{
67-
return count($this->data);
67+
return \count($this->data);
6868
}
6969

7070
/**
@@ -82,7 +82,7 @@ public function getValue($row, $column)
8282

8383
return ($value instanceof SimpleXMLElement) ? (string) $value : $value;
8484
} else {
85-
if (!in_array($column, $this->getTableMetaData()->getColumns()) || $this->getRowCount() <= $row) {
85+
if (!\in_array($column, $this->getTableMetaData()->getColumns()) || $this->getRowCount() <= $row) {
8686
throw new InvalidArgumentException("The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}");
8787
} else {
8888
return;
@@ -117,7 +117,7 @@ public function getRow($row)
117117
*/
118118
public function matches(ITable $other)
119119
{
120-
$thisMetaData = $this->getTableMetaData();
120+
$thisMetaData = $this->getTableMetaData();
121121
$otherMetaData = $other->getTableMetaData();
122122

123123
if (!$thisMetaData->matches($otherMetaData) ||
@@ -126,14 +126,14 @@ public function matches(ITable $other)
126126
return false;
127127
}
128128

129-
$columns = $thisMetaData->getColumns();
129+
$columns = $thisMetaData->getColumns();
130130
$rowCount = $this->getRowCount();
131131

132132
for ($i = 0; $i < $rowCount; $i++) {
133133
foreach ($columns as $columnName) {
134-
$thisValue = $this->getValue($i, $columnName);
134+
$thisValue = $this->getValue($i, $columnName);
135135
$otherValue = $other->getValue($i, $columnName);
136-
if (is_numeric($thisValue) && is_numeric($otherValue)) {
136+
if (\is_numeric($thisValue) && \is_numeric($otherValue)) {
137137
if ($thisValue != $otherValue) {
138138
$this->other = $other;
139139

@@ -159,21 +159,21 @@ public function matches(ITable $other)
159159
*/
160160
public function assertContainsRow(array $row)
161161
{
162-
return in_array($row, $this->data);
162+
return \in_array($row, $this->data);
163163
}
164164

165165
public function __toString()
166166
{
167167
$columns = $this->getTableMetaData()->getColumns();
168-
$count = count($columns);
168+
$count = \count($columns);
169169
// if count less than 0 (when table is empty), then set count to one
170-
$count = $count >= 1 ? $count : 1;
171-
$lineSeperator = str_repeat('+----------------------', $count) . "+\n";
172-
$lineLength = strlen($lineSeperator) - 1;
170+
$count = $count >= 1 ? $count : 1;
171+
$lineSeperator = \str_repeat('+----------------------', $count) . "+\n";
172+
$lineLength = \strlen($lineSeperator) - 1;
173173

174174
$tableString = $lineSeperator;
175-
$tblName = $this->getTableMetaData()->getTableName();
176-
$tableString .= '| ' . str_pad($tblName, $lineLength - 4, ' ',
175+
$tblName = $this->getTableMetaData()->getTableName();
176+
$tableString .= '| ' . \str_pad($tblName, $lineLength - 4, ' ',
177177
STR_PAD_RIGHT) . " |\n";
178178
$tableString .= $lineSeperator;
179179
$rows = $this->rowToString($columns);
@@ -188,10 +188,10 @@ public function __toString()
188188
if ($this->other) {
189189
try {
190190
if ($this->getValue($i, $columnName) != $this->other->getValue($i, $columnName)) {
191-
$values[] = sprintf(
191+
$values[] = \sprintf(
192192
'%s != actual %s',
193-
var_export($this->getValue($i, $columnName), true),
194-
var_export($this->other->getValue($i, $columnName), true)
193+
\var_export($this->getValue($i, $columnName), true),
194+
\var_export($this->other->getValue($i, $columnName), true)
195195
);
196196
} else {
197197
$values[] = $this->getValue($i, $columnName);
@@ -215,14 +215,14 @@ protected function rowToString(array $row)
215215
$rowString = '';
216216

217217
foreach ($row as $value) {
218-
if (is_null($value)) {
218+
if (\is_null($value)) {
219219
$value = 'NULL';
220220
}
221221

222-
$value_str = mb_substr($value, 0, 20);
222+
$value_str = \mb_substr($value, 0, 20);
223223
// make str_pad act in multibyte manner
224-
$correction = strlen($value_str) - mb_strlen($value_str);
225-
$rowString .= '| ' . str_pad($value_str, 20 + $correction, ' ', STR_PAD_BOTH) . ' ';
224+
$correction = \strlen($value_str) - \mb_strlen($value_str);
225+
$rowString .= '| ' . \str_pad($value_str, 20 + $correction, ' ', STR_PAD_BOTH) . ' ';
226226
}
227227
/** @see https://github.com/sebastianbergmann/dbunit/issues/195 */
228228
$rowString = !empty($row) ? $rowString . "|\n" : '';

src/DataSet/AbstractXmlDataSet.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,30 @@ abstract class AbstractXmlDataSet extends AbstractDataSet
3636
*/
3737
public function __construct($xmlFile)
3838
{
39-
if (!is_file($xmlFile)) {
39+
if (!\is_file($xmlFile)) {
4040
throw new InvalidArgumentException(
4141
"Could not find xml file: {$xmlFile}"
4242
);
4343
}
4444

45-
$libxmlErrorReporting = libxml_use_internal_errors(true);
46-
$this->xmlFileContents = simplexml_load_file($xmlFile, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
45+
$libxmlErrorReporting = \libxml_use_internal_errors(true);
46+
$this->xmlFileContents = \simplexml_load_file($xmlFile, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
4747

4848
if (!$this->xmlFileContents) {
4949
$message = '';
5050

51-
foreach (libxml_get_errors() as $error) {
52-
$message .= print_r($error, true);
51+
foreach (\libxml_get_errors() as $error) {
52+
$message .= \print_r($error, true);
5353
}
5454

5555
throw new RuntimeException($message);
5656
}
5757

58-
libxml_clear_errors();
59-
libxml_use_internal_errors($libxmlErrorReporting);
58+
\libxml_clear_errors();
59+
\libxml_use_internal_errors($libxmlErrorReporting);
6060

6161
$tableColumns = [];
62-
$tableValues = [];
62+
$tableValues = [];
6363

6464
$this->getTableInfo($tableColumns, $tableValues);
6565
$this->createTables($tableColumns, $tableValues);
@@ -92,7 +92,7 @@ protected function createTables(array &$tableColumns, array &$tableValues)
9292
protected function getOrCreateTable($tableName, $tableColumns)
9393
{
9494
if (empty($this->tables[$tableName])) {
95-
$tableMetaData = new DefaultTableMetadata($tableName, $tableColumns);
95+
$tableMetaData = new DefaultTableMetadata($tableName, $tableColumns);
9696
$this->tables[$tableName] = new DefaultTable($tableMetaData);
9797
}
9898

src/DataSet/ArrayDataSet.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public function __construct(array $data)
4343
foreach ($data as $tableName => $rows) {
4444
$columns = [];
4545
if (isset($rows[0])) {
46-
$columns = array_keys($rows[0]);
46+
$columns = \array_keys($rows[0]);
4747
}
4848

4949
$metaData = new DefaultTableMetadata($tableName, $columns);
50-
$table = new DefaultTable($metaData);
50+
$table = new DefaultTable($metaData);
5151

5252
foreach ($rows as $row) {
5353
$table->addRow($row);

src/DataSet/CompositeDataSet.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(array $dataSets = [])
4949
public function addDataSet(IDataSet $dataSet)
5050
{
5151
foreach ($dataSet->getTableNames() as $tableName) {
52-
if (!in_array($tableName, $this->getTableNames())) {
52+
if (!\in_array($tableName, $this->getTableNames())) {
5353
$this->motherDataSet->addTable($dataSet->getTable($tableName));
5454
} else {
5555
$other = $dataSet->getTable($tableName);

src/DataSet/CsvDataSet.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct($delimiter = ',', $enclosure = '"', $escape = '"')
5252
{
5353
$this->delimiter = $delimiter;
5454
$this->enclosure = $enclosure;
55-
$this->escape = $escape;
55+
$this->escape = $escape;
5656
}
5757

5858
/**
@@ -66,26 +66,26 @@ public function __construct($delimiter = ',', $enclosure = '"', $escape = '"')
6666
*/
6767
public function addTable($tableName, $csvFile)
6868
{
69-
if (!is_file($csvFile)) {
69+
if (!\is_file($csvFile)) {
7070
throw new InvalidArgumentException("Could not find csv file: {$csvFile}");
7171
}
7272

73-
if (!is_readable($csvFile)) {
73+
if (!\is_readable($csvFile)) {
7474
throw new InvalidArgumentException("Could not read csv file: {$csvFile}");
7575
}
7676

77-
$fh = fopen($csvFile, 'r');
77+
$fh = \fopen($csvFile, 'r');
7878
$columns = $this->getCsvRow($fh);
7979

8080
if ($columns === false) {
8181
throw new InvalidArgumentException("Could not determine the headers from the given file {$csvFile}");
8282
}
8383

8484
$metaData = new DefaultTableMetadata($tableName, $columns);
85-
$table = new DefaultTable($metaData);
85+
$table = new DefaultTable($metaData);
8686

8787
while (($row = $this->getCsvRow($fh)) !== false) {
88-
$table->addRow(array_combine($columns, $row));
88+
$table->addRow(\array_combine($columns, $row));
8989
}
9090

9191
$this->tables[$tableName] = $table;
@@ -113,10 +113,10 @@ protected function createIterator($reverse = false)
113113
*/
114114
protected function getCsvRow($fh)
115115
{
116-
if (version_compare(PHP_VERSION, '5.3.0', '>')) {
117-
return fgetcsv($fh, null, $this->delimiter, $this->enclosure, $this->escape);
116+
if (\version_compare(PHP_VERSION, '5.3.0', '>')) {
117+
return \fgetcsv($fh, null, $this->delimiter, $this->enclosure, $this->escape);
118118
} else {
119-
return fgetcsv($fh, null, $this->delimiter, $this->enclosure);
119+
return \fgetcsv($fh, null, $this->delimiter, $this->enclosure);
120120
}
121121
}
122122
}

src/DataSet/DefaultTable.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function __construct(ITableMetadata $tableMetaData)
3535
*/
3636
public function addRow($values = [])
3737
{
38-
$this->data[] = array_replace(
39-
array_fill_keys($this->getTableMetaData()->getColumns(), null),
38+
$this->data[] = \array_replace(
39+
\array_fill_keys($this->getTableMetaData()->getColumns(), null),
4040
$values
4141
);
4242
}
@@ -49,7 +49,7 @@ public function addRow($values = [])
4949
public function addTableRows(ITable $table)
5050
{
5151
$tableColumns = $this->getTableMetaData()->getColumns();
52-
$rowCount = $table->getRowCount();
52+
$rowCount = $table->getRowCount();
5353

5454
for ($i = 0; $i < $rowCount; $i++) {
5555
$newRow = [];

src/DataSet/DefaultTableIterator.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DefaultTableIterator implements ITableIterator
3838
*/
3939
public function __construct(array $tables, $reverse = false)
4040
{
41-
$this->tables = $tables;
41+
$this->tables = $tables;
4242
$this->reverse = $reverse;
4343

4444
$this->rewind();
@@ -71,7 +71,7 @@ public function getTableMetaData()
7171
*/
7272
public function current()
7373
{
74-
return current($this->tables);
74+
return \current($this->tables);
7575
}
7676

7777
/**
@@ -90,9 +90,9 @@ public function key()
9090
public function next()
9191
{
9292
if ($this->reverse) {
93-
prev($this->tables);
93+
\prev($this->tables);
9494
} else {
95-
next($this->tables);
95+
\next($this->tables);
9696
}
9797
}
9898

@@ -102,9 +102,9 @@ public function next()
102102
public function rewind()
103103
{
104104
if ($this->reverse) {
105-
end($this->tables);
105+
\end($this->tables);
106106
} else {
107-
reset($this->tables);
107+
\reset($this->tables);
108108
}
109109
}
110110

src/DataSet/DefaultTableMetadata.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class DefaultTableMetadata extends AbstractTableMetadata
2626
*/
2727
public function __construct($tableName, array $columns, array $primaryKeys = [])
2828
{
29-
$this->tableName = $tableName;
30-
$this->columns = $columns;
29+
$this->tableName = $tableName;
30+
$this->columns = $columns;
3131
$this->primaryKeys = [];
3232

3333
foreach ($primaryKeys as $columnName) {
34-
if (!in_array($columnName, $this->columns)) {
34+
if (!\in_array($columnName, $this->columns)) {
3535
throw new InvalidArgumentException('Primary key column passed that is not in the column list.');
3636
} else {
3737
$this->primaryKeys[] = $columnName;

0 commit comments

Comments
 (0)