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
php:
- 7.2
- 7.3
- 7.4
- nightly

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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