mirror of
https://github.com/dg/dibi.git
synced 2025-07-30 19:00:13 +02:00
strict fixes
This commit is contained in:
@@ -123,6 +123,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
} elseif (is_resource($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +287,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function escapeBool($value)
|
||||
{
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -98,6 +98,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
} elseif (is_resource($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +237,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function escapeBool($value)
|
||||
{
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -158,6 +158,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
} elseif (is_object($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +329,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function escapeBool($value)
|
||||
{
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -110,6 +110,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
$this->affectedRows = odbc_num_rows($res);
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +261,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function escapeBool($value)
|
||||
{
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -123,6 +123,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
$err = oci_error($this->connection);
|
||||
throw new Dibi\DriverException($err['message'], $err['code'], $sql);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +285,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function escapeBool($value)
|
||||
{
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -40,7 +40,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
private $driverName;
|
||||
|
||||
/** @var string */
|
||||
private $serverVersion;
|
||||
private $serverVersion = '';
|
||||
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
if (isset($list[$cmd])) {
|
||||
$this->affectedRows = $this->connection->exec($sql);
|
||||
if ($this->affectedRows !== FALSE) {
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
$res = $this->connection->query($sql);
|
||||
@@ -321,7 +321,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
if ($this->driverName === 'pgsql') {
|
||||
return $value ? 'TRUE' : 'FALSE';
|
||||
} else {
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -145,6 +145,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -118,6 +118,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
||||
} elseif ($res instanceof \SQLite3Result) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +281,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function escapeBool($value)
|
||||
{
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -42,7 +42,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
private $affectedRows = FALSE;
|
||||
|
||||
/** @var string */
|
||||
private $version;
|
||||
private $version = '';
|
||||
|
||||
|
||||
/**
|
||||
@@ -122,6 +122,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
$this->affectedRows = sqlsrv_rows_affected($res);
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +261,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function escapeBool($value)
|
||||
{
|
||||
return $value ? 1 : 0;
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +335,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
if ($limit < 0 || $offset < 0) {
|
||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||
|
||||
} elseif (version_compare($this->version, 11, '<')) { // 11 == SQL Server 2012
|
||||
} elseif (version_compare($this->version, '11', '<')) { // 11 == SQL Server 2012
|
||||
if ($offset) {
|
||||
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
|
||||
|
||||
|
@@ -50,14 +50,14 @@ class Helpers
|
||||
if ($i === 0) {
|
||||
echo "\n<table class=\"dump\">\n<thead>\n\t<tr>\n\t\t<th>#row</th>\n";
|
||||
foreach ($row as $col => $foo) {
|
||||
echo "\t\t<th>" . htmlSpecialChars($col) . "</th>\n";
|
||||
echo "\t\t<th>" . htmlSpecialChars((string) $col) . "</th>\n";
|
||||
}
|
||||
echo "\t</tr>\n</thead>\n<tbody>\n";
|
||||
}
|
||||
|
||||
echo "\t<tr>\n\t\t<th>", $i, "</th>\n";
|
||||
foreach ($row as $col) {
|
||||
echo "\t\t<td>", htmlSpecialChars($col), "</td>\n";
|
||||
echo "\t\t<td>", htmlSpecialChars((string) $col), "</td>\n";
|
||||
}
|
||||
echo "\t</tr>\n";
|
||||
}
|
||||
|
@@ -271,7 +271,7 @@ class Result implements IDataSource
|
||||
}
|
||||
|
||||
$data = NULL;
|
||||
$assoc = preg_split('#(\[\]|->|=|\|)#', $assoc, NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
$assoc = preg_split('#(\[\]|->|=|\|)#', $assoc, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// check columns
|
||||
foreach ($assoc as $as) {
|
||||
@@ -499,7 +499,7 @@ class Result implements IDataSource
|
||||
: $tmp;
|
||||
|
||||
} elseif ($type === Type::FLOAT) {
|
||||
$value = ltrim($value, '0');
|
||||
$value = ltrim((string) $value, '0');
|
||||
$p = strpos($value, '.');
|
||||
if ($p !== FALSE) {
|
||||
$value = rtrim(rtrim($value, '0'), '.');
|
||||
|
@@ -246,7 +246,7 @@ final class Translator
|
||||
case 'in':// replaces scalar %in modifier!
|
||||
case 'l': // (val, val, ...)
|
||||
foreach ($value as $k => $v) {
|
||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||
$pair = explode('%', (string) $k, 2); // split into identifier & modifier
|
||||
$vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
||||
}
|
||||
return '(' . (($vx || $modifier === 'l') ? implode(', ', $vx) : 'NULL') . ')';
|
||||
@@ -326,7 +326,7 @@ final class Translator
|
||||
|
||||
switch ($modifier) {
|
||||
case 's': // string
|
||||
return $value === NULL ? 'NULL' : $this->driver->escapeText($value);
|
||||
return $value === NULL ? 'NULL' : $this->driver->escapeText((string) $value);
|
||||
|
||||
case 'bin':// binary
|
||||
return $value === NULL ? 'NULL' : $this->driver->escapeBinary($value);
|
||||
@@ -336,7 +336,7 @@ final class Translator
|
||||
|
||||
case 'sN': // string or NULL
|
||||
case 'sn':
|
||||
return $value == '' ? 'NULL' : $this->driver->escapeText($value); // notice two equal signs
|
||||
return $value == '' ? 'NULL' : $this->driver->escapeText((string) $value); // notice two equal signs
|
||||
|
||||
case 'in': // deprecated
|
||||
trigger_error('Modifier %in is deprecated, use %iN.', E_USER_DEPRECATED);
|
||||
|
@@ -90,7 +90,7 @@ class dibi
|
||||
* @return Dibi\Connection
|
||||
* @throws Dibi\Exception
|
||||
*/
|
||||
public static function connect($config = [], $name = 0)
|
||||
public static function connect($config = [], $name = '0')
|
||||
{
|
||||
return self::$connection = self::$registry[$name] = new Dibi\Connection($config, $name);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class Exception extends \Exception
|
||||
* @param mixed
|
||||
* @param string SQL command
|
||||
*/
|
||||
public function __construct($message = NULL, $code = 0, $sql = NULL)
|
||||
public function __construct($message = '', $code = 0, $sql = NULL)
|
||||
{
|
||||
parent::__construct($message);
|
||||
$this->code = $code;
|
||||
|
@@ -29,7 +29,7 @@ test(function () use ($config) { // lazy
|
||||
|
||||
|
||||
test(function () use ($config) { // query string
|
||||
$conn = new Connection(http_build_query($config, NULL, '&'));
|
||||
$conn = new Connection(http_build_query($config, '', '&'));
|
||||
Assert::true($conn->isConnected());
|
||||
|
||||
Assert::null($conn->getConfig('lazy'));
|
||||
|
Reference in New Issue
Block a user