Skip to content

Commit bbeef6e

Browse files
committed
strict type fixes
1 parent 6b7e059 commit bbeef6e

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/Database/DriverException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DriverException extends \PDOException
2222
*/
2323
public static function from(\PDOException $src)
2424
{
25-
$e = new static($src->message, NULL, $src);
25+
$e = new static($src->message, 0, $src);
2626
if (!$src->errorInfo && preg_match('#SQLSTATE\[(.*?)\] \[(.*?)\] (.*)#A', $src->message, $m)) {
2727
$m[2] = (int) $m[2];
2828
$e->errorInfo = array_slice($m, 1);

src/Database/Drivers/SqliteDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function getColumns($table)
189189
'unsigned' => FALSE,
190190
'nullable' => $row['notnull'] == '0',
191191
'default' => $row['dflt_value'],
192-
'autoincrement' => (bool) preg_match($pattern, $meta['sql']),
192+
'autoincrement' => (bool) preg_match($pattern, (string) $meta['sql']),
193193
'primary' => $row['pk'] > 0,
194194
'vendor' => (array) $row,
195195
];

src/Database/Drivers/SqlsrvDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function applyLimit(&$sql, $limit, $offset)
9797
if ($limit < 0 || $offset < 0) {
9898
throw new Nette\InvalidArgumentException('Negative offset or limit.');
9999

100-
} elseif (version_compare($this->version, 11, '<')) { // 11 == SQL Server 2012
100+
} elseif (version_compare($this->version, '11', '<')) { // 11 == SQL Server 2012
101101
if ($offset) {
102102
throw new Nette\NotSupportedException('Offset is not supported by this database.');
103103

src/Database/Helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static function dumpSql($sql, array $params = NULL, Connection $connectio
132132
. '>&lt;' . htmlSpecialChars($type, ENT_NOQUOTES, 'UTF-8') . ' resource&gt;</i> ';
133133

134134
} else {
135-
return htmlspecialchars($param, ENT_NOQUOTES, 'UTF-8');
135+
return htmlspecialchars((string) $param, ENT_NOQUOTES, 'UTF-8');
136136
}
137137
}, $sql);
138138

@@ -197,7 +197,7 @@ public static function loadFromFile(Connection $connection, $file)
197197
$sql = '';
198198
$pdo = $connection->getPdo(); // native query without logging
199199
while (!feof($handle)) {
200-
$s = rtrim(fgets($handle));
200+
$s = rtrim((string) fgets($handle));
201201
if (!strncasecmp($s, 'DELIMITER ', 10)) {
202202
$delimiter = substr($s, 10);
203203

tests/Database/Drivers/SqlsrvDriver.applyLimit.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ require __DIR__ . '/../../bootstrap.php';
77

88
$rc = new ReflectionClass(Nette\Database\Drivers\SqlsrvDriver::class);
99
$driver = $rc->newInstanceWithoutConstructor();
10+
$version = $rc->getProperty('version');
11+
$version->setAccessible(TRUE);
12+
$version->setValue($driver, '10');
1013

1114
Assert::exception(function () use ($driver) {
1215
$query = 'SELECT 1 FROM t';
@@ -50,9 +53,7 @@ Assert::exception(function () use ($driver) {
5053

5154

5255

53-
$version = $rc->getProperty('version');
54-
$version->setAccessible(TRUE);
55-
$version->setValue($driver, 12);
56+
$version->setValue($driver, '11');
5657

5758
$query = 'SELECT 1 FROM t';
5859
$driver->applyLimit($query, 10, 20);

0 commit comments

Comments
 (0)