diff --git a/composer.json b/composer.json
index c0947cbe5..aece27b47 100644
--- a/composer.json
+++ b/composer.json
@@ -16,6 +16,7 @@
"require-dev": {
"tracy/tracy": "~2.2",
"nette/tester": "~2.0",
+ "nette/di": "^3.0",
"phpstan/phpstan": "^0.12"
},
"replace": {
diff --git a/src/Dibi/Bridges/Tracy/Panel.php b/src/Dibi/Bridges/Tracy/Panel.php
index 0c59bbd1c..574961766 100644
--- a/src/Dibi/Bridges/Tracy/Panel.php
+++ b/src/Dibi/Bridges/Tracy/Panel.php
@@ -104,6 +104,7 @@ public function getPanel(): ?string
return null;
}
+ /** @var float|null $totalTime */
$totalTime = $s = null;
foreach ($this->events as $event) {
$totalTime += $event->time;
@@ -129,7 +130,7 @@ public function getPanel(): ?string
$s .= '
' . Helpers::dump(strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql, true);
if ($explain) {
- $s .= " {$explain} ";
+ $s .= "{$explain} ";
}
if ($event->source) {
$s .= Tracy\Helpers::editorLink($event->source[0], $event->source[1]);//->class('tracy-DibiProfiler-source');
diff --git a/src/Dibi/Connection.php b/src/Dibi/Connection.php
index 141c6f0d8..b87d07af2 100644
--- a/src/Dibi/Connection.php
+++ b/src/Dibi/Connection.php
@@ -126,6 +126,7 @@ final public function connect(): void
$event = $this->onEvent ? new Event($this, Event::CONNECT) : null;
try {
+ /** @var string $class */
$this->driver = new $class($this->config);
$this->translator = new Translator($this);
diff --git a/src/Dibi/Drivers/FirebirdDriver.php b/src/Dibi/Drivers/FirebirdDriver.php
index eb2ff8173..9f33d52d1 100644
--- a/src/Dibi/Drivers/FirebirdDriver.php
+++ b/src/Dibi/Drivers/FirebirdDriver.php
@@ -91,6 +91,7 @@ public function disconnect(): void
public function query(string $sql): ?Dibi\ResultDriver
{
$resource = $this->inTransaction ? $this->transaction : $this->connection;
+ /** @var resource|false $res */
$res = ibase_query($resource, $sql);
if ($res === false) {
@@ -136,7 +137,7 @@ public function begin(string $savepoint = null): void
if ($savepoint !== null) {
throw new Dibi\NotSupportedException('Savepoints are not supported in Firebird/Interbase.');
}
- $this->transaction = ibase_trans($this->getResource());
+ $this->transaction = ibase_trans((int) $this->getResource());
$this->inTransaction = true;
}
diff --git a/src/Dibi/Drivers/MySqliDriver.php b/src/Dibi/Drivers/MySqliDriver.php
index 847fc24ac..b0aa0abc4 100644
--- a/src/Dibi/Drivers/MySqliDriver.php
+++ b/src/Dibi/Drivers/MySqliDriver.php
@@ -148,20 +148,26 @@ public function query(string $sql): ?Dibi\ResultDriver
}
+ /**
+ * @param int|string $code
+ */
public static function createException(string $message, $code, string $sql): Dibi\DriverException
{
- if (in_array($code, [1216, 1217, 1451, 1452, 1701], true)) {
- return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
+ if (is_int($code) === true) {
+ if (in_array($code, [1216, 1217, 1451, 1452, 1701], true)) {
+ return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
- } elseif (in_array($code, [1062, 1557, 1569, 1586], true)) {
- return new Dibi\UniqueConstraintViolationException($message, $code, $sql);
+ }
+ if (in_array($code, [1062, 1557, 1569, 1586], true)) {
+ return new Dibi\UniqueConstraintViolationException($message, $code, $sql);
- } elseif (in_array($code, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) {
- return new Dibi\NotNullConstraintViolationException($message, $code, $sql);
+ }
+ if (in_array($code, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) {
+ return new Dibi\NotNullConstraintViolationException($message, $code, $sql);
- } else {
- return new Dibi\DriverException($message, $code, $sql);
+ }
}
+ return new Dibi\DriverException($message, $code, $sql);
}
diff --git a/src/Dibi/Drivers/MySqliResult.php b/src/Dibi/Drivers/MySqliResult.php
index 67a5a86e2..8452288a4 100644
--- a/src/Dibi/Drivers/MySqliResult.php
+++ b/src/Dibi/Drivers/MySqliResult.php
@@ -41,7 +41,8 @@ public function __construct(\mysqli_result $resultSet, bool $buffered)
*/
public function __destruct()
{
- if ($this->autoFree && $this->getResultResource()) {
+ if ($this->autoFree) {
+ $this->getResultResource();
@$this->free();
}
}
diff --git a/src/Dibi/Fluent.php b/src/Dibi/Fluent.php
index fc8c0d6fb..4cb809086 100644
--- a/src/Dibi/Fluent.php
+++ b/src/Dibi/Fluent.php
@@ -32,6 +32,12 @@
* @method Fluent and(...$cond)
* @method Fluent or(...$cond)
* @method Fluent using(...$cond)
+ * @method Fluent update(...$cond)
+ * @method Fluent insert(...$cond)
+ * @method Fluent delete(...$cond)
+ * @method Fluent into(...$cond)
+ * @method Fluent values(...$cond)
+ * @method Fluent set(...$args)
* @method Fluent asc()
* @method Fluent desc()
*/
diff --git a/src/Dibi/Result.php b/src/Dibi/Result.php
index c7a66f74b..7fef8f714 100644
--- a/src/Dibi/Result.php
+++ b/src/Dibi/Result.php
@@ -251,7 +251,7 @@ final public function fetchAssoc(string $assoc): array
}
}
- if ($as === '->') { // must not be last
+ if (($as ?? '') === '->') { // must not be last
array_pop($assoc);
}
@@ -292,6 +292,7 @@ final public function fetchAssoc(string $assoc): array
} while ($row = $this->fetch());
unset($x);
+ /** @var mixed[] $data */
return $data;
}
diff --git a/src/Dibi/Translator.php b/src/Dibi/Translator.php
index 6ed3fadd2..91387fcae 100644
--- a/src/Dibi/Translator.php
+++ b/src/Dibi/Translator.php
@@ -154,7 +154,7 @@ public function translate(array $args): string
$sql = trim(implode(' ', $sql), ' ');
if ($this->errors) {
- throw new Exception('SQL translate error: ' . trim(reset($this->errors), '*'), 0, $sql);
+ throw new Exception('SQL translate error: ' . trim((string) reset($this->errors), '*'), 0, $sql);
}
// apply limit
|