From ab5a3c04d0ef9795a1fb22491aed4684aecc4596 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Fri, 10 Apr 2020 20:53:52 -0400 Subject: [PATCH] Require 7.4, add typed properties to classes --- .travis.yml | 2 -- README.md | 2 +- build/header_comment.txt | 2 +- composer.json | 10 +++++----- src/ConnectionManager.php | 8 ++++---- src/Drivers/AbstractDriver.php | 16 ++++++++-------- src/Drivers/AbstractUtil.php | 2 +- src/Drivers/Mysql/Driver.php | 4 ++-- src/Drivers/Sqlite/Driver.php | 2 +- src/QueryParser.php | 6 +++--- src/State.php | 26 +++++++++++++------------- 11 files changed, 39 insertions(+), 41 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef2e3df..e01e986 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ services: - postgresql php: - - 7.2 - - 7.3 - 7.4 - nightly diff --git a/README.md b/README.md index 822c032..b58e4c0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build/header_comment.txt b/build/header_comment.txt index 17cd15c..f803c2d 100644 --- a/build/header_comment.txt +++ b/build/header_comment.txt @@ -3,7 +3,7 @@ * * SQL Query Builder / Database Abstraction Layer * - * PHP version 7.3 + * PHP version 7.4 * * @package Query * @author Timothy J. Warren diff --git a/composer.json b/composer.json index b68e73b..3967b57 100644 --- a/composer.json +++ b/composer.json @@ -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": "*" diff --git a/src/ConnectionManager.php b/src/ConnectionManager.php index d56da9d..6cce18e 100644 --- a/src/ConnectionManager.php +++ b/src/ConnectionManager.php @@ -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 diff --git a/src/Drivers/AbstractDriver.php b/src/Drivers/AbstractDriver.php index 8d63dfe..86b6884 100644 --- a/src/Drivers/AbstractDriver.php +++ b/src/Drivers/AbstractDriver.php @@ -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 diff --git a/src/Drivers/AbstractUtil.php b/src/Drivers/AbstractUtil.php index 89322c5..a8c881f 100644 --- a/src/Drivers/AbstractUtil.php +++ b/src/Drivers/AbstractUtil.php @@ -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 diff --git a/src/Drivers/Mysql/Driver.php b/src/Drivers/Mysql/Driver.php index 4dc872a..5b9a0b8 100644 --- a/src/Drivers/Mysql/Driver.php +++ b/src/Drivers/Mysql/Driver.php @@ -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 diff --git a/src/Drivers/Sqlite/Driver.php b/src/Drivers/Sqlite/Driver.php index cdfe2db..b772215 100644 --- a/src/Drivers/Sqlite/Driver.php +++ b/src/Drivers/Sqlite/Driver.php @@ -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 diff --git a/src/QueryParser.php b/src/QueryParser.php index 6c4a677..caa9ab4 100644 --- a/src/QueryParser.php +++ b/src/QueryParser.php @@ -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' => [], diff --git a/src/State.php b/src/State.php index 71f1186..e2c8c5d 100644 --- a/src/State.php +++ b/src/State.php @@ -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) {