diff options
| author | 2022-01-07 10:05:09 +0100 | |
|---|---|---|
| committer | 2022-01-07 10:05:09 +0100 | |
| commit | ed19445f74c30854c60873cd1df1c38e15fc316b (patch) | |
| tree | 926496a8e1f4d71c8a9b2fd0f87e835037792491 /lib/Minz/Pdo.php | |
| parent | f8c5df28ab3f7e68460b74fed11f799c702435b7 (diff) | |
Optimise Minz_ModelPdo::class (#4119)
* - Fix typo,
- remove unnecessary null in property,
- remove unused property,
- add phpDoc,
- add ext PDO in composer.json,
- use strict comparison,
- indentation
* Translate
* Update lib/Minz/ModelPdo.php
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
* The code is more explicite
* Fix phpstan
* Fix phpstan expect one
* Fix phpstan
* Return in back...
* make fix-all
* Fix exception and more types
* Fix more types
* Remove ext- in composer.json
Co-authored-by: Luc SANCHEZ <l.sanchez-ext@ubitransport.com>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'lib/Minz/Pdo.php')
| -rw-r--r-- | lib/Minz/Pdo.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Minz/Pdo.php b/lib/Minz/Pdo.php index 08436393e..9dcf0e5fa 100644 --- a/lib/Minz/Pdo.php +++ b/lib/Minz/Pdo.php @@ -6,7 +6,7 @@ */ abstract class Minz_Pdo extends PDO { - public function __construct($dsn, $username = null, $passwd = null, $options = null) { + public function __construct(string $dsn, $username = null, $passwd = null, $options = null) { parent::__construct($dsn, $username, $passwd, $options); $this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } @@ -14,18 +14,18 @@ abstract class Minz_Pdo extends PDO { abstract public function dbType(); private $prefix = ''; - public function prefix() { + public function prefix(): string { return $this->prefix; } - public function setPrefix($prefix) { + public function setPrefix(string $prefix) { $this->prefix = $prefix; } - private function autoPrefix($sql) { + private function autoPrefix(string $sql): string { return str_replace('`_', '`' . $this->prefix, $sql); } - protected function preSql($statement) { + protected function preSql(string $statement): string { if (preg_match('/^(?:UPDATE|INSERT|DELETE)/i', $statement)) { invalidateHttpCache(); } @@ -43,14 +43,14 @@ abstract class Minz_Pdo extends PDO { // PHP8+: PDO::prepare(string $query, array $options = []): PDOStatement|false #[\ReturnTypeWillChange] - public function prepare($statement, $driver_options = array()) { + public function prepare(string $statement, array $driver_options = []) { $statement = $this->preSql($statement); return parent::prepare($statement, $driver_options); } // PHP8+: PDO::exec(string $statement): int|false #[\ReturnTypeWillChange] - public function exec($statement) { + public function exec(string $statement) { $statement = $this->preSql($statement); return parent::exec($statement); } |
