mirror of
https://github.com/dg/dibi.git
synced 2025-08-07 14:46:50 +02:00
type fixes
This commit is contained in:
@@ -482,10 +482,9 @@ class Connection
|
|||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch result - shortcut for query() & fetch().
|
* Executes SQL query and fetch result - shortcut for query() & fetch().
|
||||||
* @param mixed one or more arguments
|
* @param mixed one or more arguments
|
||||||
* @return Row|NULL
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function fetch(...$args)
|
public function fetch(...$args): ?Row
|
||||||
{
|
{
|
||||||
return $this->query($args)->fetch();
|
return $this->query($args)->fetch();
|
||||||
}
|
}
|
||||||
|
@@ -155,9 +155,8 @@ class DataSource implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates, executes SQL query and fetches the single row.
|
* Generates, executes SQL query and fetches the single row.
|
||||||
* @return Row|NULL
|
|
||||||
*/
|
*/
|
||||||
public function fetch()
|
public function fetch(): ?Row
|
||||||
{
|
{
|
||||||
return $this->getResult()->fetch();
|
return $this->getResult()->fetch();
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ class DateTime extends \DateTime
|
|||||||
{
|
{
|
||||||
if (is_numeric($time)) {
|
if (is_numeric($time)) {
|
||||||
parent::__construct('@' . $time);
|
parent::__construct('@' . $time);
|
||||||
$this->setTimeZone($timezone ? $timezone : new \DateTimeZone(date_default_timezone_get()));
|
$this->setTimezone($timezone ? $timezone : new \DateTimeZone(date_default_timezone_get()));
|
||||||
} elseif ($timezone === null) {
|
} elseif ($timezone === null) {
|
||||||
parent::__construct($time);
|
parent::__construct($time);
|
||||||
} else {
|
} else {
|
||||||
@@ -44,7 +44,7 @@ class DateTime extends \DateTime
|
|||||||
{
|
{
|
||||||
$zone = $this->getTimezone();
|
$zone = $this->getTimezone();
|
||||||
$this->__construct('@' . $timestamp);
|
$this->__construct('@' . $timestamp);
|
||||||
return $this->setTimeZone($zone);
|
return $this->setTimezone($zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -302,9 +302,8 @@ class Fluent implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates, executes SQL query and fetches the single row.
|
* Generates, executes SQL query and fetches the single row.
|
||||||
* @return Row|NULL
|
|
||||||
*/
|
*/
|
||||||
public function fetch()
|
public function fetch(): ?Row
|
||||||
{
|
{
|
||||||
if ($this->command === 'SELECT' && !$this->clauses['LIMIT']) {
|
if ($this->command === 'SELECT' && !$this->clauses['LIMIT']) {
|
||||||
return $this->query($this->_export(null, ['%lmt', 1]))->fetch();
|
return $this->query($this->_export(null, ['%lmt', 1]))->fetch();
|
||||||
|
@@ -289,7 +289,6 @@ class Helpers
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @return string|int
|
|
||||||
*/
|
*/
|
||||||
public static function intVal($value): int
|
public static function intVal($value): int
|
||||||
{
|
{
|
||||||
|
@@ -32,13 +32,13 @@ class Result implements IDataSource
|
|||||||
{
|
{
|
||||||
use Strict;
|
use Strict;
|
||||||
|
|
||||||
/** @var array ResultDriver */
|
/** @var ResultDriver|null */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
/** @var array Translate table */
|
/** @var array Translate table */
|
||||||
private $types = [];
|
private $types = [];
|
||||||
|
|
||||||
/** @var Reflection\Result */
|
/** @var Reflection\Result|null */
|
||||||
private $meta;
|
private $meta;
|
||||||
|
|
||||||
/** @var bool Already fetched? Used for allowance for first seek(0) */
|
/** @var bool Already fetched? Used for allowance for first seek(0) */
|
||||||
@@ -162,7 +162,7 @@ class Result implements IDataSource
|
|||||||
/**
|
/**
|
||||||
* Fetches the row at current position, process optional type conversion.
|
* Fetches the row at current position, process optional type conversion.
|
||||||
* and moves the internal cursor to the next position
|
* and moves the internal cursor to the next position
|
||||||
* @return ?Row|array
|
* @return Row|array|null
|
||||||
*/
|
*/
|
||||||
final public function fetch()
|
final public function fetch()
|
||||||
{
|
{
|
||||||
|
@@ -31,8 +31,9 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts value to DateTime object.
|
* Converts value to DateTime object.
|
||||||
|
* @return \DateTime|string|null
|
||||||
*/
|
*/
|
||||||
public function asDateTime(string $key, string $format = null): \DateTime
|
public function asDateTime(string $key, string $format = null)
|
||||||
{
|
{
|
||||||
$time = $this[$key];
|
$time = $this[$key];
|
||||||
if (!$time instanceof DateTime) {
|
if (!$time instanceof DateTime) {
|
||||||
|
@@ -170,10 +170,9 @@ class dibi
|
|||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch result - Monostate for Dibi\Connection::query() & fetch().
|
* Executes SQL query and fetch result - Monostate for Dibi\Connection::query() & fetch().
|
||||||
* @param mixed one or more arguments
|
* @param mixed one or more arguments
|
||||||
* @return Dibi\Row|NULL
|
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public static function fetch(...$args)
|
public static function fetch(...$args): ?Dibi\Row
|
||||||
{
|
{
|
||||||
return self::getConnection()->query($args)->fetch();
|
return self::getConnection()->query($args)->fetch();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user