Skip to content

Commit

Permalink
Merge branch '3.0.x' into 3.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Mar 6, 2021
2 parents d1b8728 + f18aee0 commit 246e7c1
Show file tree
Hide file tree
Showing 40 changed files with 471 additions and 234 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"require-dev": {
"doctrine/coding-standard": "8.2.0",
"jetbrains/phpstorm-stubs": "2019.3",
"phpstan/phpstan": "0.12.57",
"phpstan/phpstan": "0.12.80",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "9.5.0",
"psalm/plugin-phpunit": "0.13.0",
Expand Down
26 changes: 13 additions & 13 deletions docs/en/reference/data-retrieval-and-manipulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ Prepare a given SQL statement and return the
<?php
$statement = $conn->prepare('SELECT * FROM user');
$statement->execute();
$users = $statement->fetchAllAssociative();
$resultSet = $statement->execute();
$users = $resultSet->fetchAllAssociative();
/*
array(
0 => array(
'username' => 'jwage',
'password' => 'changeme'
'email' => 'j.wage@example.com'
)
)
*/
Expand Down Expand Up @@ -353,7 +353,7 @@ parameters to the execute method, then returning the statement:
/*
array(
0 => 'jwage',
1 => 'changeme'
1 => 'j.wage@example.com'
)
*/
Expand All @@ -376,7 +376,7 @@ Execute the query and fetch all results into an array:
array(
0 => array(
'username' => 'jwage',
'password' => 'changeme'
'email' => 'j.wage@example.com'
)
)
*/
Expand All @@ -389,11 +389,11 @@ Execute the query and fetch the first two columns into an associative array as k
.. code-block:: php
<?php
$users = $conn->fetchAllKeyValue('SELECT username, password FROM user');
$users = $conn->fetchAllKeyValue('SELECT username, email FROM user');
/*
array(
'jwage' => 'changeme',
'jwage' => 'j.wage@example.com',
)
*/
Expand All @@ -409,13 +409,13 @@ an associative array of the rest of the columns and their values:
.. code-block:: php
<?php
$users = $conn->fetchAllAssociativeIndexed('SELECT id, username, password FROM user');
$users = $conn->fetchAllAssociativeIndexed('SELECT id, username, email FROM user');
/*
array(
1 => array(
'username' => 'jwage',
'password' => 'changeme',
'email' => 'j.wage@example.com'
)
)
*/
Expand All @@ -433,7 +433,7 @@ Numeric index retrieval of first result row of the given query:
/*
array(
0 => 'jwage',
1 => 'changeme'
1 => 'j.wage@example.com'
)
*/
Expand All @@ -460,7 +460,7 @@ Retrieve associative array of the first result row.
/*
array(
'username' => 'jwage',
'password' => 'changeme'
'email' => 'j.wage@example.com'
)
*/
Expand All @@ -474,7 +474,7 @@ Execute the query and iterate over the first two columns as keys and values resp
.. code-block:: php
<?php
foreach ($conn->iterateKeyValue('SELECT username, password FROM user') as $username => $password) {
foreach ($conn->iterateKeyValue('SELECT username, email FROM user') as $username => $email) {
// ...
}
Expand All @@ -490,7 +490,7 @@ an associative array of the rest of the columns and their values:
.. code-block:: php
<?php
foreach ($conn->iterateAssociativeIndexed('SELECT id, username, password FROM user') as $id => $data) {
foreach ($conn->iterateAssociativeIndexed('SELECT id, username, email FROM user') as $id => $data) {
// ...
}
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,10 @@ parameters:
message: '~^Only iterables can be unpacked, array<int, mixed>\|false given in argument #1\.$~'
paths:
- %currentWorkingDirectory%/tests/Functional/Platform/DefaultExpressionTest.php

-
message: '~^Instanceof between Doctrine\\DBAL\\Platforms\\Keywords\\KeywordList and Doctrine\\DBAL\\Platforms\\Keywords\\KeywordList will always evaluate to true\.~'
paths:
- %currentWorkingDirectory%/src/Platforms/AbstractPlatform.php
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
170 changes: 167 additions & 3 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="3"
resolveFromConfigFile="true"
errorLevel="2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down Expand Up @@ -40,6 +38,76 @@
<file name="src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php"/>
</errorLevel>
</ConflictingReferenceConstraint>
<DeprecatedClass>
<errorLevel type="suppress">
<!--
This suppression should be removed once Composer 1
is no longer supported.
-->
<file name="src/Tools/Console/ConsoleRunner.php"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedMethod>
<errorLevel type="suppress">
<!--
This suppression should be removed after 2022
See https://github.com/doctrine/dbal/pull/4317
-->
<file name="tests/Functional/LegacyAPITest.php"/>
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/3865
-->
<file name="src/Query/Expression/CompositeExpression.php"/>
<file name="tests/Query/Expression/CompositeExpressionTest.php"/>
<file name="tests/Query/Expression/ExpressionBuilderTest.php"/>
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/4518
-->
<file name="src/Query/QueryBuilder.php"/>
<file name="src/Tools/Console/Command/ReservedWordsCommand.php"/>
<directory name="tests" />
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
<errorLevel type="suppress">
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/4518
-->
<file name="src/Connection.php"/>
</errorLevel>
</DeprecatedProperty>
<DocblockTypeContradiction>
<errorLevel type="suppress">
<!--
Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/766
-->
<file name="src/Driver/Mysqli/Result.php"/>
<!--
These issues can be mostly divided in the following categories:
1. Union types not supported at the language level (require dropping PHP 7 support)
2. Associative arrays with typed elements used instead of classes (require breaking API changes)
-->
<file name="src/Connection.php"/>
<file name="src/Driver/IBMDB2/Statement.php"/>
<file name="src/DriverManager.php"/>
<file name="src/Platforms/AbstractPlatform.php"/>
<file name="src/Platforms/MySQLPlatform.php"/>
<file name="src/Platforms/SQLServer2012Platform.php"/>
<file name="src/Platforms/SqlitePlatform.php"/>
<file name="src/Schema/Column.php"/>
<!--
This issue is fixed in 4.0
-->
<file name="src/Schema/Index.php"/>
<!--
See https://github.com/vimeo/psalm/issues/5325
-->
<file name="tests/Driver/OCI8/ExecutionModeTest.php"/>
</errorLevel>
</DocblockTypeContradiction>
<FalsableReturnStatement>
<errorLevel type="suppress">
<!--
Expand All @@ -61,18 +129,35 @@
<file name="src/Driver/OCI8/Connection.php"/>
</errorLevel>
</ImplementedReturnTypeMismatch>
<InvalidNullableReturnType>
<errorLevel type="suppress">
<!-- See https://github.com/doctrine/dbal/issues/4503 -->
<file name="src/Schema/PostgreSQLSchemaManager.php"/>
</errorLevel>
</InvalidNullableReturnType>
<InvalidPropertyAssignmentValue>
<errorLevel type="suppress">
<!-- Fixing this issue requires an API change -->
<file name="src/Driver/PDO/Exception.php"/>
</errorLevel>
</InvalidPropertyAssignmentValue>
<MissingConstructor>
<errorLevel type="suppress">
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/3712
-->
<file name="src/Schema/SchemaConfig.php"/>
</errorLevel>
</MissingConstructor>
<NullableReturnStatement>
<errorLevel type="suppress">
<!--
Fixing this issue requires an API change
-->
<file name="src/Driver/AbstractSQLiteDriver.php"/>
<!-- See https://github.com/doctrine/dbal/issues/4503 -->
<file name="src/Schema/PostgreSQLSchemaManager.php"/>
</errorLevel>
</NullableReturnStatement>
<PossiblyNullArgument>
Expand All @@ -88,6 +173,46 @@
<file name="tests/Functional/Schema/PostgreSQLSchemaManagerTest.php"/>
</errorLevel>
</PossiblyUndefinedArrayOffset>
<PossiblyNullIterator>
<errorLevel type="suppress">
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/3712
-->
<file name="src/Driver/Mysqli/Statement.php"/>
</errorLevel>
</PossiblyNullIterator>
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<!-- See https://github.com/psalm/psalm-plugin-phpunit/issues/107 -->
<!-- See https://github.com/sebastianbergmann/phpunit/pull/4610 -->
<directory name="tests"/>
<!-- See https://github.com/doctrine/dbal/issues/4506 -->
<file name="src/Schema/ForeignKeyConstraint.php"/>
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/3712
-->
<file name="src/Schema/Column.php"/>
<file name="src/Schema/Identifier.php"/>
<file name="src/Schema/Index.php"/>
<file name="src/Schema/Schema.php"/>
<file name="src/Schema/Sequence.php"/>
<file name="src/Schema/Table.php"/>
<file name="src/Schema/UniqueConstraint.php"/>
<file name="src/Schema/View.php"/>
</errorLevel>
</PropertyNotSetInConstructor>
<!-- This is necessary pre 4.0 -->
<RedundantCastGivenDocblockType>
<errorLevel type="suppress">
<!--
This suppression should be removed in 4.0.x
where we have scalar argument types enforced
-->
<directory name="src"/>
</errorLevel>
</RedundantCastGivenDocblockType>
<RedundantCondition>
<errorLevel type="suppress">
<!--
Expand All @@ -97,6 +222,36 @@
<file name="tests/Driver/API/ExceptionConverterTest.php"/>
</errorLevel>
</RedundantCondition>
<RedundantConditionGivenDocblockType>
<errorLevel type="suppress">
<!--
Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/1055
-->
<file name="src/Driver/Mysqli/Result.php"/>
<!--
Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/1053
-->
<file name="src/Driver/PDO/Result.php"/>
<!--
Fixing these issues requires support of union types at the language level
or breaking API changes.
-->
<file name="src/Platforms/MySQLPlatform.php"/>
<!--
See https://github.com/vimeo/psalm/issues/5305
-->
<file name="src/Driver/Mysqli/Connection.php"/>
</errorLevel>
</RedundantConditionGivenDocblockType>
<ReferenceConstraintViolation>
<errorLevel type="suppress">
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/3836
-->
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
</ReferenceConstraintViolation>
<TooFewArguments>
<errorLevel type="suppress">
<!--
Expand Down Expand Up @@ -134,6 +289,15 @@
<file name="src/Tools/Dumper.php"/>
</errorLevel>
</UndefinedClass>
<UnsafeInstantiation>
<errorLevel type="suppress">
<!-- See https://github.com/doctrine/dbal/issues/4510 -->
<file name="src/Platforms/AbstractPlatform.php"/>
<file name="src/Tools/Console/Command/ReservedWordsCommand.php"/>
<!-- See https://github.com/doctrine/dbal/issues/4511 -->
<file name="src/DriverManager.php"/>
</errorLevel>
</UnsafeInstantiation>
<InvalidReturnType>
<errorLevel type="suppress">
<!-- lastInsertId has a return type that does not match the one defined in the interface-->
Expand Down
4 changes: 0 additions & 4 deletions src/Cache/ArrayResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ public function fetchFirstColumn(): array

public function rowCount(): int
{
if ($this->data === null) {
return 0;
}

return count($this->data);
}

Expand Down
Loading

0 comments on commit 246e7c1

Please sign in to comment.