Fixes for phan and phpstan

Note that the (string) for pg_escape_string and pg_escape_literal are
forced for phpstan because it thinks this might return false even
thought both function only return string ever
This commit is contained in:
Clemens Schwaighofer
2022-03-03 06:49:15 +09:00
parent 42b961f35e
commit a0a7389d3b
3 changed files with 21 additions and 13 deletions

View File

@@ -528,9 +528,10 @@ class PgSQL
public function __dbEscapeLiteral($string): string
{
if ($this->dbh === false || is_bool($this->dbh)) {
return '';
return (string)'';
}
return pg_escape_literal($this->dbh, (string)$string);
// for phpstan, thinks this is string|false?
return (string)pg_escape_literal($this->dbh, (string)$string);
}
/**
@@ -544,7 +545,8 @@ class PgSQL
if ($this->dbh === false || is_bool($this->dbh)) {
return '';
}
return pg_escape_identifier($this->dbh, (string)$string);
// for phpstan, thinks this is string|false?
return (string)pg_escape_identifier($this->dbh, (string)$string);
}
/**
@@ -583,7 +585,9 @@ class PgSQL
return false;
}
$busy = pg_connection_busy($this->dbh);
/** @var array<resource>|null */
$socket = [pg_socket($this->dbh)];
$null = null;
while ($busy) {
// Will wait on that socket until that happens or the timeout is reached
stream_select($socket, $null, $null, $timeout_seconds);