Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpstan-8 typehinting #5429

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 12 additions & 22 deletions lib/Minz/ModelPdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ class Minz_ModelPdo {
protected $current_user;

/**
* @return void
* @throws Minz_ConfigurationNamespaceException
* @throws Minz_PDOConnectionException
* @throws PDOException
*/
private function dbConnect() {
private function dbConnect(): void {
$db = Minz_Configuration::get('system')->db;
$driver_options = isset($db['pdo_options']) && is_array($db['pdo_options']) ? $db['pdo_options'] : [];
$driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
Expand Down Expand Up @@ -147,35 +146,23 @@ public function __construct(?string $currentUser = null, ?Minz_Pdo $currentPdo =
);
}

/**
* @return void
*/
public function beginTransaction() {
public function beginTransaction(): void {
$this->pdo->beginTransaction();
}

public function inTransaction(): bool {
return $this->pdo->inTransaction();
}

/**
* @return void
*/
public function commit() {
public function commit(): void {
$this->pdo->commit();
}

/**
* @return void
*/
public function rollBack() {
public function rollBack(): void {
$this->pdo->rollBack();
}

/**
* @return void
*/
public static function clean() {
public static function clean(): void {
self::$sharedPdo = null;
self::$sharedCurrentUser = '';
}
Expand All @@ -190,10 +177,13 @@ private function fetchAny(string $sql, array $values, int $mode, int $column = 0
$ok = $stm !== false;
if ($ok && !empty($values)) {
foreach ($values as $name => $value) {
if (is_int($value)) $type = PDO::PARAM_INT;
elseif (is_string($value)) $type = PDO::PARAM_STR;
elseif (is_null($value)) $type = PDO::PARAM_NULL;
else {
if (is_int($value)) {
$type = PDO::PARAM_INT;
} elseif (is_string($value)) {
$type = PDO::PARAM_STR;
} elseif (is_null($value)) {
$type = PDO::PARAM_NULL;
} else {
$ok = false;
break;
}
Expand Down
1 change: 0 additions & 1 deletion tests/phpstan-next.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@
./cli/user-info.php
./lib/lib_install.php
./lib/Minz/ModelPdo.php
./lib/Minz/Translate.php