diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f1f1ed..ab5a35b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ All notable changes to this project will be documented in this file. This project adhere to the [Semantic Versioning](http://semver.org/) standard. +## [1.0.7] 2023-10-23 + +* Tweak - Updates around `trim()` for php 8.1 compatibility. +* Tweak - Force `From()` and `Select()` to convert passed non-strings to an empty string. + +## [1.0.6] 2023-09-05 + +* Tweak - Fix array shape for errors in `DatabaseQueryException` + +## [1.0.5] 2023-09-05 + +* Tweak - Updating docblock for `whereExists()` and `whereNotExists()` in response to a PHPStan flag. + +## [1.0.4] 2023-06-06 + +* Tweak - Added more documentation for methods provided by DB. +* Tweak - Adjusted docblocks to better declare types. + ## [1.0.3] 2022-11-22 * Tweak - Set composer.json `config.platform.php` to `7.0`. diff --git a/src/DB/DB.php b/src/DB/DB.php index 1a4605e..f0cf42b 100644 --- a/src/DB/DB.php +++ b/src/DB/DB.php @@ -173,11 +173,11 @@ public static function prefix( $tableName ) { * Create QueryBuilder instance * * @param string|RawSQL $table - * @param null|string $alias + * @param string|null $alias * * @return QueryBuilder */ - public static function table( $table, $alias = null ) { + public static function table( $table, $alias = '' ) { $builder = new QueryBuilder(); $builder->from( $table, $alias ); diff --git a/src/DB/QueryBuilder/Clauses/From.php b/src/DB/QueryBuilder/Clauses/From.php index 8c0dcb7..4ac4674 100644 --- a/src/DB/QueryBuilder/Clauses/From.php +++ b/src/DB/QueryBuilder/Clauses/From.php @@ -22,8 +22,8 @@ class From { * @param string|RawSQL $table * @param string|null $alias */ - public function __construct( $table, $alias = null ) { + public function __construct( $table, $alias = '' ) { $this->table = QueryBuilder::prefixTable( $table ); - $this->alias = trim( $alias ); + $this->alias = is_scalar( $alias ) ? trim( (string) $alias ) : ''; } } diff --git a/src/DB/QueryBuilder/Clauses/Join.php b/src/DB/QueryBuilder/Clauses/Join.php index 6a79fa0..63c640d 100644 --- a/src/DB/QueryBuilder/Clauses/Join.php +++ b/src/DB/QueryBuilder/Clauses/Join.php @@ -30,10 +30,10 @@ class Join { * @param string $joinType \StellarWP\DB\QueryBuilder\Types\JoinType * @param string|null $alias */ - public function __construct( $joinType, $table, $alias = null ) { + public function __construct( $joinType, $table, $alias = '' ) { $this->table = QueryBuilder::prefixTable( $table ); $this->joinType = $this->getJoinType( $joinType ); - $this->alias = trim( $alias ); + $this->alias = is_scalar( $alias ) ? trim( (string) $alias ) : ''; } /** diff --git a/src/DB/QueryBuilder/Clauses/Select.php b/src/DB/QueryBuilder/Clauses/Select.php index 56eaaf9..74831cd 100644 --- a/src/DB/QueryBuilder/Clauses/Select.php +++ b/src/DB/QueryBuilder/Clauses/Select.php @@ -20,8 +20,8 @@ class Select { * @param string $column * @param string|null $alias */ - public function __construct( $column, $alias = null ) { + public function __construct( $column, $alias = '' ) { $this->column = trim( $column ); - $this->alias = trim( $alias ); + $this->alias = is_scalar( $alias ) ? trim( (string) $alias ) : ''; } } diff --git a/src/DB/QueryBuilder/Concerns/FromClause.php b/src/DB/QueryBuilder/Concerns/FromClause.php index c0e4daf..21f079a 100644 --- a/src/DB/QueryBuilder/Concerns/FromClause.php +++ b/src/DB/QueryBuilder/Concerns/FromClause.php @@ -21,7 +21,7 @@ trait FromClause { * * @return $this */ - public function from( $table, $alias = null ) { + public function from( $table, $alias = '' ) { $this->froms[] = new From( $table, $alias ); return $this; diff --git a/src/DB/QueryBuilder/Concerns/JoinClause.php b/src/DB/QueryBuilder/Concerns/JoinClause.php index 0ba2fe7..43c5978 100644 --- a/src/DB/QueryBuilder/Concerns/JoinClause.php +++ b/src/DB/QueryBuilder/Concerns/JoinClause.php @@ -40,7 +40,7 @@ public function join( $callback ) { * * @return static */ - public function leftJoin( $table, $column1, $column2, $alias = null ) { + public function leftJoin( $table, $column1, $column2, $alias = '' ) { $this->join( function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias ) { $builder @@ -60,7 +60,7 @@ function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias * * @return static */ - public function innerJoin( $table, $column1, $column2, $alias = null ) { + public function innerJoin( $table, $column1, $column2, $alias = '' ) { $this->join( function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias ) { $builder @@ -80,7 +80,7 @@ function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias * * @return static */ - public function rightJoin( $table, $column1, $column2, $alias = null ) { + public function rightJoin( $table, $column1, $column2, $alias = '' ) { $this->join( function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias ) { $builder diff --git a/src/DB/QueryBuilder/JoinQueryBuilder.php b/src/DB/QueryBuilder/JoinQueryBuilder.php index 27d2731..a5a4499 100644 --- a/src/DB/QueryBuilder/JoinQueryBuilder.php +++ b/src/DB/QueryBuilder/JoinQueryBuilder.php @@ -19,11 +19,11 @@ class JoinQueryBuilder { /** * @param string|RawSQL $table - * @param null|string $alias + * @param string|null $alias * * @return $this */ - public function leftJoin( $table, $alias = null ) { + public function leftJoin( $table, $alias = '' ) { return $this->join( JoinType::LEFT, $table, @@ -33,11 +33,11 @@ public function leftJoin( $table, $alias = null ) { /** * @param string|RawSQL $table - * @param null|string $alias + * @param string|null $alias * * @return $this */ - public function rightJoin( $table, $alias = null ) { + public function rightJoin( $table, $alias = '' ) { return $this->join( JoinType::RIGHT, $table, @@ -47,11 +47,11 @@ public function rightJoin( $table, $alias = null ) { /** * @param string|RawSQL $table - * @param null|string $alias + * @param string|null $alias * * @return $this */ - public function innerJoin( $table, $alias = null ) { + public function innerJoin( $table, $alias = '' ) { return $this->join( JoinType::INNER, $table, @@ -122,11 +122,11 @@ public function joinRaw( $sql, ...$args ) { * * @param string $joinType * @param string|RawSQL $table - * @param string $alias + * @param string|null $alias * * @return $this */ - private function join( $joinType, $table, $alias ) { + private function join( $joinType, $table, $alias = '' ) { $this->joins[] = new Join( $joinType, $table,