mirror of
https://github.com/dg/dibi.git
synced 2025-07-30 19:00:13 +02:00
added typehints
This commit is contained in:
@@ -23,7 +23,7 @@ class DibiExtension22 extends Nette\DI\CompilerExtension
|
||||
private $debugMode;
|
||||
|
||||
|
||||
public function __construct($debugMode = null)
|
||||
public function __construct(bool $debugMode = null)
|
||||
{
|
||||
$this->debugMode = $debugMode;
|
||||
}
|
||||
|
@@ -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::getBlueScreen()->addPanel([__CLASS__, 'renderException']);
|
||||
@@ -65,7 +65,7 @@ class Panel implements Tracy\IBarPanel
|
||||
/**
|
||||
* 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()) {
|
||||
return [
|
||||
|
@@ -524,7 +524,7 @@ class Connection
|
||||
}
|
||||
|
||||
|
||||
public static function literal($value): Literal
|
||||
public static function literal(string $value): Literal
|
||||
{
|
||||
return new Literal($value);
|
||||
}
|
||||
@@ -572,7 +572,7 @@ class Connection
|
||||
}
|
||||
|
||||
|
||||
protected function onEvent($arg)
|
||||
protected function onEvent($arg): void
|
||||
{
|
||||
foreach ($this->onEvent ?: [] as $handler) {
|
||||
$handler($arg);
|
||||
|
@@ -33,14 +33,14 @@ class DateTime extends \DateTime
|
||||
}
|
||||
|
||||
|
||||
public function modifyClone(string $modify = '')
|
||||
public function modifyClone(string $modify = ''): self
|
||||
{
|
||||
$dolly = clone $this;
|
||||
return $modify ? $dolly->modify($modify) : $dolly;
|
||||
}
|
||||
|
||||
|
||||
public function setTimestamp($timestamp)
|
||||
public function setTimestamp($timestamp): self
|
||||
{
|
||||
$zone = $this->getTimezone();
|
||||
$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');
|
||||
}
|
||||
|
@@ -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;
|
||||
});
|
||||
if (empty($config['persistent'])) {
|
||||
|
@@ -53,7 +53,7 @@ class Event
|
||||
public $source;
|
||||
|
||||
|
||||
public function __construct(Connection $connection, $type, $sql = null)
|
||||
public function __construct(Connection $connection, int $type, string $sql = null)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->type = $type;
|
||||
@@ -83,7 +83,7 @@ class Event
|
||||
}
|
||||
|
||||
|
||||
public function done($result = null)
|
||||
public function done($result = null): self
|
||||
{
|
||||
$this->result = $result;
|
||||
try {
|
||||
|
@@ -286,7 +286,7 @@ class Fluent implements IDataSource
|
||||
* @return Result|int result set or number of affected rows
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute($return = null)
|
||||
public function execute(string $return = null)
|
||||
{
|
||||
$res = $this->query($this->_export());
|
||||
switch ($return) {
|
||||
|
@@ -25,13 +25,13 @@ abstract class HashMapBase
|
||||
}
|
||||
|
||||
|
||||
public function setCallback(callable $callback)
|
||||
public function setCallback(callable $callback): void
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
|
||||
public function getCallback()
|
||||
public function getCallback(): callable
|
||||
{
|
||||
return $this->callback;
|
||||
}
|
||||
|
@@ -155,7 +155,7 @@ class Helpers
|
||||
|
||||
|
||||
/** @internal */
|
||||
public static function escape(Driver $driver, $value, $type)
|
||||
public static function escape(Driver $driver, $value, string $type): string
|
||||
{
|
||||
static $types = [
|
||||
Type::TEXT => 'text',
|
||||
@@ -233,7 +233,7 @@ class Helpers
|
||||
* Import SQL dump from file.
|
||||
* @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 @
|
||||
|
||||
|
@@ -33,7 +33,7 @@ class Database
|
||||
private $tables;
|
||||
|
||||
|
||||
public function __construct(Dibi\Reflector $reflector, $name)
|
||||
public function __construct(Dibi\Reflector $reflector, string $name = null)
|
||||
{
|
||||
$this->reflector = $reflector;
|
||||
$this->name = $name;
|
||||
|
@@ -29,7 +29,7 @@ class ForeignKey
|
||||
private $references;
|
||||
|
||||
|
||||
public function __construct($name, array $references)
|
||||
public function __construct(string $name, array $references)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->references = $references;
|
||||
|
@@ -303,7 +303,7 @@ class Result implements IDataSource
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
private function oldFetchAssoc($assoc)
|
||||
private function oldFetchAssoc(string $assoc)
|
||||
{
|
||||
$this->seek(0);
|
||||
$row = $this->fetch();
|
||||
@@ -514,7 +514,7 @@ class Result implements IDataSource
|
||||
/**
|
||||
* Returns column type.
|
||||
*/
|
||||
final public function getType($column): string
|
||||
final public function getType(string $column): string
|
||||
{
|
||||
return $this->types[$column] ?? null;
|
||||
}
|
||||
@@ -533,7 +533,7 @@ class Result implements IDataSource
|
||||
/**
|
||||
* Returns data format.
|
||||
*/
|
||||
final public function getFormat($type): ?string
|
||||
final public function getFormat(string $type): ?string
|
||||
{
|
||||
return $this->formats[$type] ?? null;
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ namespace Dibi;
|
||||
*/
|
||||
class Row implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
{
|
||||
public function __construct($arr)
|
||||
public function __construct(array $arr)
|
||||
{
|
||||
foreach ($arr as $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;
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ class ProcedureException extends 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);
|
||||
$this->severity = $severity;
|
||||
|
Reference in New Issue
Block a user