Skip to content

Commit 6be24cd

Browse files
committed
Merge pull request #1 from rkrx/scrutinizer-patch-1
Scrutinizer Auto-Fixes
2 parents 3e76123 + d71b9c8 commit 6be24cd

File tree

9 files changed

+41
-41
lines changed

9 files changed

+41
-41
lines changed

src/Builder/InsertUpdateStatement.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public function setMask(array $mask) {
3030
*/
3131
protected function buildFieldList(array $fields, array $query = array()) {
3232
foreach ($fields as $fieldName => $fieldValue) {
33-
if($fieldValue instanceof DefaultValue) {
33+
if ($fieldValue instanceof DefaultValue) {
3434
$fieldValue = 'DEFAULT';
3535
}
36-
if(is_array($this->mask) && !in_array($fieldName, $this->mask)) {
36+
if (is_array($this->mask) && !in_array($fieldName, $this->mask)) {
3737
continue;
3838
}
3939
if (is_int($fieldName)) {
40-
if(is_array($fieldValue)) {
40+
if (is_array($fieldValue)) {
4141
$fieldValue = $this->db()->quoteExpression($fieldValue[0], array_slice($fieldValue, 1));
4242
}
4343
$query[] = "\t{$fieldValue}";
@@ -55,10 +55,10 @@ protected function buildFieldList(array $fields, array $query = array()) {
5555
* @return bool
5656
*/
5757
protected function isFieldAccessible($fieldName, array $tableFields) {
58-
if(!in_array($fieldName, $tableFields)) {
58+
if (!in_array($fieldName, $tableFields)) {
5959
return false;
6060
}
61-
if(!is_array($this->mask)) {
61+
if (!is_array($this->mask)) {
6262
return true;
6363
}
6464
return in_array($fieldName, $this->mask);

src/Builder/QueryStatement.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public function getStatement() {
4343
* @return bool
4444
*/
4545
public function execute(array $params = []) {
46-
return $this->exceptionHandler(function () use ($params) {
46+
return $this->exceptionHandler(function() use ($params) {
4747
$timer = microtime(true);
4848
$response = $this->statement->execute($params);
49-
$this->queryLoggers->log($this->query, microtime(true) - $timer);
49+
$this->queryLoggers->log($this->query, microtime(true)-$timer);
5050
return $response;
5151
});
5252
}
@@ -56,7 +56,7 @@ public function execute(array $params = []) {
5656
*/
5757
public function fetchAll() {
5858
$args = func_get_args();
59-
return $this->exceptionHandler(function () use ($args) {
59+
return $this->exceptionHandler(function() use ($args) {
6060
return call_user_func_array([$this->statement, 'fetchAll'], $args);
6161
});
6262
}
@@ -68,7 +68,7 @@ public function fetchAll() {
6868
* @return mixed
6969
*/
7070
public function fetch($fetchStyle = PDO::FETCH_ASSOC, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) {
71-
return $this->exceptionHandler(function () use ($fetchStyle, $cursorOrientation, $cursorOffset) {
71+
return $this->exceptionHandler(function() use ($fetchStyle, $cursorOrientation, $cursorOffset) {
7272
return $this->statement->fetch($fetchStyle, $cursorOrientation, $cursorOffset);
7373
});
7474
}
@@ -78,7 +78,7 @@ public function fetch($fetchStyle = PDO::FETCH_ASSOC, $cursorOrientation = PDO::
7878
* @return mixed
7979
*/
8080
public function fetchColumn($columnNo = 0) {
81-
return $this->exceptionHandler(function () use ($columnNo) {
81+
return $this->exceptionHandler(function() use ($columnNo) {
8282
return $this->statement->fetchColumn($columnNo);
8383
});
8484
}
@@ -87,7 +87,7 @@ public function fetchColumn($columnNo = 0) {
8787
* @return bool
8888
*/
8989
public function closeCursor() {
90-
return $this->exceptionHandler(function () {
90+
return $this->exceptionHandler(function() {
9191
return $this->statement->closeCursor();
9292
});
9393
}
@@ -96,7 +96,7 @@ public function closeCursor() {
9696
* @return int
9797
*/
9898
public function columnCount() {
99-
return $this->exceptionHandler(function () {
99+
return $this->exceptionHandler(function() {
100100
return $this->statement->columnCount();
101101
});
102102
}
@@ -106,7 +106,7 @@ public function columnCount() {
106106
* @return array
107107
*/
108108
public function getColumnMeta($columnNo) {
109-
return $this->exceptionHandler(function () use ($columnNo) {
109+
return $this->exceptionHandler(function() use ($columnNo) {
110110
return $this->statement->getColumnMeta($columnNo);
111111
});
112112
}

src/Builder/RunnableInsert.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class RunnableInsert extends Insert implements DDLPreparable {
1515
* @return int[] Insert IDs
1616
*/
1717
public function insertRows($rows) {
18-
if(!(is_array($rows) || $rows instanceof Traversable)) {
18+
if (!(is_array($rows) || $rows instanceof Traversable)) {
1919
throw new BadMethodCallException('Expected $rows to by an array or an instance of \\Traversable');
2020
}
2121
$result = [];
2222
$query = $this->__toString();
2323
$stmt = $this->db()->prepare($query);
24-
foreach($rows as $row) {
24+
foreach ($rows as $row) {
2525
$stmt->execute($row);
2626
$result[] = (int) $this->db()->getLastInsertId();
2727
}
@@ -33,7 +33,7 @@ public function insertRows($rows) {
3333
* @return DDLRunnable
3434
*/
3535
public function prepare() {
36-
return $this->createPreparable($this->db()->prepare($this), function () {
36+
return $this->createPreparable($this->db()->prepare($this), function() {
3737
return (int) $this->db()->getLastInsertId();
3838
});
3939
}

src/Builder/Select.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ class Select extends Statement {
3737
* @return $this
3838
*/
3939
public function field($expression, $alias = null) {
40-
if(is_object($expression)) {
40+
if (is_object($expression)) {
4141
$expression = (string) $expression;
4242
$expression = trim($expression);
4343
$expression = rtrim($expression, ';');
4444
$expression = trim($expression);
4545
$lines = explode("\n", $expression);
46-
$lines = array_map(function ($line) { return "\t\t{$line}"; }, $lines);
46+
$lines = array_map(function($line) { return "\t\t{$line}"; }, $lines);
4747
$expression = join("\n", $lines);
4848
$expression = sprintf("(\n%s\n\t)", $expression);
4949
}
50-
if($alias === null) {
50+
if ($alias === null) {
5151
$this->fields[] = $expression;
5252
} else {
5353
$this->fields[$alias] = $expression;
@@ -60,7 +60,7 @@ public function field($expression, $alias = null) {
6060
* @return $this
6161
*/
6262
public function fields(array $fields) {
63-
foreach($fields as $alias => $expression) {
63+
foreach ($fields as $alias => $expression) {
6464
$this->field($expression, $alias);
6565
}
6666
return $this;
@@ -95,7 +95,7 @@ public function getCalcFoundRows() {
9595
* @return $this
9696
*/
9797
public function setCalcFoundRows($calcFoundRows = true) {
98-
if(ini_get("mysql.trace_mode")) {
98+
if (ini_get("mysql.trace_mode")) {
9999
throw new \Exception('This function cant operate with mysql.trace_mode is set.');
100100
}
101101
$this->calcFoundRows = $calcFoundRows;
@@ -117,12 +117,12 @@ public function from($alias, $tableName = null) {
117117
*/
118118
public function __toString() {
119119
$query = "SELECT";
120-
if($this->calcFoundRows) {
120+
if ($this->calcFoundRows) {
121121
$query .= " SQL_CALC_FOUND_ROWS";
122122
}
123123
$query .= "\n";
124124
$query = $this->buildFields($query);
125-
if(count($this->getTables())) {
125+
if (count($this->getTables())) {
126126
$query .= "FROM\n";
127127
}
128128
$query = $this->buildTables($query);
@@ -144,9 +144,9 @@ public function __toString() {
144144
*/
145145
private function buildFields($query) {
146146
$fields = array();
147-
if(count($this->fields)) {
148-
foreach($this->fields as $alias => $expression) {
149-
if(is_numeric($alias)) {
147+
if (count($this->fields)) {
148+
foreach ($this->fields as $alias => $expression) {
149+
if (is_numeric($alias)) {
150150
$fields[] = "\t{$expression}";
151151
} else {
152152
$fields[] = "\t{$expression} AS `{$alias}`";
@@ -163,7 +163,7 @@ private function buildFields($query) {
163163
* @return string
164164
*/
165165
private function buildForUpdate($query) {
166-
if($this->forUpdate) {
166+
if ($this->forUpdate) {
167167
$query .= "FOR UPDATE\n";
168168
}
169169
return $query;

src/Builder/Statement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public function __construct(MySQL $db) {
2424
* @return $this
2525
*/
2626
public function debug($stop = true) {
27-
if(php_sapi_name() == 'cli') {
27+
if (php_sapi_name() == 'cli') {
2828
echo "\n{$this->__toString()}\n";
2929
} else {
3030
echo "<pre>{$this->__toString()}</pre>";
3131
}
32-
if($stop) {
32+
if ($stop) {
3333
exit;
3434
}
3535
return $this;

src/Builder/Update.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ public function setExpr($expr) {
7474
* @throws Exception
7575
*/
7676
public function setAll(array $data, array $allowedFields = null) {
77-
if($allowedFields !== null) {
78-
foreach($data as $fieldName => $value) {
79-
if(in_array($fieldName, $allowedFields)) {
77+
if ($allowedFields !== null) {
78+
foreach ($data as $fieldName => $value) {
79+
if (in_array($fieldName, $allowedFields)) {
8080
$this->set($fieldName, $value);
8181
}
8282
}
8383
} else {
8484
$values = $this->clearValues($data);
85-
foreach($values as $fieldName => $value) {
85+
foreach ($values as $fieldName => $value) {
8686
$this->set($fieldName, $value);
8787
}
8888
}
@@ -125,14 +125,14 @@ private function buildAssignments($query) {
125125
* @throws Exception
126126
*/
127127
private function clearValues(array $values) {
128-
if(!count($values)) {
128+
if (!count($values)) {
129129
return [];
130130
}
131131
$tables = $this->getTables();
132-
if(!count($tables)) {
132+
if (!count($tables)) {
133133
throw new Exception('Table name is missing');
134134
}
135-
if(count($tables) > 1) {
135+
if (count($tables) > 1) {
136136
throw new Exception('Batch values only work with max. one table');
137137
}
138138
list($table) = $tables;
@@ -142,7 +142,7 @@ private function clearValues(array $values) {
142142
$result = array();
143143

144144
foreach ($values as $fieldName => $fieldValue) {
145-
if(in_array($fieldName, $fields)) {
145+
if (in_array($fieldName, $fields)) {
146146
$result[$fieldName] = $fieldValue;
147147
}
148148
}

src/QueryLogger/QueryLoggers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function add(QueryLogger $queryLogger) {
2020
* @return $this
2121
*/
2222
public function log($query, $duration) {
23-
foreach($this->queryLoggers as $queryLogger) {
23+
foreach ($this->queryLoggers as $queryLogger) {
2424
$queryLogger->log($query, $duration);
2525
}
2626
return $this;

src/Tools/AliasRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function add($alias, $string) {
2323
* @return string
2424
*/
2525
public function get($alias) {
26-
if(!array_key_exists($alias, $this->aliases)) {
26+
if (!array_key_exists($alias, $this->aliases)) {
2727
throw new \Exception("Alias not found: {$alias}");
2828
}
2929
return $this->aliases[$alias];

src/Tools/AliasReplacer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public function __construct(AliasRegistry $aliasRegistry) {
1919
* @return string
2020
*/
2121
public function replace($name) {
22-
$fn = function ($values) {
22+
$fn = function($values) {
2323
$alias = $values[1];
2424
$part = $values[2];
2525
$string = $this->aliasRegistry->get($alias);
26-
return $string . $part;
26+
return $string.$part;
2727
};
2828
return preg_replace_callback('/^(\\w+)#(\\w+)$/', $fn, $name);
2929
}

0 commit comments

Comments
 (0)