chore: Аннотации к типам
This commit is contained in:
parent
530a3b931d
commit
730a608f9b
27 changed files with 491 additions and 134 deletions
|
|
@ -240,7 +240,7 @@ class Manager
|
|||
* @param array $fields
|
||||
* @param array|string|null $constraints
|
||||
*/
|
||||
public function createTableQuery($table, $fields, $constraints)
|
||||
public function createTableQuery($table, $fields, $constraints): void
|
||||
{
|
||||
$pg = $this->db->isPostgres();
|
||||
if ($constraints) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@ use TheSeer\Tokenizer\Exception;
|
|||
|
||||
class PDOStatement extends \PDOStatement implements \IteratorAggregate
|
||||
{
|
||||
/** @var int */
|
||||
protected $cursorPos = 0;
|
||||
public $cache = array();
|
||||
/** @var array */
|
||||
public $cache = [];
|
||||
/** @var ?array */
|
||||
public $fields;
|
||||
|
||||
function getIterator(): \Iterator {
|
||||
|
|
@ -20,11 +23,15 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate
|
|||
protected function __construct() {
|
||||
}
|
||||
|
||||
function rewind() {
|
||||
function rewind(): void {
|
||||
$this->cursorPos = 0;
|
||||
}
|
||||
|
||||
public function seek($rownum) {
|
||||
/**
|
||||
* @param int $rownum
|
||||
* @return bool
|
||||
*/
|
||||
public function seek($rownum): bool {
|
||||
if ($rownum < 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -35,17 +42,17 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate
|
|||
return true;
|
||||
}
|
||||
|
||||
function valid() {
|
||||
function valid(): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function first() {
|
||||
if($this->cursorPos !== 0) { $this->seek(0); }
|
||||
if ($this->cursorPos !== 0) { $this->seek(0); }
|
||||
return $this->next();
|
||||
}
|
||||
|
||||
function next() {
|
||||
function next(): bool{
|
||||
if ($this->getRecordCount() > $this->cursorPos) {
|
||||
if (!isset($this->cache[$this->cursorPos])) {
|
||||
$this->cache[$this->cursorPos] = $this->fetch(PDO::FETCH_ASSOC);
|
||||
|
|
@ -60,10 +67,13 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate
|
|||
}
|
||||
}
|
||||
|
||||
function key() {
|
||||
function key(): int {
|
||||
return $this->cursorPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
function current() {
|
||||
return $this->cache[$this->cursorPos];
|
||||
}
|
||||
|
|
@ -72,37 +82,68 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate
|
|||
return $this->fields;
|
||||
}
|
||||
|
||||
function getInt($name) {
|
||||
/**
|
||||
* @param string $name
|
||||
* @return int
|
||||
*/
|
||||
function getInt($name): int {
|
||||
if (!$this->fields) {
|
||||
throw new \Exception('no fields');
|
||||
}
|
||||
return (int)$this->fields[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
function getBlob($name) {
|
||||
return $this->fields[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
function getString($name) {
|
||||
return $this->fields[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
function getBoolean($name) {
|
||||
return (bool)$this->fields[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
function get($name) {
|
||||
return $this->fields[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
function getArray($name) {
|
||||
return StringUtil::strToArray($this->fields[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
function getRecordCount() {
|
||||
return count($this->cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
* @return bool
|
||||
*/
|
||||
function execute($args = null): bool {
|
||||
$result = parent::execute($args);
|
||||
return $result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue