1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-06 14:16:39 +02:00

removed useless type juggling and checking

This commit is contained in:
David Grudl
2017-06-10 02:37:50 +02:00
parent 43045a0585
commit f9997f9b52
7 changed files with 8 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ class Panel implements Tracy\IBarPanel
public function __construct(bool $explain = TRUE, int $filter = NULL) public function __construct(bool $explain = TRUE, int $filter = NULL)
{ {
$this->filter = $filter ? (int) $filter : Event::QUERY; $this->filter = $filter ?: Event::QUERY;
$this->explain = $explain; $this->explain = $explain;
} }

View File

@@ -331,7 +331,7 @@ class Connection
if ($id < 1) { if ($id < 1) {
throw new Exception('Cannot retrieve last generated ID.'); throw new Exception('Cannot retrieve last generated ID.');
} }
return (int) $id; return $id;
} }

View File

@@ -236,7 +236,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
public function escapeBinary(string $value): string public function escapeBinary(string $value): string
{ {
return "X'" . bin2hex((string) $value) . "'"; return "X'" . bin2hex($value) . "'";
} }

View File

@@ -27,7 +27,7 @@ class FileLogger
public function __construct(string $file, int $filter = NULL) public function __construct(string $file, int $filter = NULL)
{ {
$this->file = $file; $this->file = $file;
$this->filter = $filter ? (int) $filter : Dibi\Event::QUERY; $this->filter = $filter ?: Dibi\Event::QUERY;
} }

View File

@@ -47,7 +47,7 @@ class FirePhpLogger
public function __construct(int $filter = NULL) public function __construct(int $filter = NULL)
{ {
$this->filter = $filter ? (int) $filter : Dibi\Event::QUERY; $this->filter = $filter ?: Dibi\Event::QUERY;
} }

View File

@@ -200,8 +200,8 @@ class Result implements IDataSource
*/ */
final public function fetchAll(int $offset = NULL, int $limit = NULL): array final public function fetchAll(int $offset = NULL, int $limit = NULL): array
{ {
$limit = $limit === NULL ? -1 : (int) $limit; $limit = $limit === NULL ? -1 : $limit;
$this->seek((int) $offset); $this->seek($offset ?: 0);
$row = $this->fetch(); $row = $this->fetch();
if (!$row) { if (!$row) {
return []; // empty result set return []; // empty result set

View File

@@ -95,7 +95,7 @@ class ProcedureException extends Exception
*/ */
public function __construct(string $message = NULL, int $code = 0, string $severity = NULL, $sql = NULL) public function __construct(string $message = NULL, int $code = 0, string $severity = NULL, $sql = NULL)
{ {
parent::__construct($message, (int) $code, $sql); parent::__construct($message, $code, $sql);
$this->severity = $severity; $this->severity = $severity;
} }