Skip to content

Commit 6638122

Browse files
committed
improved coding style
1 parent fa9aa8a commit 6638122

File tree

84 files changed

+496
-493
lines changed

Some content is hidden

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

84 files changed

+496
-493
lines changed

src/Bridges/DatabaseTracy/ConnectionPanel.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace Nette\Bridges\DatabaseTracy;
99

10-
use Nette,
11-
Nette\Database\Helpers,
12-
Tracy;
10+
use Nette;
11+
use Nette\Database\Helpers;
12+
use Tracy;
1313

1414

1515
/**
@@ -126,7 +126,8 @@ public function getPanel()
126126
try {
127127
$cmd = is_string($this->explain) ? $this->explain : 'EXPLAIN';
128128
$explain = $connection->queryArgs("$cmd $sql", $params)->fetchAll();
129-
} catch (\PDOException $e) {}
129+
} catch (\PDOException $e) {
130+
}
130131
}
131132
$query[] = $explain;
132133
$queries[] = $query;

src/Database/Connection.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace Nette\Database;
99

10-
use Nette,
11-
PDO,
12-
PDOException;
10+
use Nette;
11+
use PDO;
12+
use PDOException;
1313

1414

1515
/**
@@ -23,10 +23,10 @@
2323
*/
2424
class Connection extends Nette\Object
2525
{
26-
/** @var callable[] function(Connection $connection); Occurs after connection is established */
26+
/** @var callable[] function (Connection $connection); Occurs after connection is established */
2727
public $onConnect;
2828

29-
/** @var callable[] function(Connection $connection, ResultSet|DriverException $result); Occurs after query is executed */
29+
/** @var callable[] function (Connection $connection, ResultSet|DriverException $result); Occurs after query is executed */
3030
public $onQuery;
3131

3232
/** @var array */
@@ -279,5 +279,4 @@ public static function literal($value)
279279
$args = func_get_args();
280280
return new SqlLiteral(array_shift($args), $args);
281281
}
282-
283282
}

src/Database/Context.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Database;
99

10-
use Nette,
11-
Nette\Database\Conventions\StaticConventions;
10+
use Nette;
11+
use Nette\Database\Conventions\StaticConventions;
1212

1313

1414
/**

src/Database/Helpers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Database;
99

10-
use Nette,
11-
Tracy;
10+
use Nette;
11+
use Tracy;
1212

1313

1414
/**
@@ -93,7 +93,7 @@ public static function dumpSql($sql, array $params = NULL, Connection $connectio
9393

9494
// syntax highlight
9595
$sql = htmlSpecialChars($sql, ENT_IGNORE, 'UTF-8');
96-
$sql = preg_replace_callback("#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])($keywords1)(?=[\\s,)])|(?<=[\\s,(=])($keywords2)(?=[\\s,)=])#is", function($matches) {
96+
$sql = preg_replace_callback("#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])($keywords1)(?=[\\s,)])|(?<=[\\s,(=])($keywords2)(?=[\\s,)=])#is", function ($matches) {
9797
if (!empty($matches[1])) { // comment
9898
return '<em style="color:gray">' . $matches[1] . '</em>';
9999

@@ -109,7 +109,7 @@ public static function dumpSql($sql, array $params = NULL, Connection $connectio
109109
}, $sql);
110110

111111
// parameters
112-
$sql = preg_replace_callback('#\?#', function() use ($params, $connection) {
112+
$sql = preg_replace_callback('#\?#', function () use ($params, $connection) {
113113
static $i = 0;
114114
if (!isset($params[$i])) {
115115
return '?';

src/Database/ResultSet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Database;
99

10-
use Nette,
11-
PDO;
10+
use Nette;
11+
use PDO;
1212

1313

1414
/**

src/Database/SqlPreprocessor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public function __construct(Connection $connection)
5050
public function process($params)
5151
{
5252
$this->params = $params;
53-
$this->counter = 0; $prev = -1;
53+
$this->counter = 0;
54+
$prev = -1;
5455
$this->remaining = [];
5556
$this->arrayMode = NULL;
5657
$res = [];
@@ -181,7 +182,7 @@ private function formatValue($value, $mode = NULL)
181182
}
182183
foreach ($value as $val) {
183184
$vx2 = [];
184-
foreach ($val as $v) {
185+
foreach ($val as $v) {
185186
$vx2[] = $this->formatValue($v);
186187
}
187188
$vx[] = implode(', ', $vx2);

src/Database/Structure.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function loadStructure()
193193

194194
if (isset($structure['hasMany'])) {
195195
foreach ($structure['hasMany'] as & $table) {
196-
uksort($table, function($a, $b) {
196+
uksort($table, function ($a, $b) {
197197
return strlen($a) - strlen($b);
198198
});
199199
}
@@ -230,7 +230,7 @@ protected function analyzeForeignKeys(& $structure, $table)
230230
}
231231

232232
if (isset($structure['belongsTo'][$table])) {
233-
uksort($structure['belongsTo'][$table], function($a, $b) {
233+
uksort($structure['belongsTo'][$table], function ($a, $b) {
234234
return strlen($a) - strlen($b);
235235
});
236236
}

src/Database/Table/GroupedSelection.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace Nette\Database\Table;
99

10-
use Nette,
11-
Nette\Database\Context,
12-
Nette\Database\IConventions;
10+
use Nette;
11+
use Nette\Database\Context;
12+
use Nette\Database\IConventions;
1313

1414

1515
/**
@@ -180,7 +180,7 @@ protected function getRefTable(& $refPath)
180180
{
181181
$refObj = $this->refTable;
182182
$refPath = $this->name . '.';
183-
while ($refObj instanceof GroupedSelection) {
183+
while ($refObj instanceof self) {
184184
$refPath .= $refObj->name . '.';
185185
$refObj = $refObj->refTable;
186186
}
@@ -193,11 +193,11 @@ protected function loadRefCache()
193193
{
194194
$hash = $this->getSpecificCacheKey();
195195
$referencing = & $this->refCache['referencing'][$this->getGeneralCacheKey()];
196-
$this->observeCache = & $referencing['observeCache'];
197-
$this->refCacheCurrent = & $referencing[$hash];
198-
$this->accessedColumns = & $referencing[$hash]['accessed'];
199-
$this->specificCacheKey = & $referencing[$hash]['specificCacheKey'];
200-
$this->rows = & $referencing[$hash]['rows'];
196+
$this->observeCache = & $referencing['observeCache'];
197+
$this->refCacheCurrent = & $referencing[$hash];
198+
$this->accessedColumns = & $referencing[$hash]['accessed'];
199+
$this->specificCacheKey = & $referencing[$hash]['specificCacheKey'];
200+
$this->rows = & $referencing[$hash]['rows'];
201201

202202
if (isset($referencing[$hash]['data'][$this->active])) {
203203
$this->data = & $referencing[$hash]['data'][$this->active];

src/Database/Table/Selection.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace Nette\Database\Table;
99

10-
use Nette,
11-
Nette\Database\Context,
12-
Nette\Database\IConventions;
10+
use Nette;
11+
use Nette\Database\Context;
12+
use Nette\Database\IConventions;
1313

1414

1515
/**
@@ -510,7 +510,7 @@ protected function createRow(array $row)
510510

511511
public function createSelectionInstance($table = NULL)
512512
{
513-
return new Selection($this->context, $this->conventions, $table ?: $this->name, $this->cache ? $this->cache->getStorage() : NULL);
513+
return new self($this->context, $this->conventions, $table ?: $this->name, $this->cache ? $this->cache->getStorage() : NULL);
514514
}
515515

516516

@@ -708,7 +708,7 @@ public function getDataRefreshed()
708708
*/
709709
public function insert($data)
710710
{
711-
if ($data instanceof Selection) {
711+
if ($data instanceof self) {
712712
$return = $this->context->queryArgs($this->sqlBuilder->buildInsertQuery() . ' ' . $data->getSql(), $data->getSqlBuilder()->getParameters());
713713

714714
} else {
@@ -720,7 +720,7 @@ public function insert($data)
720720

721721
$this->loadRefCache();
722722

723-
if ($data instanceof Selection || $this->primary === NULL) {
723+
if ($data instanceof self || $this->primary === NULL) {
724724
unset($this->refCache['referencing'][$this->getGeneralCacheKey()][$this->getSpecificCacheKey()]);
725725
return $return->getRowCount();
726726
}

src/Database/Table/SqlBuilder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
namespace Nette\Database\Table;
99

10-
use Nette,
11-
Nette\Database\ISupplementalDriver,
12-
Nette\Database\SqlLiteral,
13-
Nette\Database\IConventions,
14-
Nette\Database\Context,
15-
Nette\Database\IStructure;
10+
use Nette;
11+
use Nette\Database\ISupplementalDriver;
12+
use Nette\Database\SqlLiteral;
13+
use Nette\Database\IConventions;
14+
use Nette\Database\Context;
15+
use Nette\Database\IStructure;
1616

1717

1818
/**
@@ -129,7 +129,7 @@ public function buildDeleteQuery()
129129
public function buildSelectQuery($columns = NULL)
130130
{
131131
$queryCondition = $this->buildConditions();
132-
$queryEnd = $this->buildQueryEnd();
132+
$queryEnd = $this->buildQueryEnd();
133133

134134
$joins = [];
135135
$this->parseJoins($joins, $queryCondition);
@@ -416,7 +416,7 @@ protected function parseJoins(& $joins, & $query)
416416
(?P<node> (?&del)? (?&word) (\((?&word)\))? )
417417
)
418418
(?P<chain> (?!\.) (?&node)*) \. (?P<column> (?&word) | \* )
419-
~xi', function($match) use (& $joins, $builder) {
419+
~xi', function ($match) use (& $joins, $builder) {
420420
return $builder->parseJoinsCb($joins, $match);
421421
}, $query);
422422
}
@@ -543,7 +543,7 @@ protected function buildQueryEnd()
543543
protected function tryDelimite($s)
544544
{
545545
$driver = $this->driver;
546-
return preg_replace_callback('#(?<=[^\w`"\[?]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|\z)#i', function($m) use ($driver) {
546+
return preg_replace_callback('#(?<=[^\w`"\[?]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|\z)#i', function ($m) use ($driver) {
547547
return strtoupper($m[0]) === $m[0] ? $m[0] : $driver->delimite($m[0]);
548548
}, $s);
549549
}

0 commit comments

Comments
 (0)