diff --git a/src/Dibi/Bridges/Nette/DibiExtension22.php b/src/Dibi/Bridges/Nette/DibiExtension22.php index a26203f1..b4e55417 100644 --- a/src/Dibi/Bridges/Nette/DibiExtension22.php +++ b/src/Dibi/Bridges/Nette/DibiExtension22.php @@ -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; } diff --git a/src/Dibi/Bridges/Tracy/Panel.php b/src/Dibi/Bridges/Tracy/Panel.php index e6018b0c..ddb5a37d 100644 --- a/src/Dibi/Bridges/Tracy/Panel.php +++ b/src/Dibi/Bridges/Tracy/Panel.php @@ -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 [ diff --git a/src/Dibi/Connection.php b/src/Dibi/Connection.php index afffd6b4..c6aa56d3 100644 --- a/src/Dibi/Connection.php +++ b/src/Dibi/Connection.php @@ -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); diff --git a/src/Dibi/DateTime.php b/src/Dibi/DateTime.php index 9612d2e9..18ac8cba 100644 --- a/src/Dibi/DateTime.php +++ b/src/Dibi/DateTime.php @@ -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'); } diff --git a/src/Dibi/Drivers/PostgreDriver.php b/src/Dibi/Drivers/PostgreDriver.php index 38d72b83..4cd2edea 100644 --- a/src/Dibi/Drivers/PostgreDriver.php +++ b/src/Dibi/Drivers/PostgreDriver.php @@ -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'])) { diff --git a/src/Dibi/Event.php b/src/Dibi/Event.php index 30de8905..e40f1dcc 100644 --- a/src/Dibi/Event.php +++ b/src/Dibi/Event.php @@ -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 { diff --git a/src/Dibi/Fluent.php b/src/Dibi/Fluent.php index 18ebdcbd..44c08bfe 100644 --- a/src/Dibi/Fluent.php +++ b/src/Dibi/Fluent.php @@ -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) { diff --git a/src/Dibi/HashMap.php b/src/Dibi/HashMap.php index bdf1b693..fe361c7a 100644 --- a/src/Dibi/HashMap.php +++ b/src/Dibi/HashMap.php @@ -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; } diff --git a/src/Dibi/Helpers.php b/src/Dibi/Helpers.php index 90f58a3d..20cac485 100644 --- a/src/Dibi/Helpers.php +++ b/src/Dibi/Helpers.php @@ -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 @ diff --git a/src/Dibi/Reflection/Database.php b/src/Dibi/Reflection/Database.php index ebf25155..028b75be 100644 --- a/src/Dibi/Reflection/Database.php +++ b/src/Dibi/Reflection/Database.php @@ -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; diff --git a/src/Dibi/Reflection/ForeignKey.php b/src/Dibi/Reflection/ForeignKey.php index 71b49d18..99bd50a3 100644 --- a/src/Dibi/Reflection/ForeignKey.php +++ b/src/Dibi/Reflection/ForeignKey.php @@ -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; diff --git a/src/Dibi/Result.php b/src/Dibi/Result.php index 315081d3..6f54543d 100644 --- a/src/Dibi/Result.php +++ b/src/Dibi/Result.php @@ -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; } diff --git a/src/Dibi/Row.php b/src/Dibi/Row.php index ef96dd33..59d83a4f 100644 --- a/src/Dibi/Row.php +++ b/src/Dibi/Row.php @@ -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; } diff --git a/src/Dibi/exceptions.php b/src/Dibi/exceptions.php index 9d9b61d2..3214fe4d 100644 --- a/src/Dibi/exceptions.php +++ b/src/Dibi/exceptions.php @@ -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;