Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
4509f271
Unverified
Commit
4509f271
authored
Jun 20, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.11.x' into 3.0.x
parents
2bd48393
f7e8b5f1
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
81 additions
and
41 deletions
+81
-41
phpstan.neon.dist
phpstan.neon.dist
+14
-0
psalm.xml
psalm.xml
+18
-1
CachingResult.php
src/Cache/CachingResult.php
+5
-9
Connection.php
src/Connection.php
+7
-14
DB2Statement.php
src/Driver/IBMDB2/DB2Statement.php
+2
-0
PDOConnection.php
src/Driver/PDOConnection.php
+5
-1
Connection.php
src/Portability/Connection.php
+3
-0
QueryBuilder.php
src/Query/QueryBuilder.php
+1
-1
ConnectionTest.php
tests/ConnectionTest.php
+4
-1
DriverTest.php
tests/Functional/Driver/PDOSqlsrv/DriverTest.php
+1
-2
DBAL630Test.php
tests/Functional/Ticket/DBAL630Test.php
+13
-4
AbstractMySQLPlatformTestCase.php
tests/Platforms/AbstractMySQLPlatformTestCase.php
+1
-1
AbstractPlatformTestCase.php
tests/Platforms/AbstractPlatformTestCase.php
+1
-1
AbstractPostgreSQLPlatformTestCase.php
tests/Platforms/AbstractPostgreSQLPlatformTestCase.php
+1
-1
AbstractSQLServerPlatformTestCase.php
tests/Platforms/AbstractSQLServerPlatformTestCase.php
+1
-1
DB2PlatformTest.php
tests/Platforms/DB2PlatformTest.php
+1
-1
OraclePlatformTest.php
tests/Platforms/OraclePlatformTest.php
+1
-1
SqlitePlatformTest.php
tests/Platforms/SqlitePlatformTest.php
+2
-2
No files found.
phpstan.neon.dist
View file @
4509f271
...
...
@@ -75,6 +75,16 @@ parameters:
message: '~^Cannot cast array<string>\|bool\|string\|null to int\.$~'
path: %currentWorkingDirectory%/src/Tools/Console/Command/RunSqlCommand.php
# Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/553
-
message: '~^Call to function assert\(\) with true will always evaluate to true\.$~'
path: %currentWorkingDirectory%/src/Driver/PDOConnection.php
# Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/553
-
message: '~^Strict comparison using !== between int and false will always evaluate to true\.$~'
path: %currentWorkingDirectory%/src/Driver/PDOConnection.php
# Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/732
-
message: '~^Access to undefined constant PDO::PGSQL_ATTR_DISABLE_PREPARES\.$~'
...
...
@@ -135,5 +145,9 @@ parameters:
paths:
- %currentWorkingDirectory%/src/Driver/PDOSqlsrv/Connection.php
-
message: '~Return type \(Doctrine\\DBAL\\Portability\\Statement\) of method Doctrine\\DBAL\\Portability\\Connection::prepare\(\) should be compatible with return type \(Doctrine\\DBAL\\Statement\) of method Doctrine\\DBAL\\Connection::prepare\(\)~'
paths:
- %currentWorkingDirectory%/src/Portability/Connection.php
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
psalm.xml
View file @
4509f271
<?xml version="1.0"?>
<psalm
totallyTyped=
"false"
errorLevel=
"
6
"
errorLevel=
"
5
"
resolveFromConfigFile=
"true"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"https://getpsalm.org/schema/config"
...
...
@@ -32,6 +32,23 @@
<file
name=
"src/Driver/OCI8/OCI8Statement.php"
/>
</errorLevel>
</ConflictingReferenceConstraint>
<FalsableReturnStatement>
<errorLevel
type=
"suppress"
>
<!--
Fixing these issues requires an API change
-->
<file
name=
"src/Driver/PDOSqlsrv/Connection.php"
/>
<file
name=
"src/Driver/SQLSrv/SQLSrvConnection.php"
/>
</errorLevel>
</FalsableReturnStatement>
<NullableReturnStatement>
<errorLevel
type=
"suppress"
>
<!--
Fixing this issue requires an API change
-->
<file
name=
"src/Driver/AbstractSQLiteDriver.php"
/>
</errorLevel>
</NullableReturnStatement>
<TooFewArguments>
<errorLevel
type=
"suppress"
>
<!--
...
...
src/Cache/CachingResult.php
View file @
4509f271
...
...
@@ -92,11 +92,7 @@ class CachingResult implements Result
*/
public
function
fetchAllNumeric
()
:
array
{
$this
->
store
(
$this
->
result
->
fetchAllAssociative
()
);
return
array_map
(
'array_values'
,
$this
->
data
);
return
array_map
(
'array_values'
,
$this
->
result
->
fetchAllAssociative
());
}
/**
...
...
@@ -104,11 +100,11 @@ class CachingResult implements Result
*/
public
function
fetchAllAssociative
()
:
array
{
$
this
->
store
(
$this
->
result
->
fetchAllAssociative
()
);
$
data
=
$this
->
result
->
fetchAllAssociative
();
$this
->
store
(
$data
);
return
$
this
->
data
;
return
$data
;
}
/**
...
...
src/Connection.php
View file @
4509f271
...
...
@@ -71,13 +71,6 @@ class Connection implements DriverConnection
/** @var ExpressionBuilder */
protected
$_expr
;
/**
* Whether or not a connection has been established.
*
* @var bool
*/
private
$isConnected
=
false
;
/**
* The current auto-commit mode of this connection.
*
...
...
@@ -284,7 +277,7 @@ class Connection implements DriverConnection
*/
public
function
connect
()
{
if
(
$this
->
isConnected
)
{
if
(
$this
->
_conn
!==
null
)
{
return
false
;
}
...
...
@@ -294,8 +287,6 @@ class Connection implements DriverConnection
throw
DBALException
::
driverException
(
$this
->
_driver
,
$e
);
}
$this
->
isConnected
=
true
;
$this
->
transactionNestingLevel
=
0
;
if
(
$this
->
autoCommit
===
false
)
{
...
...
@@ -453,7 +444,7 @@ class Connection implements DriverConnection
$this
->
autoCommit
=
$autoCommit
;
// Commit all currently active transactions if any when switching auto-commit mode.
if
(
$this
->
isConnected
!==
true
||
$this
->
transactionNestingLevel
===
0
)
{
if
(
$this
->
_conn
===
null
||
$this
->
transactionNestingLevel
===
0
)
{
return
;
}
...
...
@@ -530,7 +521,7 @@ class Connection implements DriverConnection
*/
public
function
isConnected
()
{
return
$this
->
isConnected
;
return
$this
->
_conn
!==
null
;
}
/**
...
...
@@ -612,8 +603,6 @@ class Connection implements DriverConnection
public
function
close
()
{
$this
->
_conn
=
null
;
$this
->
isConnected
=
false
;
}
/**
...
...
@@ -904,6 +893,8 @@ class Connection implements DriverConnection
*
* @param string $sql The SQL statement to prepare.
*
* @return Statement
*
* @throws DBALException
*/
public
function
prepare
(
string
$sql
)
:
DriverStatement
...
...
@@ -1435,6 +1426,8 @@ class Connection implements DriverConnection
{
$this
->
connect
();
assert
(
$this
->
_conn
!==
null
);
return
$this
->
_conn
;
}
...
...
src/Driver/IBMDB2/DB2Statement.php
View file @
4509f271
...
...
@@ -55,6 +55,8 @@ class DB2Statement implements Statement
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
{
assert
(
is_int
(
$param
));
return
$this
->
bindParam
(
$param
,
$value
,
$type
);
}
...
...
src/Driver/PDOConnection.php
View file @
4509f271
...
...
@@ -40,7 +40,11 @@ class PDOConnection implements ServerInfoAwareConnection
public
function
exec
(
string
$statement
)
:
int
{
try
{
return
$this
->
connection
->
exec
(
$statement
);
$result
=
$this
->
connection
->
exec
(
$statement
);
assert
(
$result
!==
false
);
return
$result
;
}
catch
(
\PDOException
$exception
)
{
throw
new
PDOException
(
$exception
);
}
...
...
src/Portability/Connection.php
View file @
4509f271
...
...
@@ -101,6 +101,9 @@ class Connection extends BaseConnection
);
}
/**
* @return Statement
*/
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
return
new
Statement
(
parent
::
prepare
(
$sql
),
$this
->
converter
);
...
...
src/Query/QueryBuilder.php
View file @
4509f271
...
...
@@ -397,7 +397,7 @@ class QueryBuilder
* Gets the maximum number of results the query object was set to retrieve (the "limit").
* Returns NULL if all results will be returned.
*
* @return int The maximum number of results.
* @return int
|null
The maximum number of results.
*/
public
function
getMaxResults
()
{
...
...
tests/ConnectionTest.php
View file @
4509f271
...
...
@@ -632,7 +632,10 @@ class ConnectionTest extends TestCase
{
$driver
=
$this
->
createMock
(
Driver
::
class
);
$driver
->
expects
(
self
::
once
())
->
method
(
'connect'
);
->
method
(
'connect'
)
->
willReturn
(
$this
->
createMock
(
Driver\Connection
::
class
)
);
$platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
...
...
tests/Functional/Driver/PDOSqlsrv/DriverTest.php
View file @
4509f271
...
...
@@ -3,7 +3,6 @@
namespace
Doctrine\DBAL\Tests\Functional\Driver\PDOSqlsrv
;
use
Doctrine\DBAL\Driver
as
DriverInterface
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\PDOConnection
;
use
Doctrine\DBAL\Driver\PDOSqlsrv\Driver
;
use
Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest
;
...
...
@@ -44,7 +43,7 @@ class DriverTest extends AbstractDriverTest
/**
* @param int[]|string[] $driverOptions
*/
pr
otected
function
getConnection
(
array
$driverOptions
)
:
Connection
pr
ivate
function
getConnection
(
array
$driverOptions
)
:
PDO
Connection
{
return
$this
->
connection
->
getDriver
()
->
connect
(
array_merge
(
...
...
tests/Functional/Ticket/DBAL630Test.php
View file @
4509f271
...
...
@@ -3,6 +3,7 @@
namespace
Doctrine\DBAL\Tests\Functional\Ticket
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Driver\PDOConnection
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\Platforms\PostgreSQL94Platform
;
use
Doctrine\DBAL\Tests\FunctionalTestCase
;
...
...
@@ -36,7 +37,7 @@ class DBAL630Test extends FunctionalTestCase
protected
function
tearDown
()
:
void
{
if
(
$this
->
running
)
{
$this
->
connection
->
getWrappedConnection
()
$this
->
getWrappedConnection
()
->
getWrappedConnection
()
->
setAttribute
(
PDO
::
ATTR_EMULATE_PREPARES
,
false
);
}
...
...
@@ -72,7 +73,7 @@ class DBAL630Test extends FunctionalTestCase
public
function
testBooleanConversionBoolParamEmulatedPrepares
()
:
void
{
$this
->
connection
->
getWrappedConnection
()
$this
->
getWrappedConnection
()
->
getWrappedConnection
()
->
setAttribute
(
PDO
::
ATTR_EMULATE_PREPARES
,
true
);
...
...
@@ -98,7 +99,7 @@ class DBAL630Test extends FunctionalTestCase
?
bool
$statementValue
,
?
bool
$databaseConvertedValue
)
:
void
{
$this
->
connection
->
getWrappedConnection
()
$this
->
getWrappedConnection
()
->
getWrappedConnection
()
->
setAttribute
(
PDO
::
ATTR_EMULATE_PREPARES
,
true
);
...
...
@@ -124,7 +125,7 @@ class DBAL630Test extends FunctionalTestCase
?
bool
$statementValue
,
bool
$databaseConvertedValue
)
:
void
{
$this
->
connection
->
getWrappedConnection
()
$this
->
getWrappedConnection
()
->
getWrappedConnection
()
->
setAttribute
(
PDO
::
ATTR_EMULATE_PREPARES
,
true
);
...
...
@@ -176,4 +177,12 @@ class DBAL630Test extends FunctionalTestCase
[
null
,
null
],
];
}
private
function
getWrappedConnection
()
:
PDOConnection
{
$connection
=
$this
->
connection
->
getWrappedConnection
();
self
::
assertInstanceOf
(
PDOConnection
::
class
,
$connection
);
return
$connection
;
}
}
tests/Platforms/AbstractMySQLPlatformTestCase.php
View file @
4509f271
...
...
@@ -153,7 +153,7 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
return
'CREATE UNIQUE INDEX index_name ON test (test, test2)'
;
}
p
ublic
function
getGenerateForeignKeySql
()
:
string
p
rotected
function
getGenerateForeignKeySql
()
:
string
{
return
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'
;
}
...
...
tests/Platforms/AbstractPlatformTestCase.php
View file @
4509f271
...
...
@@ -246,7 +246,7 @@ abstract class AbstractPlatformTestCase extends TestCase
self
::
assertEquals
(
$sql
,
$this
->
getGenerateForeignKeySql
());
}
abstract
p
ublic
function
getGenerateForeignKeySql
()
:
string
;
abstract
p
rotected
function
getGenerateForeignKeySql
()
:
string
;
public
function
testGeneratesConstraintCreationSql
()
:
void
{
...
...
tests/Platforms/AbstractPostgreSQLPlatformTestCase.php
View file @
4509f271
...
...
@@ -64,7 +64,7 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa
return
'CREATE INDEX my_idx ON mytable (user_name, last_login)'
;
}
p
ublic
function
getGenerateForeignKeySql
()
:
string
p
rotected
function
getGenerateForeignKeySql
()
:
string
{
return
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id) NOT DEFERRABLE INITIALLY IMMEDIATE'
;
}
...
...
tests/Platforms/AbstractSQLServerPlatformTestCase.php
View file @
4509f271
...
...
@@ -181,7 +181,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
return
'CREATE UNIQUE INDEX index_name ON test (test, test2) WHERE test IS NOT NULL AND test2 IS NOT NULL'
;
}
p
ublic
function
getGenerateForeignKeySql
()
:
string
p
rotected
function
getGenerateForeignKeySql
()
:
string
{
return
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'
;
}
...
...
tests/Platforms/DB2PlatformTest.php
View file @
4509f271
...
...
@@ -42,7 +42,7 @@ class DB2PlatformTest extends AbstractPlatformTestCase
];
}
p
ublic
function
getGenerateForeignKeySql
()
:
string
p
rotected
function
getGenerateForeignKeySql
()
:
string
{
return
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'
;
}
...
...
tests/Platforms/OraclePlatformTest.php
View file @
4509f271
...
...
@@ -235,7 +235,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase
return
'CREATE UNIQUE INDEX index_name ON test (test, test2)'
;
}
p
ublic
function
getGenerateForeignKeySql
()
:
string
p
rotected
function
getGenerateForeignKeySql
()
:
string
{
return
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'
;
}
...
...
tests/Platforms/SqlitePlatformTest.php
View file @
4509f271
...
...
@@ -286,9 +286,9 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
parent
::
testGeneratesConstraintCreationSql
();
}
p
ublic
function
getGenerateForeignKeySql
()
:
string
p
rotected
function
getGenerateForeignKeySql
()
:
string
{
return
null
;
return
''
;
}
public
function
testModifyLimitQuery
()
:
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment