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

FIX Reference concrete class names for PHP 8.1 #142

Open
wants to merge 1 commit into
base: 3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions code/PostgreSQLConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use SilverStripe\ORM\Connect\DBConnector;
use ErrorException;
use PgSql\Connection;
use PgSql\Result;

/**
* PostgreSQL connector class using the PostgreSQL specific api
Expand All @@ -20,7 +22,7 @@ class PostgreSQLConnector extends DBConnector
/**
* Connection to the PG Database database
*
* @var resource
* @var Connection
*/
protected $dbConn = null;

Expand All @@ -34,7 +36,7 @@ class PostgreSQLConnector extends DBConnector
/**
* Reference to the last query result (for pg_affected_rows)
*
* @var resource
* @var Result
*/
protected $lastQuery = null;

Expand Down
7 changes: 4 additions & 3 deletions code/PostgreSQLDatabaseConfigurationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Dev\Install\DatabaseConfigurationHelper;
use Exception;
use PDO;
use PgSql\Connection;

/**
* This is a helper class for the SS installer.
Expand Down Expand Up @@ -94,7 +95,7 @@ public function getDatabaseVersion($databaseConfig)
return false;
} elseif ($conn instanceof PDO) {
return $conn->getAttribute(PDO::ATTR_SERVER_VERSION);
} elseif (is_resource($conn)) {
} elseif ($conn instanceof Connection) {
$info = pg_version($conn);
return $info['server'];
} else {
Expand Down Expand Up @@ -132,7 +133,7 @@ public function requireDatabaseVersion($databaseConfig)
/**
* Helper function to execute a query
*
* @param mixed $conn Connection object/resource
* @param mixed $conn Connection object
* @param string $sql SQL string to execute
* @return array List of first value from each resulting row
*/
Expand All @@ -143,7 +144,7 @@ protected function query($conn, $sql)
foreach ($conn->query($sql) as $row) {
$items[] = $row[0];
}
} elseif (is_resource($conn)) {
} elseif ($conn instanceof Connection) {
$result = pg_query($conn, $sql);
while ($row = pg_fetch_row($result)) {
$items[] = $row[0];
Expand Down
9 changes: 4 additions & 5 deletions code/PostgreSQLQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\PostgreSQL;

use Iterator;
use PgSql\Result;
use SilverStripe\ORM\Connect\Query;

/**
Expand All @@ -15,7 +16,7 @@ class PostgreSQLQuery extends Query
{
/**
* The internal Postgres handle that points to the result set.
* @var resource
* @var Result
*/
private $handle;

Expand All @@ -38,7 +39,7 @@ class PostgreSQLQuery extends Query

/**
* Hook the result-set given into a Query class, suitable for use by sapphire.
* @param resource $handle the internal Postgres handle that is points to the resultset.
* @param Result $handle the internal Postgres handle that is points to the resultset.
*/
public function __construct($handle)
{
Expand All @@ -52,9 +53,7 @@ public function __construct($handle)

public function __destruct()
{
if (is_resource($this->handle)) {
pg_free_result($this->handle);
}
pg_free_result($this->handle);
}

public function getIterator(): Iterator
Expand Down