Remove PDOInterface to prevent conflicts in method parameters with native PDO object

This commit is contained in:
Timothy Warren 2018-01-22 16:04:29 -05:00
parent 91eb8123d1
commit 8401cceb0d
8 changed files with 16 additions and 178 deletions

View File

@ -2,5 +2,6 @@ parameters:
autoload_files:
- %rootDir%/../../../tests/bootstrap.php
ignoreErrors:
- '#Access to an undefined property Aviat\\\Ion\\\Friend::\$[a-zA-Z0-9_]+#'
- '#Call to an undefined method Aviat\\\Ion\\\Friend::[a-zA-Z0-9_]+\(\)#'
- '#Access to an undefined property Query\\QueryBuilderInterface::\$[a-zA-Z0-9_]+#'
- '#Call to an undefined method Query\\QueryBuilderInterface::[a-zA-Z0-9_]+\(\)#'
- '#Call to an undefined method Query\\Drivers\\DriverInterface::[a-zA-Z0-9_]+\(\)#'

View File

@ -31,9 +31,9 @@ final class ConnectionManager {
/**
* Class instance variable
* @var ConnectionManager
* @var ConnectionManager|null
*/
private static $instance = NULL;
private static $instance;
/**
* Private constructor to prevent multiple instances
@ -62,7 +62,7 @@ final class ConnectionManager {
*/
public function __sleep()
{
throw new DomainException("No serializing of singleton");
throw new DomainException('No serializing of singleton');
}
/**
@ -112,7 +112,7 @@ final class ConnectionManager {
}
// You should actually connect before trying to get a connection...
throw new InvalidArgumentException("The specified connection does not exist");
throw new InvalidArgumentException('The specified connection does not exist');
}
/**
@ -214,11 +214,6 @@ final class ConnectionManager {
*/
private function createDsn(string $dbtype, \stdClass $params): string
{
if (strtolower($dbtype) === 'pdo_firebird')
{
$dbtype = 'firebird';
}
$pairs = [];
if ( ! empty($params->database))

View File

@ -22,11 +22,10 @@ use PDOStatement;
* Base Database class
*
* Extends PDO to simplify cross-database issues
*
* @package Query
* @subpackage Drivers
*/
abstract class AbstractDriver extends PDO implements DriverInterface {
abstract class AbstractDriver
extends PDO
implements DriverInterface {
/**
* Reference to the last executed query
@ -536,11 +535,7 @@ abstract class AbstractDriver extends PDO implements DriverInterface {
public function insertBatch($table, $data=[])
{
$data = (array) $data;
$firstRow = current($data);
if (is_scalar($firstRow))
{
return NULL;
}
$firstRow = (array) current($data);
// Values for insertion
$vals = [];

View File

@ -17,7 +17,7 @@ namespace Query\Drivers;
/**
* PDO Interface to implement for database drivers
*/
interface DriverInterface extends PDOInterface {
interface DriverInterface {
/**
* Constructor/Connection method

View File

@ -1,146 +0,0 @@
<?php declare(strict_types=1);
/**
* Query
*
* SQL Query Builder / Database Abstraction Layer
*
* PHP version 7.1
*
* @package Query
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2012 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link https://git.timshomepage.net/aviat4ion/Query
*/
namespace Query\Drivers;
use PDO;
use PDOException;
use PDOStatement;
/**
* Interface describing the PDO class in PHP
*/
interface PDOInterface {
/**
* Creates a PDO instance representing a connection to a database
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
* @throws PDOException
*/
public function __construct($dsn, $username, $password, array $options = []);
/**
* Initiates a transaction
*
* @throws PDOException
* @return boolean
*/
public function beginTransaction();
/**
* Commits a transaction
*
* @throws PDOException
* @return boolean
*/
public function commit();
/**
* Fetch the SQLSTATE associated with the last operation on the database handle
*
* @return mixed
*/
public function errorCode();
/**
* Fetch extended error information associated with the last operation on the database handle
*
* @return array
*/
public function errorInfo();
/**
* Execute an SQL statement and return the number of affected rows
*
* @param string $statement
* @return int
*/
public function exec($statement);
/**
* Retrieve a database connection attribute
*
* @param int $attribute
* @return mixed
*/
public function getAttribute($attribute);
/**
* Return an array of available PDO drivers
*
* @return array
*/
public static function getAvailableDrivers();
/**
* Checks if inside a transaction
*
* @return boolean
*/
public function inTransaction();
/**
* Returns teh ID of the last inserted row or sequence value
*
* @param string $name Name of the sequence object from which the ID should be returned
* @return string
*/
public function lastInsertId($name = NULL);
/**
* Prepares a statement for execution and returns a statement object
*
* @param string $statement
* @param array $options
* @return PDOStatement
*/
public function prepare($statement, $options = NULL);
/**
* Executes an SQL statement, returning a result set as a PDOStatement object
*
* @return PDOStatement
*/
public function query();
/**
* Quotes a string for use in a query
*
* @param string $string
* @param int $parameterType
* @return string|false
*/
public function quote($string, $parameterType = PDO::PARAM_STR);
/**
* Rolls back a transaction
*
* @throws PDOException
* @return boolean
*/
public function rollBack();
/**
* Set an attribute
*
* @param int $attribute
* @param mixed $value
* @return boolean
*/
public function setAttribute($attribute, $value);
}

View File

@ -24,7 +24,6 @@ use Query\Drivers\{
/**
* Convenience class for creating sql queries
* @method query(mixed $sql): PDOStatement;
*/
class QueryBuilder implements QueryBuilderInterface {
@ -274,15 +273,6 @@ class QueryBuilder implements QueryBuilderInterface {
throw new BadMethodCallException('Method does not exist');
}
// --------------------------------------------------------------------------
// ! Driver setters
// --------------------------------------------------------------------------
public function setDriver(DriverInterface $driver)
{
}
// --------------------------------------------------------------------------
// ! Select Queries
// --------------------------------------------------------------------------

View File

@ -22,7 +22,7 @@ namespace Query\Tests;
abstract class BaseDriverTest extends TestCase {
/**
* @var \Query\QueryBuilder
* @var \Query\QueryBuilderInterface|null
*/
protected static $db;

View File

@ -21,6 +21,9 @@ use PDO;
*/
abstract class BaseQueryBuilderTest extends TestCase {
/**
* @var \Query\QueryBuilderInterface|null
*/
protected static $db;
public function __destruct()