From fb0e65a65642bdbdfb6fe3834fd2ecad62d97b9c Mon Sep 17 00:00:00 2001 From: Ciki Date: Wed, 25 Oct 2023 16:50:46 +0200 Subject: [PATCH 1/3] Update BarPanel.php --- src/Tracy/BarPanel.php | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/Tracy/BarPanel.php b/src/Tracy/BarPanel.php index 1d23f1e..c2969ba 100755 --- a/src/Tracy/BarPanel.php +++ b/src/Tracy/BarPanel.php @@ -21,32 +21,25 @@ class BarPanel implements IBarPanel /** * Title - * @var string */ - public $title = 'PDO logger'; + public string $title = 'PDO logger'; /** * Title HTML attributes - * @var string */ - public $title_attributes = 'style="font-size:1.6em"'; + public string $title_attributes = 'style="font-size:1.6em"'; /** * Time table cell HTML attributes - * @var string */ - public $time_attributes = 'style="font-weight:bold;color:#333;font-family:Courier New;font-size:1.1em"'; + public string $time_attributes = 'style="font-weight:bold;color:#333;font-family:Courier New;font-size:1.1em"'; /** * Query table cell HTML attributes - * @var string */ - public $query_attributes = ''; + public string $query_attributes = ''; - /** - * @var PDO - */ - private $pdo; + private PDO $pdo; public function __construct(PDO $pdo) { @@ -55,18 +48,16 @@ public function __construct(PDO $pdo) /** * Get total queries execution time - * @return string */ - protected function getTotalTime() + protected function getTotalTime(): string { return (string) round(array_sum(array_column($this->pdo->getLog(), 'time')), 4); } /** * Renders HTML code for custom tab. - * @return string */ - public function getTab() + public function getTab(): string { $html = 'PDO queries logger '; $queries = count($this->pdo->getLog()); @@ -86,7 +77,7 @@ public function getTab() * Renders HTML code for custom panel. * @return string */ - public function getPanel() + public function getPanel(): string { if (class_exists('\SqlFormatter')) { \SqlFormatter::$pre_attributes = 'style="color: black;"'; From 4cd41d54c13340ac8924d26b97706ea9d99c2869 Mon Sep 17 00:00:00 2001 From: Ciki Date: Wed, 25 Oct 2023 16:52:52 +0200 Subject: [PATCH 2/3] Update PDO.php --- src/PDO.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PDO.php b/src/PDO.php index 17d7124..fc13a51 100755 --- a/src/PDO.php +++ b/src/PDO.php @@ -12,12 +12,12 @@ class PDO extends NativePdo * Logged queries. * @var array */ - protected $log = []; + protected array $log = []; /** * @inheritDoc */ - public function __construct($dsn, $username = null, $passwd = null, $options = null) + public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) { parent::__construct($dsn, $username, $passwd, $options); $this->setAttribute(self::ATTR_STATEMENT_CLASS, [PDOStatement::class, [$this]]); @@ -26,7 +26,7 @@ public function __construct($dsn, $username = null, $passwd = null, $options = n /** * @inheritDoc */ - public function exec($statement) + public function exec(string $statement): int|false { $start = microtime(true); $result = parent::exec($statement); @@ -38,7 +38,7 @@ public function exec($statement) /** * @inheritDoc */ - public function query($statement, $mode = PDO::FETCH_ASSOC, ...$ctorargs) + public function query(string $statement, ?int $mode = PDO::FETCH_ASSOC, ...$ctorargs): PDOStatement|false { $start = microtime(true); $result = parent::query($statement, $mode, ...$ctorargs); From 14de15450edf40e87613dc5a38dfb3c5005d1f7d Mon Sep 17 00:00:00 2001 From: Ciki Date: Wed, 25 Oct 2023 16:53:41 +0200 Subject: [PATCH 3/3] Update PDOStatement.php --- src/PDOStatement.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/PDOStatement.php b/src/PDOStatement.php index cf6e994..98ae8bd 100755 --- a/src/PDOStatement.php +++ b/src/PDOStatement.php @@ -27,12 +27,12 @@ protected function __construct(PDO $pdo) * @inheritDoc */ public function bindParam( - $param, - &$var, - $type = PDO::PARAM_STR, - $maxLength = null, - $driverOptions = null - ) { + int|string $param, + mixed &$var, + int $type = PDO::PARAM_STR, + int $maxLength = 0, + mixed $driverOptions = null + ): bool { $this->bindings[$param] = $var; return parent::bindParam($param, $var, $type, $maxLength, $driverOptions); } @@ -40,7 +40,7 @@ public function bindParam( /** * @inheritDoc */ - public function bindValue($param, $value, $type = PDO::PARAM_STR) + public function bindValue(string|int $param, mixed $value, int $type = PDO::PARAM_STR): bool { $this->bindings[$param] = $value; return parent::bindValue($param, $value, $type); @@ -49,7 +49,7 @@ public function bindValue($param, $value, $type = PDO::PARAM_STR) /** * @inheritDoc */ - public function execute($params = null) + public function execute(?array $params = null): bool { if (is_array($params)) { $this->bindings = $params;