Updated function signatures and error messages (#1163)

This commit is contained in:
Jenny Tam 2020-07-22 09:52:16 -07:00 committed by GitHub
parent 550a7104a4
commit bba1f18f0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 10 deletions

View file

@ -58,7 +58,7 @@ class ExPDO extends PDO
$this->test2 = 22;
}
function query($sql)
function query($sql, $fetch_style = PDO::FETCH_BOTH,...$fetch_mode_args)
{
echo __METHOD__ . "()\n";
$stmt = parent::prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('ExPDOStatement')));

View file

@ -55,7 +55,7 @@ class ExPDO extends PDO
return (call_user_func_array(array($this, 'parent::exec'), $args));
}
public function query(string $statement)
public function query($statement, $fetch_style = PDO::FETCH_BOTH,...$fetch_mode_args)
{
$this->protocol();
$args = func_get_args();

View file

@ -61,7 +61,7 @@ class ExPDO extends PDO
echo __METHOD__ . "()\n";
}
function query($sql)
function query($sql, $fetch_style = PDO::FETCH_BOTH,...$fetch_mode_args)
{
echo __METHOD__ . "()\n";
$stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('ExPDOStatement', array($this))));

View file

@ -66,7 +66,7 @@ class ExPDO extends PDO
echo __METHOD__ . "()\n";
}
function query($sql)
function query($sql, $fetch_style = PDO::FETCH_BOTH,...$fetch_mode_args)
{
echo __METHOD__ . "()\n";
$stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('ExPDOStatement', array($this))));

View file

@ -69,7 +69,7 @@ class ExPDO extends PDO
echo __METHOD__ . "()\n";
}
function query($sql)
function query($sql, $fetch_style = PDO::FETCH_BOTH,...$fetch_mode_args)
{
echo __METHOD__ . "()\n";
$stmt = parent::query($sql);

View file

@ -80,8 +80,11 @@ function fetchAllInvalid($conn, $tbname)
} catch (PDOException $ex) {
print_r($ex);
} catch (Error $err) {
$expected = (PHP_MAJOR_VERSION == 8) ? 'PDO::FETCH_UNKNOWN' : 'FETCH_UNKNOWN';
$message = "Undefined class constant '$expected'";
if (PHP_MAJOR_VERSION == 8) {
$message = "Undefined constant PDO::FETCH_UNKNOWN";
} else {
$message = "Undefined class constant 'FETCH_UNKNOWN'";
}
if ($err->getMessage() !== $message) {
echo $err->getMessage() . PHP_EOL;
}

View file

@ -82,8 +82,11 @@ function fetchWithStyle($conn, $tbname, $style)
} catch (PDOException $err) {
print_r($err);
} catch (Error $err) {
$expected = (PHP_MAJOR_VERSION == 8) ? 'PDO::FETCH_UNKNOWN' : 'FETCH_UNKNOWN';
$message = "Undefined class constant '$expected'";
if (PHP_MAJOR_VERSION == 8) {
$message = "Undefined constant PDO::FETCH_UNKNOWN";
} else {
$message = "Undefined class constant 'FETCH_UNKNOWN'";
}
if ($err->getMessage() !== $message) {
echo $err->getMessage() . PHP_EOL;
}

View file

@ -21,7 +21,7 @@ function warningHandler($errno, $errstr)
function compareMessages($err)
{
$exp8x = "Undefined constant 'SQLSRV_ENC_UNKNOWN'";
$exp8x = 'Undefined constant "SQLSRV_ENC_UNKNOWN"';
$exp7x = "Use of undefined constant SQLSRV_ENC_UNKNOWN - assumed 'SQLSRV_ENC_UNKNOWN' (this will throw an Error in a future version of PHP)";
$expected = (PHP_MAJOR_VERSION == 8) ? $exp8x : $exp7x;