diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9364eaa0..51fca5c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,6 @@ jobs: runs-on: ubuntu-latest container: joomlaprojects/docker-images:php8.4 needs: [code-style-php] - continue-on-error: true steps: - uses: actions/checkout@v4 - uses: actions/cache/restore@v4 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e00f4195..36246507 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -126,12 +126,6 @@ parameters: count: 1 path: src/DatabaseQuery.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 9 - path: src/DatabaseQuery.php - - message: '#^Instanceof between Joomla\\Database\\DatabaseInterface and Joomla\\Database\\DatabaseInterface will always evaluate to true\.$#' identifier: instanceof.alwaysTrue @@ -144,30 +138,12 @@ parameters: count: 1 path: src/DatabaseQuery.php - - - message: '#^Left side of \|\| is always true\.$#' - identifier: booleanOr.leftAlwaysTrue - count: 1 - path: src/DatabaseQuery.php - - - - message: '#^Parameter \#2 \$array of function implode expects array\|null, string given\.$#' - identifier: argument.type - count: 1 - path: src/DatabaseQuery.php - - message: '#^Parameter \#2 \$elements of class Joomla\\Database\\Query\\QueryElement constructor expects array\\|string, null given\.$#' identifier: argument.type count: 1 path: src/DatabaseQuery.php - - - message: '#^Property Joomla\\Database\\DatabaseQuery\:\:\$querySet has unknown class Joomla\\Database\\Query\\DatabaseQuery as its type\.$#' - identifier: class.notFound - count: 1 - path: src/DatabaseQuery.php - - message: '#^Return type \(string\) of method Joomla\\Database\\DatabaseQuery\:\:length\(\) should be compatible with return type \(int\) of method Joomla\\Database\\QueryInterface\:\:length\(\)$#' identifier: method.childReturnType @@ -216,18 +192,6 @@ parameters: count: 1 path: src/Mysql/MysqlDriver.php - - - message: '#^Method Joomla\\Database\\Mysql\\MysqlImporter\:\:getKeyLookup\(\) has Exception in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Mysql/MysqlImporter.php - - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 1 - path: src/Mysql/MysqlQuery.php - - message: '#^Call to function is_callable\(\) with array\{mysqli, ''close''\} will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -264,12 +228,6 @@ parameters: count: 1 path: src/Mysqli/MysqliDriver.php - - - message: '#^Method Joomla\\Database\\Mysqli\\MysqliDriver\:\:connect\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Mysqli/MysqliDriver.php - - message: '#^Method Joomla\\Database\\Mysqli\\MysqliDriver\:\:serverClaimsUtf8mb4Support\(\) is unused\.$#' identifier: method.unused @@ -300,12 +258,6 @@ parameters: count: 2 path: src/Mysqli/MysqliDriver.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 1 - path: src/Mysqli/MysqliQuery.php - - message: '#^PHPDoc type array of property Joomla\\Database\\Mysqli\\MysqliQuery\:\:\$nullDatetimeList is not covariant with PHPDoc type array\ of overridden property Joomla\\Database\\DatabaseQuery\:\:\$nullDatetimeList\.$#' identifier: property.phpDocType @@ -360,12 +312,6 @@ parameters: count: 4 path: src/Pdo/PdoDriver.php - - - message: '#^Method Joomla\\Database\\Pdo\\PdoDriver\:\:connect\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Pdo/PdoDriver.php - - message: '#^PHPDoc type PDO of property Joomla\\Database\\Pdo\\PdoDriver\:\:\$connection is not covariant with PHPDoc type resource of overridden property Joomla\\Database\\DatabaseDriver\:\:\$connection\.$#' identifier: property.phpDocType @@ -402,12 +348,6 @@ parameters: count: 1 path: src/Pgsql/PgsqlDriver.php - - - message: '#^Method Joomla\\Database\\Pgsql\\PgsqlDriver\:\:getTableCreate\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Pgsql/PgsqlDriver.php - - message: '#^Strict comparison using \=\=\= between string and 0 will always evaluate to false\.$#' identifier: identical.alwaysFalse @@ -498,12 +438,6 @@ parameters: count: 1 path: src/Pgsql/PgsqlImporter.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 12 - path: src/Pgsql/PgsqlQuery.php - - message: '#^Instanceof between string and \$this\(Joomla\\Database\\Pgsql\\PgsqlQuery\) will always evaluate to false\.$#' identifier: instanceof.alwaysFalse @@ -523,8 +457,14 @@ parameters: path: src/Pgsql/PgsqlQuery.php - - message: '#^Ternary operator condition is always true\.$#' - identifier: ternary.alwaysTrue + message: '#^Property Joomla\\Database\\DatabaseQuery\:\:\$limit \(int\|null\) does not accept Joomla\\Database\\Query\\QueryElement\.$#' + identifier: assign.propertyType + count: 1 + path: src/Pgsql/PgsqlQuery.php + + - + message: '#^Property Joomla\\Database\\DatabaseQuery\:\:\$offset \(int\|null\) does not accept Joomla\\Database\\Query\\QueryElement\.$#' + identifier: assign.propertyType count: 1 path: src/Pgsql/PgsqlQuery.php @@ -552,72 +492,12 @@ parameters: count: 1 path: src/Sqlite/SqliteDriver.php - - - message: '#^Method Joomla\\Database\\Sqlite\\SqliteDriver\:\:alterDbCharacterSet\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlite/SqliteDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlite\\SqliteDriver\:\:connect\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlite/SqliteDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlite\\SqliteDriver\:\:createDatabase\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlite/SqliteDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlite\\SqliteDriver\:\:getConnectionCollation\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlite/SqliteDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlite\\SqliteDriver\:\:getConnectionEncryption\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlite/SqliteDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlite\\SqliteDriver\:\:lockTable\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlite/SqliteDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlite\\SqliteDriver\:\:unlockTables\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlite/SqliteDriver.php - - message: '#^Unreachable statement \- code above always terminates\.$#' identifier: deadCode.unreachable count: 1 path: src/Sqlite/SqliteDriver.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 1 - path: src/Sqlite/SqliteQuery.php - - - - message: '#^Left side of \|\| is always true\.$#' - identifier: booleanOr.leftAlwaysTrue - count: 1 - path: src/Sqlite/SqliteQuery.php - - - - message: '#^Result of \|\| is always true\.$#' - identifier: booleanOr.alwaysTrue - count: 1 - path: src/Sqlite/SqliteQuery.php - - message: '#^Unsafe usage of new static\(\)\.$#' identifier: new.static @@ -642,28 +522,10 @@ parameters: count: 4 path: src/Sqlsrv/SqlsrvDriver.php - - - message: '#^Method Joomla\\Database\\Sqlsrv\\SqlsrvDriver\:\:connect\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlsrv/SqlsrvDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlsrv\\SqlsrvDriver\:\:lockTable\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlsrv/SqlsrvDriver.php - - - - message: '#^Method Joomla\\Database\\Sqlsrv\\SqlsrvDriver\:\:unlockTables\(\) has RuntimeException in PHPDoc @throws tag but it''s not thrown\.$#' - identifier: throws.unusedType - count: 1 - path: src/Sqlsrv/SqlsrvDriver.php - - message: '#^Parameter \#2 \$array of function implode expects array\, list\ given\.$#' identifier: argument.type - count: 1 + count: 2 path: src/Sqlsrv/SqlsrvDriver.php - @@ -690,24 +552,12 @@ parameters: count: 1 path: src/Sqlsrv/SqlsrvQuery.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 14 - path: src/Sqlsrv/SqlsrvQuery.php - - message: '#^Instanceof between Joomla\\Database\\DatabaseInterface and Joomla\\Database\\DatabaseInterface will always evaluate to true\.$#' identifier: instanceof.alwaysTrue count: 1 path: src/Sqlsrv/SqlsrvQuery.php - - - message: '#^Left side of \|\| is always true\.$#' - identifier: booleanOr.leftAlwaysTrue - count: 1 - path: src/Sqlsrv/SqlsrvQuery.php - - message: '#^Offset int\<1, max\> on list in isset\(\) does not exist\.$#' identifier: isset.offset @@ -720,18 +570,6 @@ parameters: count: 1 path: src/Sqlsrv/SqlsrvQuery.php - - - message: '#^Parameter \#2 \$array of function implode expects array\, array\ given\.$#' - identifier: argument.type - count: 1 - path: src/Sqlsrv/SqlsrvQuery.php - - - - message: '#^Result of \|\| is always true\.$#' - identifier: booleanOr.alwaysTrue - count: 1 - path: src/Sqlsrv/SqlsrvQuery.php - - message: '#^Return type \(string\) of method Joomla\\Database\\Sqlsrv\\SqlsrvQuery\:\:length\(\) should be compatible with return type \(int\) of method Joomla\\Database\\QueryInterface\:\:length\(\)$#' identifier: method.childReturnType diff --git a/src/DatabaseInterface.php b/src/DatabaseInterface.php index 9b65b24b..5f3e41c9 100644 --- a/src/DatabaseInterface.php +++ b/src/DatabaseInterface.php @@ -470,7 +470,7 @@ public function lockTable($tableName); * @param array|string $text A string or an array of strings to quote. * @param boolean $escape True (default) to escape the string, false to leave it unchanged. * - * @return string + * @return array|string The quoted input string. * * @since 2.0.0 */ diff --git a/src/DatabaseQuery.php b/src/DatabaseQuery.php index e7866ab5..6abc16f8 100644 --- a/src/DatabaseQuery.php +++ b/src/DatabaseQuery.php @@ -20,26 +20,26 @@ * @property-read array $bounded Holds key / value pair of bound objects. * @property-read array $parameterMapping Mapping array for parameter types. * @property-read DatabaseInterface $db The database driver. - * @property-read string $sql The SQL query (if a direct query string was provided). + * @property-read string|null $sql The SQL query (if a direct query string was provided). * @property-read string $type The query type. * @property-read string|null $alias The query alias. * @property-read Query\QueryElement $element The query element for a generic query (type = null). - * @property-read Query\QueryElement $select The select element. - * @property-read Query\QueryElement $delete The delete element. - * @property-read Query\QueryElement $update The update element. - * @property-read Query\QueryElement $insert The insert element. - * @property-read Query\QueryElement $from The from element. + * @property-read Query\QueryElement|null $select The select element. + * @property-read Query\QueryElement|null $delete The delete element. + * @property-read Query\QueryElement|null $update The update element. + * @property-read Query\QueryElement|null $insert The insert element. + * @property-read Query\QueryElement|null $from The from element. * @property-read Query\QueryElement[]|null $join The join elements. - * @property-read Query\QueryElement $set The set element. - * @property-read Query\QueryElement $where The where element. - * @property-read Query\QueryElement $group The group element. - * @property-read Query\QueryElement $having The having element. - * @property-read Query\QueryElement $columns The column list for an INSERT statement. - * @property-read Query\QueryElement $values The values list for an INSERT statement. - * @property-read Query\QueryElement $order The order element. - * @property-read boolean $autoIncrementField The auto increment insert field element. - * @property-read Query\QueryElement $call The call element. - * @property-read Query\QueryElement $exec The exec element. + * @property-read Query\QueryElement|null $set The set element. + * @property-read Query\QueryElement|null $where The where element. + * @property-read Query\QueryElement|null $group The group element. + * @property-read Query\QueryElement|null $having The having element. + * @property-read Query\QueryElement|null $columns The column list for an INSERT statement. + * @property-read Query\QueryElement|null $values The values list for an INSERT statement. + * @property-read Query\QueryElement|null $order The order element. + * @property-read boolean|null $autoIncrementField The auto increment insert field element. + * @property-read Query\QueryElement|null $call The call element. + * @property-read Query\QueryElement|null $exec The exec element. * @property-read Query\QueryElement[]|null $merge The list of query elements. * @property-read DatabaseQuery|null $querySet The query object. * @property-read array|null $selectRowNumber Details of window function. @@ -83,7 +83,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The SQL query (if a direct query string was provided). * - * @var string + * @var ?string * @since 1.0 */ protected $sql; @@ -115,7 +115,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The select element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $select; @@ -123,7 +123,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The delete element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $delete; @@ -131,7 +131,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The update element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $update; @@ -139,7 +139,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The insert element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $insert; @@ -147,7 +147,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The from element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $from; @@ -155,7 +155,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The join elements. * - * @var Query\QueryElement[] + * @var ?Query\QueryElement[] * @since 1.0 */ protected $join; @@ -163,7 +163,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The set element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $set; @@ -171,7 +171,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The where element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $where; @@ -179,7 +179,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The group by element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $group; @@ -187,7 +187,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The having element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $having; @@ -195,7 +195,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The column list for an INSERT statement. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $columns; @@ -203,7 +203,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The values list for an INSERT statement. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $values; @@ -211,7 +211,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The order element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $order; @@ -219,7 +219,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The auto increment insert field element. * - * @var boolean + * @var ?boolean * @since 1.0 */ protected $autoIncrementField = false; @@ -227,7 +227,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The call element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $call; @@ -235,7 +235,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The exec element. * - * @var Query\QueryElement + * @var ?Query\QueryElement * @since 1.0 */ protected $exec; @@ -243,7 +243,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The list of query elements, which may include UNION, UNION ALL, EXCEPT and INTERSECT. * - * @var Query\QueryElement[] + * @var ?Query\QueryElement[] * @since 2.0.0 */ protected $merge; @@ -251,7 +251,7 @@ abstract class DatabaseQuery implements QueryInterface /** * The query object. * - * @var Query\DatabaseQuery + * @var ?DatabaseQuery * @since 2.0.0 */ protected $querySet; @@ -1466,7 +1466,7 @@ public function q($text, $escape = true) * @param array|string $text A string or an array of strings to quote. * @param boolean $escape True (default) to escape the string, false to leave it unchanged. * - * @return string The quoted input string. + * @return array|string The quoted input string. * * @since 1.0 * @throws \RuntimeException if the internal db property is not a valid object. diff --git a/src/Query/MysqlQueryBuilder.php b/src/Query/MysqlQueryBuilder.php index 1ce5000b..7ac3139b 100644 --- a/src/Query/MysqlQueryBuilder.php +++ b/src/Query/MysqlQueryBuilder.php @@ -138,7 +138,7 @@ public function groupConcat($expression, $separator = ',') * @param array|string $text A string or an array of strings to quote. * @param boolean $escape True (default) to escape the string, false to leave it unchanged. * - * @return string The quoted input string. + * @return array|string The quoted input string. * * @since 2.0.0 * @throws \RuntimeException if the internal db property is not a valid object. diff --git a/src/Query/PostgresqlQueryBuilder.php b/src/Query/PostgresqlQueryBuilder.php index d54464e5..a520fc5e 100644 --- a/src/Query/PostgresqlQueryBuilder.php +++ b/src/Query/PostgresqlQueryBuilder.php @@ -19,7 +19,7 @@ trait PostgresqlQueryBuilder /** * The FOR UPDATE element used in "FOR UPDATE" lock * - * @var QueryElement + * @var ?QueryElement * @since 2.0.0 */ protected $forUpdate; @@ -27,7 +27,7 @@ trait PostgresqlQueryBuilder /** * The FOR SHARE element used in "FOR SHARE" lock * - * @var QueryElement + * @var ?QueryElement * @since 2.0.0 */ protected $forShare; @@ -35,7 +35,7 @@ trait PostgresqlQueryBuilder /** * The NOWAIT element used in "FOR SHARE" and "FOR UPDATE" lock * - * @var QueryElement + * @var ?QueryElement * @since 2.0.0 */ protected $noWait; @@ -59,7 +59,7 @@ trait PostgresqlQueryBuilder /** * The RETURNING element of INSERT INTO * - * @var QueryElement + * @var ?QueryElement * @since 2.0.0 */ protected $returning; diff --git a/src/Sqlsrv/SqlsrvDriver.php b/src/Sqlsrv/SqlsrvDriver.php index dadbb27a..e2a430c7 100644 --- a/src/Sqlsrv/SqlsrvDriver.php +++ b/src/Sqlsrv/SqlsrvDriver.php @@ -249,7 +249,7 @@ public function escape($text, $extra = false) * @param mixed $text A string or an array of strings to quote. * @param boolean $escape True (default) to escape the string, false to leave it unchanged. * - * @return string The quoted input string. + * @return array|string The quoted input string. * * @since 1.6.0 */