Skip to content

Commit

Permalink
Merge branch '3.3.x' into 3.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Feb 13, 2022
2 parents 6b7df36 + 7ac3095 commit 6283869
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 36 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ env:
jobs:
phpunit-smoke-check:
name: "PHPUnit with SQLite"
runs-on: "ubuntu-20.04"
runs-on: "${{ matrix.os }}"

strategy:
matrix:
os:
- "ubuntu-20.04"
php-version:
- "7.3"
- "7.4"
Expand All @@ -43,8 +45,12 @@ jobs:
dependencies:
- "highest"
include:
- dependencies: "lowest"
- os: "ubuntu-20.04"
php-version: "7.3"
dependencies: "lowest"
- os: "ubuntu-18.04"
php-version: "8.1"
dependencies: "highest"

steps:
- name: "Checkout"
Expand All @@ -64,6 +70,10 @@ jobs:
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Print SQLite version"
run: >
php -r 'printf("Testing with libsqlite version %s\n", (new PDO("sqlite::memory:"))->query("select sqlite_version()")->fetch()[0]);'
- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --coverage-clover=coverage.xml"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.0"
- "8.1"

steps:
- name: "Checkout code"
Expand All @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.0"
- "8.1"

steps:
- name: Checkout code
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
"require-dev": {
"doctrine/coding-standard": "9.0.0",
"jetbrains/phpstorm-stubs": "2021.1",
"phpstan/phpstan": "1.4.0",
"phpstan/phpstan": "1.4.6",
"phpstan/phpstan-strict-rules": "^1.1",
"phpunit/phpunit": "9.5.11",
"phpunit/phpunit": "9.5.13",
"psalm/plugin-phpunit": "0.16.1",
"squizlabs/php_codesniffer": "3.6.2",
"symfony/cache": "^5.2|^6.0",
"symfony/console": "^2.7|^3.0|^4.0|^5.0|^6.0",
"vimeo/psalm": "4.16.1"
"vimeo/psalm": "4.20.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
Expand Down
31 changes: 17 additions & 14 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ parameters:
paths:
- src/Schema/AbstractSchemaManager.php

# See https://github.com/doctrine/dbal/pull/4707
# TODO: remove in 4.0.0
-
message: '~^Dynamic call to static method Doctrine\\DBAL\\Schema\\Comparator::compareSchemas\(\)\.$~'
paths:
- src/Schema/AbstractSchemaManager.php
- src/Schema/Comparator.php
- src/Schema/Schema.php

# https://github.com/phpstan/phpstan/issues/1901
-
message: '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string\|null\.$~'
Expand Down Expand Up @@ -129,12 +120,24 @@ parameters:
# TODO: remove in 4.0.0
- "~Call to function method_exists\\(\\) with Doctrine\\\\DBAL\\\\Driver\\\\Connection and 'getNativeConnection' will always evaluate to true\\.~"

# TODO: remove in 4.0.0
# Fixing the issue would cause a BC break.
# TODO: fix in 4.0.0
-
message: '~^Call to an undefined method.*compareSchemas.*$~'
message: '~^Method Doctrine\\DBAL\\Connection::executeUpdate\(\) should return int but returns int\|string\.$~'
paths:
- src/Schema/AbstractSchemaManager.php
- src/Schema/Comparator.php
- src/Schema/Schema.php
- src/Connection.php
-
message: '~^Method Doctrine\\DBAL\\Connection::exec\(\) should return int but returns int\|string\.$~'
paths:
- src/Connection.php
-
message: '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\Connection::exec\(\) should return int but returns int\|string\.$~'
paths:
- src/Driver/Mysqli/Connection.php
-
message: '~^Method Doctrine\\DBAL\\Query\\QueryBuilder::executeStatement\(\) should return int but returns int\|string\.$~'
paths:
- src/Query/QueryBuilder.php

includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
32 changes: 26 additions & 6 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@
<file name="src/Schema/View.php"/>
</errorLevel>
</PropertyNotSetInConstructor>
<RedundantCondition>
<errorLevel type="suppress">
<!--
See https://github.com/vimeo/psalm/pull/7660
-->
<file name="src/Driver/Mysqli/Exception/ConnectionFailed.php"/>
</errorLevel>
</RedundantCondition>
<!-- This is necessary pre 4.0 -->
<RedundantCastGivenDocblockType>
<errorLevel type="suppress">
Expand Down Expand Up @@ -470,10 +478,28 @@
<referencedClass name="Doctrine\DBAL\Portability\T"/>
</errorLevel>
</UndefinedDocblockClass>
<InvalidReturnStatement>
<errorLevel type="suppress">
<!-- lastInsertId has a return type that does not match the one defined in the interface-->
<file name="src/Driver/Mysqli/Connection.php"/>
<!--
This issue should be fixed in 4.0
-->
<file name="src/Connection.php"/>
<file name="src/Statement.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
</InvalidReturnStatement>
<InvalidReturnType>
<errorLevel type="suppress">
<!-- lastInsertId has a return type that does not match the one defined in the interface-->
<file name="src/Driver/Mysqli/Connection.php"/>
<!--
This issue should be fixed in 4.0
-->
<file name="src/Connection.php"/>
<file name="src/Statement.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
</InvalidReturnType>
<InvalidScalarArgument>
Expand All @@ -495,11 +521,5 @@
<referencedFunction name="db2_autocommit"/>
</errorLevel>
</InvalidScalarArgument>
<InvalidReturnStatement>
<errorLevel type="suppress">
<!-- lastInsertId has a return type that does not match the one defined in the interface-->
<file name="src/Driver/Mysqli/Connection.php"/>
</errorLevel>
</InvalidReturnStatement>
</issueHandlers>
</psalm>
12 changes: 5 additions & 7 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class Connection
* The parameters used during creation of the Connection instance.
*
* @var array<string,mixed>
* @phpstan-var array<string,mixed>
* @psalm-var Params
*/
private $params;
Expand Down Expand Up @@ -215,7 +214,6 @@ public function __construct(
*
* @return array<string,mixed>
* @psalm-return Params
* @phpstan-return array<string,mixed>
*/
public function getParams()
{
Expand Down Expand Up @@ -625,7 +623,7 @@ private function addCriteriaCondition(
* @param array<string, mixed> $criteria Deletion criteria
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $types Parameter types
*
* @return int The number of affected rows.
* @return int|string The number of affected rows.
*
* @throws Exception
*/
Expand Down Expand Up @@ -662,7 +660,7 @@ public function close()
*
* @param int $level The level to set.
*
* @return int
* @return int|string
*
* @throws Exception
*/
Expand Down Expand Up @@ -699,7 +697,7 @@ public function getTransactionIsolation()
* @param array<string, mixed> $criteria Update criteria
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $types Parameter types
*
* @return int The number of affected rows.
* @return int|string The number of affected rows.
*
* @throws Exception
*/
Expand Down Expand Up @@ -734,7 +732,7 @@ public function update($table, array $data, array $criteria, array $types = [])
* @param array<string, mixed> $data Column-value pairs
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $types Parameter types
*
* @return int The number of affected rows.
* @return int|string The number of affected rows.
*
* @throws Exception
*/
Expand Down Expand Up @@ -1127,7 +1125,7 @@ public function executeCacheQuery($sql, $params, $types, QueryCacheProfile $qcp)
* @param list<mixed>|array<string, mixed> $params Statement parameters
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $types Parameter types
*
* @return int The number of affected rows.
* @return int|string The number of affected rows.
*
* @throws Exception
*/
Expand Down
7 changes: 6 additions & 1 deletion src/Driver/Mysqli/Exception/ConnectionFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use mysqli_sql_exception;
use ReflectionProperty;

use function assert;

/**
* @internal
*
Expand All @@ -18,7 +20,10 @@ final class ConnectionFailed extends AbstractException
{
public static function new(mysqli $connection): self
{
return new self($connection->connect_error, 'HY000', $connection->connect_errno);
$error = $connection->connect_error;
assert($error !== null);

return new self($error, 'HY000', $connection->connect_errno);
}

public static function upcast(mysqli_sql_exception $exception): self
Expand Down
2 changes: 2 additions & 0 deletions src/DriverManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* @psalm-type Params = array{
* charset?: string,
* dbname?: string,
* defaultTableOptions?: array<string, mixed>,
* default_dbname?: string,
* driver?: key-of<self::DRIVER_MAP>,
* driverClass?: class-string<Driver>,
Expand All @@ -61,6 +62,7 @@
* port?: int,
* primary?: OverrideParams,
* replica?: array<OverrideParams>,
* serverVersion?: string,
* sharding?: array<string,mixed>,
* slaves?: array<OverrideParams>,
* user?: string,
Expand Down
2 changes: 1 addition & 1 deletion src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public function executeStatement(): int
*
* @deprecated Use {@see executeQuery()} or {@see executeStatement()} instead.
*
* @return Result|int
* @return Result|int|string
*
* @throws Exception
*/
Expand Down

0 comments on commit 6283869

Please sign in to comment.