Skip to content

Commit 661abda

Browse files
author
Afonso Gloeden
committed
Lines less than 80 characters (PSR-2)
1 parent d710f5b commit 661abda

File tree

5 files changed

+154
-39
lines changed

5 files changed

+154
-39
lines changed

Database/Query/SybaseGrammar.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ protected function compileColumns(Builder $query, $columns)
5252

5353
$select = $query->distinct ? 'select distinct ' : 'select ';
5454

55-
// If there is a limit on the query, but not an offset, we will add the top
56-
// clause to the query, which serves as a "limit" type clause within the
57-
// SQL Server system similar to the limit keywords available in MySQL.
55+
// If there is a limit on the query, but not an offset, we will add the
56+
// top clause to the query, which serves as a "limit" type clause
57+
// within the SQL Server system similar to the limit keywords available
58+
// in MySQL.
5859
if ($query->limit > 0 && $query->offset <= 0) {
5960
$select .= 'top ' . $query->limit . ' ';
6061
}
@@ -78,7 +79,8 @@ protected function compileFrom(Builder $query, $table)
7879
}
7980

8081
if (!is_null($query->lock)) {
81-
return $from . ' with(rowlock,' . ($query->lock ? 'updlock,' : '') . 'holdlock)';
82+
return $from . ' with(rowlock,' .
83+
($query->lock ? 'updlock,' : '') . 'holdlock)';
8284
}
8385

8486
return $from;

Database/Schema/BlueprintSybase.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ class BlueprintSybase extends Blueprint
88
{
99
public function numeric($column, $total = 8, $autoIncrement = false)
1010
{
11-
return $this->addColumn('numeric', $column, compact('total', 'autoIncrement'));
11+
return $this->addColumn(
12+
'numeric',
13+
$column,
14+
compact(
15+
'total',
16+
'autoIncrement'
17+
)
18+
);
1219
}
1320
}

Database/Schema/SybaseGrammar.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ public function compilePrimary(Blueprint $blueprint, Fluent $command)
106106

107107
$table = $this->wrapTable($blueprint);
108108

109-
return "ALTER TABLE {$table} ADD CONSTRAINT {$command->index} PRIMARY KEY ({$columns})";
109+
return "
110+
ALTER TABLE {$table}
111+
ADD CONSTRAINT {$command->index}
112+
PRIMARY KEY ({$columns})";
110113
}
111114

112115
/**
@@ -186,7 +189,8 @@ public function compileDropColumn(Blueprint $blueprint, Fluent $command)
186189

187190
$table = $this->wrapTable($blueprint);
188191

189-
return 'ALTER TABLE ' . $table . ' DROP COLUMN ' . implode(', ', $columns);
192+
return 'ALTER TABLE ' . $table .
193+
' DROP COLUMN ' . implode(', ', $columns);
190194
}
191195

192196
/**
@@ -582,7 +586,10 @@ protected function modifyDefault(Blueprint $blueprint, Fluent $column)
582586
*/
583587
protected function modifyIncrement(Blueprint $blueprint, Fluent $column)
584588
{
585-
if (in_array($column->type, $this->serials) && $column->autoIncrement) {
589+
if (
590+
in_array($column->type, $this->serials) &&
591+
$column->autoIncrement
592+
) {
586593
return ' identity primary key';
587594
}
588595
}

Database/SybaseConnection.php

+108-27
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ private function compileForSelect(Builder $builder, $bindings) {
117117
}
118118
$newFormat = [];
119119
foreach ($arrTables as $tables) {
120-
preg_match("/(?:(?'table'.*)(?: as )(?'alias'.*))|(?'tables'.*)/", $tables, $alias);
120+
preg_match(
121+
"/(?:(?'table'.*)(?: as )(?'alias'.*))|(?'tables'.*)/",
122+
$tables,
123+
$alias
124+
);
121125
if (empty($alias['alias'])) {
122126
$tables = $alias['tables'];
123127
} else {
@@ -132,7 +136,9 @@ private function compileForSelect(Builder $builder, $bindings) {
132136
$tipos[strtolower($tables . '.' . $row['name'])] = $row['type'];
133137

134138
if (!empty($alias['alias'])) {
135-
$tipos[strtolower($alias['alias'] . '.' . $row['name'])] = $row['type'];
139+
$tipos[
140+
strtolower($alias['alias'] . '.' . $row['name'])
141+
] = $row['type'];
136142
}
137143
}
138144

@@ -153,9 +159,19 @@ private function compileForSelect(Builder $builder, $bindings) {
153159
$wheresCount = count($wheres);
154160

155161
for ($ind = 0; $ind < $wheresCount; $ind++) {
156-
if (isset($wheres[$ind]['value']) && isset($tipos[strtolower($wheres[$ind]['column'])])) {
162+
if (
163+
isset($wheres[$ind]['value']) &&
164+
isset($tipos[strtolower($wheres[$ind]['column'])])
165+
) {
157166
if (is_object($wheres[$ind]['value']) === false) {
158-
if (in_array(strtolower($tipos[strtolower($wheres[$ind]['column'])]), $this->withoutQuotes)) {
167+
if (
168+
in_array(
169+
strtolower($tipos[
170+
strtolower($wheres[$ind]['column'])
171+
]),
172+
$this->withoutQuotes
173+
)
174+
) {
159175
if (!is_null($bindings[$i])) {
160176
$newBinds[$i] = $bindings[$i] / 1;
161177
} else {
@@ -179,7 +195,14 @@ private function compileForSelect(Builder $builder, $bindings) {
179195
for ($ind = 0; $ind < $wheresCount; $ind++) {
180196
if (isset($wheres[$ind]['value'])) {
181197
if (is_object($wheres[$ind]['value']) === false) {
182-
if (in_array(strtolower($tipos[strtolower($wheres[$ind]['column'])]), $this->withoutQuotes)) {
198+
if (
199+
in_array(
200+
strtolower($tipos[
201+
strtolower($wheres[$ind]['column'])
202+
]),
203+
$this->withoutQuotes
204+
)
205+
) {
183206
if (!is_null($bindings[$i])) {
184207
$newBinds[$i] = $bindings[$i] / 1;
185208
} else {
@@ -277,20 +300,35 @@ private function compileBindings($query, $bindings)
277300
return $bindings;
278301
}
279302
case "insert":
280-
preg_match("/(?'tables'.*) \((?'attributes'.*)\) values/i", $query, $matches);
303+
preg_match(
304+
"/(?'tables'.*) \((?'attributes'.*)\) values/i",
305+
$query,
306+
$matches
307+
);
281308
break;
282309
case "update":
283-
preg_match("/(?'tables'.*) set (?'attributes'.*)/i", $query, $matches);
310+
preg_match(
311+
"/(?'tables'.*) set (?'attributes'.*)/i",
312+
$query,
313+
$matches
314+
);
284315
break;
285316
case "delete":
286-
preg_match("/(?'tables'.*) where (?'attributes'.*)/i", $query, $matches);
317+
preg_match(
318+
"/(?'tables'.*) where (?'attributes'.*)/i",
319+
$query,
320+
$matches
321+
);
287322
break;
288323
default:
289324
return $bindings;
290325
break;
291326
}
292327

293-
$desQuery = array_intersect_key($matches, array_flip(array_filter(array_keys($matches), 'is_string')));
328+
$desQuery = array_intersect_key(
329+
$matches,
330+
array_flip(array_filter(array_keys($matches), 'is_string'))
331+
);
294332

295333
if (is_array($desQuery['tables'])) {
296334
$desQuery['tables'] = implode($desQuery['tables'], ' ');
@@ -302,7 +340,11 @@ private function compileBindings($query, $bindings)
302340
unset($matches);
303341
unset($queryType);
304342
preg_match_all("/\[([^\]]*)\]/", $desQuery['attributes'], $arrQuery);
305-
preg_match_all("/\[([^\]]*)\]/", str_replace("].[].[", '..', $desQuery['tables']), $arrTables);
343+
preg_match_all(
344+
"/\[([^\]]*)\]/",
345+
str_replace("].[].[", '..', $desQuery['tables']),
346+
$arrTables
347+
);
306348

307349
$arrQuery = $arrQuery[1];
308350
$arrTables = $arrTables[1];
@@ -323,10 +365,14 @@ private function compileBindings($query, $bindings)
323365
$table = $campos;
324366
}
325367
if (!array_key_exists($table, $newFormat)) {
326-
$queryRes = $this->getPdo()->query($this->queryStringForCompileBindings($table));
368+
$queryRes = $this->getPdo()->query(
369+
$this->queryStringForCompileBindings($table)
370+
);
327371
$types[$table] = $queryRes->fetchAll(\PDO::FETCH_ASSOC);
328372
for ($k = 0; $k < count($types[$table]); $k++) {
329-
$types[$table][$types[$table][$k]['name']] = $types[$table][$k];
373+
$types[$table][
374+
$types[$table][$k]['name']
375+
] = $types[$table][$k];
330376
unset($types[$table][$k]);
331377
}
332378
$newFormat[$table] = [];
@@ -335,8 +381,18 @@ private function compileBindings($query, $bindings)
335381

336382
if (!$itsTable) {
337383
if (count($bindings) > $ind) {
338-
array_push($newFormat[$table], ['campo' => $campos, 'binding' => $ind]);
339-
if (in_array(strtolower($types[$table][$campos]['type']), $this->withoutQuotes)) {
384+
array_push(
385+
$newFormat[$table], [
386+
'campo' => $campos,
387+
'binding' => $ind
388+
]
389+
);
390+
if (
391+
in_array(
392+
strtolower($types[$table][$campos]['type']),
393+
$this->withoutQuotes
394+
)
395+
) {
340396
if (!is_null($bindings[$ind])) {
341397
$newBinds[$ind] = $bindings[$ind] / 1;
342398
} else {
@@ -413,9 +469,11 @@ private function queryStringForCompileBindings($table)
413469

414470
/**
415471
* Set new bindings with specified column types to Sybase.
416-
* Poderia compilar novamente dos bindings usando os PDO::PARAM, porém, não tem nenhuma constante que lide
417-
* com decimais, logo, a única maneira seria colocando PDO::PARAM_STR, que colocaria plicas.
418-
* Detalhes: http://stackoverflow.com/questions/2718628/pdoparam-for-type-decimal
472+
* Poderia compilar novamente dos bindings usando os PDO::PARAM, porém,
473+
* não tem nenhuma constante que lide com decimais, logo, a única maneira
474+
* seria colocando PDO::PARAM_STR, que colocaria plicas.
475+
* Detalhes:
476+
* http://stackoverflow.com/questions/2718628/pdoparam-for-type-decimal
419477
*
420478
* @param string $query
421479
* @param array $bindings
@@ -453,22 +511,33 @@ public function compileOffset($offset, $query, $bindings = array(), $me)
453511
$limit = 999999999999999999999999999;
454512
}
455513
$queryString = $this->queryStringForIdentity($from);
456-
$identity = $this->getPdo()->query($queryString)->fetchAll($me->getFetchMode())[0];
514+
$identity = $this->getPdo()->query($queryString)->fetchAll(
515+
$me->getFetchMode()
516+
)[0];
457517

458518
if (count($identity) === 0) {
459519
$queryString = $this->queryStringForPrimaries($from);
460-
$primaries = $this->getPdo()->query($queryString)->fetchAll($me->getFetchMode());
520+
$primaries = $this->getPdo()->query($queryString)->fetchAll(
521+
$me->getFetchMode()
522+
);
461523
foreach ($primaries as $primary) {
462-
$newArr[] = $primary->primary_key . '+0 AS ' . $primary->primary_key;
463-
$whereArr[] = "#tmpPaginate." . $primary->primary_key . ' = #tmpTable.' . $primary->primary_key;
524+
$newArr[] = $primary->primary_key . '+0 AS ' .
525+
$primary->primary_key;
526+
$whereArr[] = "#tmpPaginate." . $primary->primary_key .
527+
' = #tmpTable.' . $primary->primary_key;
464528
}
465529
$resPrimaries = implode(', ', $newArr);
466530
$wherePrimaries = implode(' AND ', $whereArr);
467531
} else {
468532
$resPrimaries = $identity->column . '+0 AS ' . $identity->column;
469-
$wherePrimaries = "#tmpPaginate." . $identity->column . ' = #tmpTable.' . $identity->column;
533+
$wherePrimaries = "#tmpPaginate." . $identity->column .
534+
' = #tmpTable.' . $identity->column;
470535
// Offset operation
471-
$this->getPdo()->query(str_replace(" from ", " into #tmpPaginate from ", $this->compileNewQuery($query, $bindings)));
536+
$this->getPdo()->query(str_replace(
537+
" from ",
538+
" into #tmpPaginate from ",
539+
$this->compileNewQuery($query, $bindings)
540+
));
472541
$this->getPdo()->query("
473542
SELECT
474543
" . $resPrimaries . ",
@@ -569,7 +638,10 @@ private function queryStringForPrimaries($from)
569638
*/
570639
public function select($query, $bindings = array(), $useReadPdo = true)
571640
{
572-
return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
641+
return $this->run($query, $bindings, function (
642+
$query,
643+
$bindings
644+
) use ($useReadPdo) {
573645
if ($this->pretending()) {
574646
return [];
575647
}
@@ -584,7 +656,10 @@ public function select($query, $bindings = array(), $useReadPdo = true)
584656
return $this->compileOffset($offset, $query, $bindings, $this);
585657
} else {
586658
$result = [];
587-
$statement = $this->getPdo()->query($this->compileNewQuery($query, $bindings));
659+
$statement = $this->getPdo()->query($this->compileNewQuery(
660+
$query,
661+
$bindings
662+
));
588663
do {
589664
$result += $statement->fetchAll($this->getFetchMode());
590665
} while ($statement->nextRowset());
@@ -604,7 +679,10 @@ public function statement($query, $bindings = array())
604679
if ($this->pretending()) {
605680
return true;
606681
}
607-
return $this->getPdo()->query($this->compileNewQuery($query, $bindings));
682+
return $this->getPdo()->query($this->compileNewQuery(
683+
$query,
684+
$bindings
685+
));
608686
});
609687
}
610688

@@ -614,7 +692,10 @@ public function affectingStatement($query, $bindings = [])
614692
if ($this->pretending()) {
615693
return 0;
616694
}
617-
return $this->getPdo()->query($this->compileNewQuery($query, $bindings))->rowCount();
695+
return $this->getPdo()->query($this->compileNewQuery(
696+
$query,
697+
$bindings
698+
))->rowCount();
618699
});
619700
}
620701

Database/SybaseServiceProvider.php

+22-4
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,35 @@ class SybaseServiceProvider extends ServiceProvider
1616
*/
1717
public function register()
1818
{
19-
Connection::resolverFor('sqlsrv', function ($connection, $database, $prefix, $config) {
20-
return new SybaseConnection($connection, $database, $prefix, $config);
19+
Connection::resolverFor('sqlsrv', function (
20+
$connection,
21+
$database,
22+
$prefix,
23+
$config
24+
) {
25+
return new SybaseConnection(
26+
$connection,
27+
$database,
28+
$prefix,
29+
$config
30+
);
2131
});
2232

2333
$this->app->bind('db.connector.sqlsrv', function ($app) {
2434
return new SybaseConnector();
2535
});
2636

27-
// $this->app->bind('db.connection.sqlsrv', function ($app, $parameters) {
37+
// $this->app->bind('db.connection.sqlsrv', function (
38+
// $app,
39+
// $parameters
40+
// ) {
2841
// list($connection, $database, $prefix, $config) = $parameters;
29-
// return new SybaseConnection($connection, $database, $prefix, $config);
42+
// return new SybaseConnection(
43+
// $connection,
44+
// $database,
45+
// $prefix,
46+
// $config
47+
// );
3048
// });
3149
}
3250
}

0 commit comments

Comments
 (0)