Require 7.4, add typed properties to classes

This commit is contained in:
Timothy Warren 2020-04-10 20:53:52 -04:00
parent 77df254a0c
commit ab5a3c04d0
11 changed files with 39 additions and 41 deletions

View File

@ -10,8 +10,6 @@ services:
- postgresql - postgresql
php: php:
- 7.2
- 7.3
- 7.4 - 7.4
- nightly - nightly

View File

@ -10,7 +10,7 @@ A query builder/database abstraction layer, using prepared statements for securi
## Requirements ## Requirements
* PDO extensions for the databases you wish to use * PDO extensions for the databases you wish to use
* PHP 7.2 or later * PHP 7.4 or later
## Databases Supported ## Databases Supported

View File

@ -3,7 +3,7 @@
* *
* SQL Query Builder / Database Abstraction Layer * SQL Query Builder / Database Abstraction Layer
* *
* PHP version 7.3 * PHP version 7.4
* *
* @package Query * @package Query
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>

View File

@ -24,21 +24,21 @@
"config": { "config": {
"lock": false, "lock": false,
"platform": { "platform": {
"php": "7.3" "php": "7.4"
} }
}, },
"require": { "require": {
"php": ">=7.3", "php": ">=7.4",
"ext-pdo": "*" "ext-pdo": "*"
}, },
"require-dev": { "require-dev": {
"consolidation/robo": "^2.0.0", "consolidation/robo": "^2.0.0",
"monolog/monolog": "^2.0.1", "monolog/monolog": "^2.0.1",
"phploc/phploc": "^5.0", "phploc/phploc": "^6.0",
"phpmd/phpmd": "^2.8", "phpmd/phpmd": "^2.8",
"phpstan/phpstan": "^0.12.2", "phpstan/phpstan": "^0.12.2",
"phpunit/phpunit": "^8.5", "phpunit/phpunit": "^9.1",
"sebastian/phpcpd": "^4.1", "sebastian/phpcpd": "^5",
"simpletest/simpletest": "^1.1", "simpletest/simpletest": "^1.1",
"squizlabs/php_codesniffer": "^3.0.0", "squizlabs/php_codesniffer": "^3.0.0",
"theseer/phpdox": "*" "theseer/phpdox": "*"

View File

@ -27,7 +27,7 @@ final class ConnectionManager {
* Map of named database connections * Map of named database connections
* @var array * @var array
*/ */
private $connections = []; private array $connections = [];
/** /**
* Class instance variable * Class instance variable
@ -60,7 +60,7 @@ final class ConnectionManager {
* @throws DomainException * @throws DomainException
* @return void * @return void
*/ */
public function __sleep() public function __sleep(): void
{ {
throw new DomainException('No serializing of singleton'); throw new DomainException('No serializing of singleton');
} }
@ -71,7 +71,7 @@ final class ConnectionManager {
* @throws DomainException * @throws DomainException
* @return void * @return void
*/ */
public function __wakeup() public function __wakeup(): void
{ {
throw new DomainException("Can't unserialize singleton"); throw new DomainException("Can't unserialize singleton");
} }
@ -169,7 +169,7 @@ final class ConnectionManager {
{ {
$params = (object) $params; $params = (object) $params;
$params->type = strtolower($params->type); $params->type = strtolower($params->type);
$dbType = ($params->type !== 'postgresql') ? $params->type : 'pgsql'; $dbType = ($params->type === 'postgresql') ? 'pgsql' : $params->type;
$dbType = ucfirst($dbType); $dbType = ucfirst($dbType);
// Make sure the class exists // Make sure the class exists

View File

@ -34,49 +34,49 @@ abstract class AbstractDriver
* Reference to the last executed query * Reference to the last executed query
* @var PDOStatement * @var PDOStatement
*/ */
protected $statement; protected PDOStatement $statement;
/** /**
* Start character to escape identifiers * Start character to escape identifiers
* @var string * @var string
*/ */
protected $escapeCharOpen = '"'; protected string $escapeCharOpen = '"';
/** /**
* End character to escape identifiers * End character to escape identifiers
* @var string * @var string
*/ */
protected $escapeCharClose = '"'; protected string $escapeCharClose = '"';
/** /**
* Reference to sql class * Reference to sql class
* @var SQLInterface * @var SQLInterface
*/ */
protected $sql; protected SQLInterface $sql;
/** /**
* Reference to util class * Reference to util class
* @var AbstractUtil * @var AbstractUtil
*/ */
protected $util; protected AbstractUtil $util;
/** /**
* Last query executed * Last query executed
* @var string * @var string
*/ */
protected $lastQuery = ''; protected string $lastQuery = '';
/** /**
* Prefix to apply to table names * Prefix to apply to table names
* @var string * @var string
*/ */
protected $tablePrefix = ''; protected string $tablePrefix = '';
/** /**
* Whether the driver supports 'TRUNCATE' * Whether the driver supports 'TRUNCATE'
* @var boolean * @var boolean
*/ */
protected $hasTruncate = TRUE; protected bool $hasTruncate = TRUE;
/** /**
* PDO constructor wrapper * PDO constructor wrapper

View File

@ -24,7 +24,7 @@ abstract class AbstractUtil {
* Reference to the current connection object * Reference to the current connection object
* @var DriverInterface * @var DriverInterface
*/ */
private $connection; private DriverInterface $connection;
/** /**
* Save a reference to the connection object for later use * Save a reference to the connection object for later use

View File

@ -28,14 +28,14 @@ class Driver extends AbstractDriver {
* *
* @var string * @var string
*/ */
protected $escapeCharOpen = '`'; protected string $escapeCharOpen = '`';
/** /**
* Set the backtick as the MySQL escape character * Set the backtick as the MySQL escape character
* *
* @var string * @var string
*/ */
protected $escapeCharClose = '`'; protected string $escapeCharClose = '`';
/** /**
* Connect to MySQL Database * Connect to MySQL Database

View File

@ -31,7 +31,7 @@ class Driver extends AbstractDriver {
* but no support for the actual keyword * but no support for the actual keyword
* @var boolean * @var boolean
*/ */
protected $hasTruncate = FALSE; protected bool $hasTruncate = FALSE;
/** /**
* Open SQLite Database * Open SQLite Database

View File

@ -27,14 +27,14 @@ class QueryParser {
* *
* @var DriverInterface * @var DriverInterface
*/ */
private $db; private DriverInterface $db;
/** /**
* Regex patterns for various syntax components * Regex patterns for various syntax components
* *
* @var array * @var array
*/ */
private $matchPatterns = [ private array $matchPatterns = [
'function' => '([a-zA-Z0-9_]+\((.*?)\))', 'function' => '([a-zA-Z0-9_]+\((.*?)\))',
'identifier' => '([a-zA-Z0-9_-]+\.?)+', 'identifier' => '([a-zA-Z0-9_-]+\.?)+',
'operator' => '=|AND|&&?|~|\|\|?|\^|/|>=?|<=?|-|%|OR|\+|NOT|\!=?|<>|XOR' 'operator' => '=|AND|&&?|~|\|\|?|\^|/|>=?|<=?|-|%|OR|\+|NOT|\!=?|<>|XOR'
@ -45,7 +45,7 @@ class QueryParser {
* *
* @var array * @var array
*/ */
public $matches = [ public array $matches = [
'functions' => [], 'functions' => [],
'identifiers' => [], 'identifiers' => [],
'operators' => [], 'operators' => [],

View File

@ -46,31 +46,31 @@ class State {
* Compiled 'select' clause * Compiled 'select' clause
* @var string * @var string
*/ */
protected $selectString = ''; protected string $selectString = '';
/** /**
* Compiled 'from' clause * Compiled 'from' clause
* @var string * @var string
*/ */
protected $fromString = ''; protected string $fromString = '';
/** /**
* Compiled arguments for insert / update * Compiled arguments for insert / update
* @var string * @var string
*/ */
protected $setString = ''; protected string $setString = '';
/** /**
* Order by clause * Order by clause
* @var string * @var string
*/ */
protected $orderString = ''; protected string $orderString = '';
/** /**
* Group by clause * Group by clause
* @var string * @var string
*/ */
protected $groupString = ''; protected string $groupString = '';
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! SQL Clause Arrays // ! SQL Clause Arrays
@ -80,19 +80,19 @@ class State {
* Keys for insert/update statement * Keys for insert/update statement
* @var array * @var array
*/ */
protected $setArrayKeys = []; protected array $setArrayKeys = [];
/** /**
* Key/val pairs for order by clause * Key/val pairs for order by clause
* @var array * @var array
*/ */
protected $orderArray = []; protected array $orderArray = [];
/** /**
* Key/val pairs for group by clause * Key/val pairs for group by clause
* @var array * @var array
*/ */
protected $groupArray = []; protected array $groupArray = [];
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! Other Class vars // ! Other Class vars
@ -102,19 +102,19 @@ class State {
* Values to apply to prepared statements * Values to apply to prepared statements
* @var array * @var array
*/ */
protected $values = []; protected array $values = [];
/** /**
* Values to apply to where clauses in prepared statements * Values to apply to where clauses in prepared statements
* @var array * @var array
*/ */
protected $whereValues = []; protected array $whereValues = [];
/** /**
* Value for limit string * Value for limit string
* @var integer * @var integer
*/ */
protected $limit; protected int $limit;
/** /**
* Value for offset in limit string * Value for offset in limit string
@ -135,13 +135,13 @@ class State {
* *
* @var array * @var array
*/ */
protected $queryMap = []; protected array $queryMap = [];
/** /**
* Map for having clause * Map for having clause
* @var array * @var array
*/ */
protected $havingMap = []; protected array $havingMap = [];
public function __call(string $name, array $arguments) public function __call(string $name, array $arguments)
{ {