1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 13:47:33 +02:00

added typehints

This commit is contained in:
David Grudl
2018-03-21 13:48:20 +01:00
parent 837b97b582
commit 3616130959
14 changed files with 24 additions and 24 deletions

View File

@@ -23,7 +23,7 @@ class DibiExtension22 extends Nette\DI\CompilerExtension
private $debugMode; private $debugMode;
public function __construct($debugMode = null) public function __construct(bool $debugMode = null)
{ {
$this->debugMode = $debugMode; $this->debugMode = $debugMode;
} }

View File

@@ -42,7 +42,7 @@ class Panel implements Tracy\IBarPanel
} }
public function register(Dibi\Connection $connection) public function register(Dibi\Connection $connection): void
{ {
Tracy\Debugger::getBar()->addPanel($this); Tracy\Debugger::getBar()->addPanel($this);
Tracy\Debugger::getBlueScreen()->addPanel([__CLASS__, 'renderException']); Tracy\Debugger::getBlueScreen()->addPanel([__CLASS__, 'renderException']);
@@ -65,7 +65,7 @@ class Panel implements Tracy\IBarPanel
/** /**
* Returns blue-screen custom tab. * Returns blue-screen custom tab.
*/ */
public static function renderException($e): ?array public static function renderException(?\Throwable $e): ?array
{ {
if ($e instanceof Dibi\Exception && $e->getSql()) { if ($e instanceof Dibi\Exception && $e->getSql()) {
return [ return [

View File

@@ -524,7 +524,7 @@ class Connection
} }
public static function literal($value): Literal public static function literal(string $value): Literal
{ {
return new Literal($value); return new Literal($value);
} }
@@ -572,7 +572,7 @@ class Connection
} }
protected function onEvent($arg) protected function onEvent($arg): void
{ {
foreach ($this->onEvent ?: [] as $handler) { foreach ($this->onEvent ?: [] as $handler) {
$handler($arg); $handler($arg);

View File

@@ -33,14 +33,14 @@ class DateTime extends \DateTime
} }
public function modifyClone(string $modify = '') public function modifyClone(string $modify = ''): self
{ {
$dolly = clone $this; $dolly = clone $this;
return $modify ? $dolly->modify($modify) : $dolly; return $modify ? $dolly->modify($modify) : $dolly;
} }
public function setTimestamp($timestamp) public function setTimestamp($timestamp): self
{ {
$zone = $this->getTimezone(); $zone = $this->getTimezone();
$this->__construct('@' . $timestamp); $this->__construct('@' . $timestamp);
@@ -55,7 +55,7 @@ class DateTime extends \DateTime
} }
public function __toString() public function __toString(): string
{ {
return $this->format('Y-m-d H:i:s.u'); return $this->format('Y-m-d H:i:s.u');
} }

View File

@@ -80,7 +80,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
} }
} }
set_error_handler(function ($severity, $message) use (&$error) { set_error_handler(function ($severity, string $message) use (&$error) {
$error = $message; $error = $message;
}); });
if (empty($config['persistent'])) { if (empty($config['persistent'])) {

View File

@@ -53,7 +53,7 @@ class Event
public $source; public $source;
public function __construct(Connection $connection, $type, $sql = null) public function __construct(Connection $connection, int $type, string $sql = null)
{ {
$this->connection = $connection; $this->connection = $connection;
$this->type = $type; $this->type = $type;
@@ -83,7 +83,7 @@ class Event
} }
public function done($result = null) public function done($result = null): self
{ {
$this->result = $result; $this->result = $result;
try { try {

View File

@@ -286,7 +286,7 @@ class Fluent implements IDataSource
* @return Result|int result set or number of affected rows * @return Result|int result set or number of affected rows
* @throws Exception * @throws Exception
*/ */
public function execute($return = null) public function execute(string $return = null)
{ {
$res = $this->query($this->_export()); $res = $this->query($this->_export());
switch ($return) { switch ($return) {

View File

@@ -25,13 +25,13 @@ abstract class HashMapBase
} }
public function setCallback(callable $callback) public function setCallback(callable $callback): void
{ {
$this->callback = $callback; $this->callback = $callback;
} }
public function getCallback() public function getCallback(): callable
{ {
return $this->callback; return $this->callback;
} }

View File

@@ -155,7 +155,7 @@ class Helpers
/** @internal */ /** @internal */
public static function escape(Driver $driver, $value, $type) public static function escape(Driver $driver, $value, string $type): string
{ {
static $types = [ static $types = [
Type::TEXT => 'text', Type::TEXT => 'text',
@@ -233,7 +233,7 @@ class Helpers
* Import SQL dump from file. * Import SQL dump from file.
* @return int count of sql commands * @return int count of sql commands
*/ */
public static function loadFromFile(Connection $connection, $file, callable $onProgress = null): int public static function loadFromFile(Connection $connection, string $file, callable $onProgress = null): int
{ {
@set_time_limit(0); // intentionally @ @set_time_limit(0); // intentionally @

View File

@@ -33,7 +33,7 @@ class Database
private $tables; private $tables;
public function __construct(Dibi\Reflector $reflector, $name) public function __construct(Dibi\Reflector $reflector, string $name = null)
{ {
$this->reflector = $reflector; $this->reflector = $reflector;
$this->name = $name; $this->name = $name;

View File

@@ -29,7 +29,7 @@ class ForeignKey
private $references; private $references;
public function __construct($name, array $references) public function __construct(string $name, array $references)
{ {
$this->name = $name; $this->name = $name;
$this->references = $references; $this->references = $references;

View File

@@ -303,7 +303,7 @@ class Result implements IDataSource
/** /**
* @deprecated * @deprecated
*/ */
private function oldFetchAssoc($assoc) private function oldFetchAssoc(string $assoc)
{ {
$this->seek(0); $this->seek(0);
$row = $this->fetch(); $row = $this->fetch();
@@ -514,7 +514,7 @@ class Result implements IDataSource
/** /**
* Returns column type. * Returns column type.
*/ */
final public function getType($column): string final public function getType(string $column): string
{ {
return $this->types[$column] ?? null; return $this->types[$column] ?? null;
} }
@@ -533,7 +533,7 @@ class Result implements IDataSource
/** /**
* Returns data format. * Returns data format.
*/ */
final public function getFormat($type): ?string final public function getFormat(string $type): ?string
{ {
return $this->formats[$type] ?? null; return $this->formats[$type] ?? null;
} }

View File

@@ -15,7 +15,7 @@ namespace Dibi;
*/ */
class Row implements \ArrayAccess, \IteratorAggregate, \Countable class Row implements \ArrayAccess, \IteratorAggregate, \Countable
{ {
public function __construct($arr) public function __construct(array $arr)
{ {
foreach ($arr as $k => $v) { foreach ($arr as $k => $v) {
$this->$k = $v; $this->$k = $v;
@@ -23,7 +23,7 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable
} }
public function toArray() public function toArray(): array
{ {
return (array) $this; return (array) $this;
} }

View File

@@ -93,7 +93,7 @@ class ProcedureException extends Exception
/** /**
* Construct the exception. * Construct the 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, string $sql = null)
{ {
parent::__construct($message, $code, $sql); parent::__construct($message, $code, $sql);
$this->severity = $severity; $this->severity = $severity;