Skip to content

Commit 6264bea

Browse files
committed
coding style: TRUE/FALSE/NULL -> true/false/null
1 parent 9d526a7 commit 6264bea

File tree

71 files changed

+602
-602
lines changed

Some content is hidden

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

71 files changed

+602
-602
lines changed

src/Bridges/DatabaseDI/DatabaseExtension.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
class DatabaseExtension extends Nette\DI\CompilerExtension
1919
{
2020
public $databaseDefaults = [
21-
'dsn' => NULL,
22-
'user' => NULL,
23-
'password' => NULL,
24-
'options' => NULL,
25-
'debugger' => TRUE,
26-
'explain' => TRUE,
27-
'reflection' => NULL, // BC
21+
'dsn' => null,
22+
'user' => null,
23+
'password' => null,
24+
'options' => null,
25+
'debugger' => true,
26+
'explain' => true,
27+
'reflection' => null, // BC
2828
'conventions' => 'discovered', // Nette\Database\Conventions\DiscoveredConventions
29-
'autowired' => NULL,
29+
'autowired' => null,
3030
];
3131

3232
/** @var bool */
3333
private $debugMode;
3434

3535

36-
public function __construct(bool $debugMode = FALSE)
36+
public function __construct(bool $debugMode = false)
3737
{
3838
$this->debugMode = $debugMode;
3939
}
@@ -50,13 +50,13 @@ public function loadConfiguration()
5050
}
5151

5252
$defaults = $this->databaseDefaults;
53-
$defaults['autowired'] = TRUE;
53+
$defaults['autowired'] = true;
5454
foreach ((array) $configs as $name => $config) {
5555
if (!is_array($config)) {
5656
continue;
5757
}
5858
$config = $this->validateConfig($defaults, $config, $this->prefix($name));
59-
$defaults['autowired'] = FALSE;
59+
$defaults['autowired'] = false;
6060
$this->setupDatabase($config, $name);
6161
}
6262
}
@@ -96,7 +96,7 @@ private function setupDatabase($config, $name): void
9696
}
9797

9898
if (!$config['conventions']) {
99-
$conventions = NULL;
99+
$conventions = null;
100100

101101
} elseif (is_string($config['conventions'])) {
102102
$conventions = $builder->addDefinition($this->prefix("$name.$conventionsServiceName"))

src/Bridges/DatabaseTracy/ConnectionPanel.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class ConnectionPanel implements Tracy\IBarPanel
3737
public $name;
3838

3939
/** @var bool|string explain queries? */
40-
public $explain = TRUE;
40+
public $explain = true;
4141

4242
/** @var bool */
43-
public $disabled = FALSE;
43+
public $disabled = false;
4444

4545

4646
public function __construct(Nette\Database\Connection $connection)
@@ -56,7 +56,7 @@ public function logQuery(Nette\Database\Connection $connection, $result): void
5656
}
5757
$this->count++;
5858

59-
$source = NULL;
59+
$source = null;
6060
$trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
6161
foreach ($trace as $row) {
6262
if (isset($row['file']) && is_file($row['file']) && !Tracy\Debugger::getBluescreen()->isCollapsed($row['file'])) {
@@ -72,19 +72,19 @@ public function logQuery(Nette\Database\Connection $connection, $result): void
7272
if ($result instanceof Nette\Database\ResultSet) {
7373
$this->totalTime += $result->getTime();
7474
if ($this->count < $this->maxQueries) {
75-
$this->queries[] = [$connection, $result->getQueryString(), $result->getParameters(), $source, $result->getTime(), $result->getRowCount(), NULL];
75+
$this->queries[] = [$connection, $result->getQueryString(), $result->getParameters(), $source, $result->getTime(), $result->getRowCount(), null];
7676
}
7777

7878
} elseif ($result instanceof \PDOException && $this->count < $this->maxQueries) {
79-
$this->queries[] = [$connection, $result->queryString, NULL, $source, NULL, NULL, $result->getMessage()];
79+
$this->queries[] = [$connection, $result->queryString, null, $source, null, null, $result->getMessage()];
8080
}
8181
}
8282

8383

8484
public static function renderException($e): ?array
8585
{
8686
if (!$e instanceof \PDOException) {
87-
return NULL;
87+
return null;
8888
}
8989
if (isset($e->queryString)) {
9090
$sql = $e->queryString;
@@ -95,7 +95,7 @@ public static function renderException($e): ?array
9595
return isset($sql) ? [
9696
'tab' => 'SQL',
9797
'panel' => Helpers::dumpSql($sql),
98-
] : NULL;
98+
] : null;
9999
}
100100

101101

@@ -112,9 +112,9 @@ public function getTab(): string
112112

113113
public function getPanel(): ?string
114114
{
115-
$this->disabled = TRUE;
115+
$this->disabled = true;
116116
if (!$this->count) {
117-
return NULL;
117+
return null;
118118
}
119119

120120
$name = $this->name;
@@ -123,7 +123,7 @@ public function getPanel(): ?string
123123
$queries = [];
124124
foreach ($this->queries as $query) {
125125
[$connection, $sql, $params, $source, $time, $rows, $error] = $query;
126-
$explain = NULL;
126+
$explain = null;
127127
if (!$error && $this->explain && preg_match('#\s*\(?\s*SELECT\s#iA', $sql)) {
128128
try {
129129
$cmd = is_string($this->explain) ? $this->explain : 'EXPLAIN';

src/Bridges/DatabaseTracy/templates/ConnectionPanel.panel.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use Tracy;
2626
<td>
2727
<?php if ($error): ?>
2828
<span title="<?= htmlSpecialChars($error, ENT_IGNORE | ENT_QUOTES, 'UTF-8') ?>">ERROR</span>
29-
<?php elseif ($time !== NULL): echo sprintf('%0.3f', $time * 1000); endif ?>
29+
<?php elseif ($time !== null): echo sprintf('%0.3f', $time * 1000); endif ?>
3030
<?php if ($explain): ?>
3131
<br /><a class="tracy-toggle tracy-collapsed" data-tracy-ref="^tr .nette-DbConnectionPanel-explain">explain</a>
3232
<?php endif ?>

src/Database/Connection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Connection
4343
private $pdo;
4444

4545

46-
public function __construct($dsn, $user = NULL, $password = NULL, array $options = NULL)
46+
public function __construct($dsn, $user = null, $password = null, array $options = null)
4747
{
4848
$this->params = [$dsn, $user, $password];
4949
$this->options = (array) $options;
@@ -86,7 +86,7 @@ public function reconnect(): void
8686

8787
public function disconnect(): void
8888
{
89-
$this->pdo = NULL;
89+
$this->pdo = null;
9090
}
9191

9292

@@ -113,11 +113,11 @@ public function getSupplementalDriver(): ISupplementalDriver
113113
/**
114114
* @param string sequence object
115115
*/
116-
public function getInsertId(string $name = NULL): string
116+
public function getInsertId(string $name = null): string
117117
{
118118
try {
119119
$res = $this->getPdo()->lastInsertId($name);
120-
return $res === FALSE ? '0' : $res;
120+
return $res === false ? '0' : $res;
121121
} catch (PDOException $e) {
122122
throw $this->driver->convertException($e);
123123
}

src/Database/Context.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Context
3333
private $cacheStorage;
3434

3535

36-
public function __construct(Connection $connection, IStructure $structure, IConventions $conventions = NULL, Nette\Caching\IStorage $cacheStorage = NULL)
36+
public function __construct(Connection $connection, IStructure $structure, IConventions $conventions = null, Nette\Caching\IStorage $cacheStorage = null)
3737
{
3838
$this->connection = $connection;
3939
$this->structure = $structure;
@@ -63,7 +63,7 @@ public function rollBack(): void
6363
/**
6464
* @param string sequence object
6565
*/
66-
public function getInsertId(string $name = NULL): string
66+
public function getInsertId(string $name = null): string
6767
{
6868
return $this->connection->getInsertId($name);
6969
}

src/Database/Conventions/DiscoveredConventions.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public function getHasManyReference(string $nsTable, string $key): ?array
4242

4343
foreach ($targets as $targetNsTable => $targetColumns) {
4444
$targetTable = preg_replace('#^(.*\.)?(.*)$#', '$2', $targetNsTable);
45-
if (stripos($targetNsTable, $key) === FALSE) {
45+
if (stripos($targetNsTable, $key) === false) {
4646
continue;
4747
}
4848

4949
foreach ($targetColumns as $targetColumn) {
50-
if (stripos($targetColumn, $table) !== FALSE) {
50+
if (stripos($targetColumn, $table) !== false) {
5151
$columnCandidates[] = $candidate = [$targetNsTable, $targetColumn];
5252
if (strcmp($targetTable, $key) === 0 || strcmp($targetNsTable, $key) === 0) {
5353
return $candidate;
@@ -75,7 +75,7 @@ public function getHasManyReference(string $nsTable, string $key): ?array
7575
}
7676

7777
if ($this->structure->isRebuilt()) {
78-
return NULL;
78+
return null;
7979
}
8080

8181
$this->structure->rebuild();
@@ -88,13 +88,13 @@ public function getBelongsToReference(string $table, string $key): ?array
8888
$tableColumns = $this->structure->getBelongsToReference($table);
8989

9090
foreach ($tableColumns as $column => $targetTable) {
91-
if (stripos($column, $key) !== FALSE) {
91+
if (stripos($column, $key) !== false) {
9292
return [$targetTable, $column];
9393
}
9494
}
9595

9696
if ($this->structure->isRebuilt()) {
97-
return NULL;
97+
return null;
9898
}
9999

100100
$this->structure->rebuild();

src/Database/DriverException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ public static function from(\PDOException $src)
3838

3939

4040
/**
41-
* @return int|string|NULL Driver-specific error code
41+
* @return int|string|null Driver-specific error code
4242
*/
4343
public function getDriverCode()
4444
{
45-
return $this->errorInfo[1] ?? NULL;
45+
return $this->errorInfo[1] ?? null;
4646
}
4747

4848

4949
/**
50-
* @return string|NULL SQLSTATE error code
50+
* @return string|null SQLSTATE error code
5151
*/
5252
public function getSqlState(): ?string
5353
{
54-
return $this->errorInfo[0] ?? NULL;
54+
return $this->errorInfo[0] ?? null;
5555
}
5656

5757

5858
/**
59-
* @return string|NULL SQL command
59+
* @return string|null SQL command
6060
*/
6161
public function getQueryString(): ?string
6262
{

src/Database/Drivers/MsSqlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset): void
8282
} elseif ($limit < 0) {
8383
throw new Nette\InvalidArgumentException('Negative offset or limit.');
8484

85-
} elseif ($limit !== NULL) {
85+
} elseif ($limit !== null) {
8686
$sql = preg_replace('#^\s*(SELECT(\s+DISTINCT|\s+ALL)?|UPDATE|DELETE)#i', '$0 TOP ' . (int) $limit, $sql, 1, $count);
8787
if (!$count) {
8888
throw new Nette\InvalidArgumentException('SQL query must begin with SELECT, UPDATE or DELETE command.');

src/Database/Drivers/MySqlDriver.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ public function initialize(Nette\Database\Connection $connection, array $options
4949

5050
public function convertException(\PDOException $e): Nette\Database\DriverException
5151
{
52-
$code = $e->errorInfo[1] ?? NULL;
53-
if (in_array($code, [1216, 1217, 1451, 1452, 1701], TRUE)) {
52+
$code = $e->errorInfo[1] ?? null;
53+
if (in_array($code, [1216, 1217, 1451, 1452, 1701], true)) {
5454
return Nette\Database\ForeignKeyConstraintViolationException::from($e);
5555

56-
} elseif (in_array($code, [1062, 1557, 1569, 1586], TRUE)) {
56+
} elseif (in_array($code, [1062, 1557, 1569, 1586], true)) {
5757
return Nette\Database\UniqueConstraintViolationException::from($e);
5858

5959
} elseif ($code >= 2001 && $code <= 2028) {
6060
return Nette\Database\ConnectionException::from($e);
6161

62-
} elseif (in_array($code, [1048, 1121, 1138, 1171, 1252, 1263, 1566], TRUE)) {
62+
} elseif (in_array($code, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) {
6363
return Nette\Database\NotNullConstraintViolationException::from($e);
6464

6565
} else {
@@ -118,9 +118,9 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset): void
118118
if ($limit < 0 || $offset < 0) {
119119
throw new Nette\InvalidArgumentException('Negative offset or limit.');
120120

121-
} elseif ($limit !== NULL || $offset) {
121+
} elseif ($limit !== null || $offset) {
122122
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
123-
$sql .= ' LIMIT ' . ($limit === NULL ? '18446744073709551615' : $limit)
123+
$sql .= ' LIMIT ' . ($limit === null ? '18446744073709551615' : $limit)
124124
. ($offset ? ' OFFSET ' . $offset : '');
125125
}
126126
}
@@ -138,7 +138,7 @@ public function getTables(): array
138138
foreach ($this->connection->query('SHOW FULL TABLES') as $row) {
139139
$tables[] = [
140140
'name' => $row[0],
141-
'view' => ($row[1] ?? NULL) === 'VIEW',
141+
'view' => ($row[1] ?? null) === 'VIEW',
142142
];
143143
}
144144
return $tables;
@@ -157,7 +157,7 @@ public function getColumns(string $table): array
157157
'name' => $row['Field'],
158158
'table' => $table,
159159
'nativetype' => strtoupper($type[0]),
160-
'size' => isset($type[1]) ? (int) $type[1] : NULL,
160+
'size' => isset($type[1]) ? (int) $type[1] : null,
161161
'unsigned' => (bool) strstr($row['Type'], 'unsigned'),
162162
'nullable' => $row['Null'] === 'YES',
163163
'default' => $row['Default'],

src/Database/Drivers/OciDriver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ public function initialize(Nette\Database\Connection $connection, array $options
3535

3636
public function convertException(\PDOException $e): Nette\Database\DriverException
3737
{
38-
$code = $e->errorInfo[1] ?? NULL;
39-
if (in_array($code, [1, 2299, 38911], TRUE)) {
38+
$code = $e->errorInfo[1] ?? null;
39+
if (in_array($code, [1, 2299, 38911], true)) {
4040
return Nette\Database\UniqueConstraintViolationException::from($e);
4141

42-
} elseif (in_array($code, [1400], TRUE)) {
42+
} elseif (in_array($code, [1400], true)) {
4343
return Nette\Database\NotNullConstraintViolationException::from($e);
4444

45-
} elseif (in_array($code, [2266, 2291, 2292], TRUE)) {
45+
} elseif (in_array($code, [2266, 2291, 2292], true)) {
4646
return Nette\Database\ForeignKeyConstraintViolationException::from($e);
4747

4848
} else {
@@ -102,10 +102,10 @@ public function applyLimit(string &$sql, ?int $limit, ?int $offset): void
102102
} elseif ($offset) {
103103
// see http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
104104
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
105-
. ($limit !== NULL ? 'WHERE ROWNUM <= ' . ($offset + $limit) : '')
105+
. ($limit !== null ? 'WHERE ROWNUM <= ' . ($offset + $limit) : '')
106106
. ') WHERE "__rnum" > ' . $offset;
107107

108-
} elseif ($limit !== NULL) {
108+
} elseif ($limit !== null) {
109109
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . $limit;
110110
}
111111
}

0 commit comments

Comments
 (0)