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
0346d393
Unverified
Commit
0346d393
authored
Apr 10, 2018
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-3079] Added type hints to query-related method parameters and return values
parent
b888c048
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
92 additions
and
148 deletions
+92
-148
ResultCacheStatement.php
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+1
-1
Connection.php
lib/Doctrine/DBAL/Connection.php
+14
-27
MasterSlaveConnection.php
lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
+7
-6
Connection.php
lib/Doctrine/DBAL/Driver/Connection.php
+4
-12
DB2Connection.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
+5
-4
DB2Statement.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+1
-1
MysqliConnection.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
+6
-5
MysqliStatement.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+1
-1
OCI8Connection.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
+6
-5
OCI8Statement.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+1
-1
PDOConnection.php
lib/Doctrine/DBAL/Driver/PDOConnection.php
+4
-4
PDOStatement.php
lib/Doctrine/DBAL/Driver/PDOStatement.php
+1
-1
SQLAnywhereConnection.php
...octrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
+6
-5
SQLAnywhereStatement.php
...Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
+1
-1
SQLSrvConnection.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
+5
-3
SQLSrvStatement.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+1
-1
Statement.php
lib/Doctrine/DBAL/Driver/Statement.php
+1
-1
Connection.php
lib/Doctrine/DBAL/Portability/Connection.php
+6
-4
Statement.php
lib/Doctrine/DBAL/Portability/Statement.php
+1
-1
Statement.php
lib/Doctrine/DBAL/Statement.php
+1
-1
StatementTest.php
...ine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
+1
-1
StatementTest.php
tests/Doctrine/Tests/DBAL/StatementTest.php
+16
-18
DriverConnectionMock.php
tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
+0
-43
DriverMock.php
tests/Doctrine/Tests/Mocks/DriverMock.php
+2
-1
No files found.
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
View file @
0346d393
...
...
@@ -190,7 +190,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
*
* @return int The number of rows.
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
$this
->
statement
->
rowCount
();
}
...
...
lib/Doctrine/DBAL/Connection.php
View file @
0346d393
...
...
@@ -24,7 +24,6 @@ use Throwable;
use
function
array_key_exists
;
use
function
array_merge
;
use
function
assert
;
use
function
func_get_args
;
use
function
implode
;
use
function
is_int
;
use
function
is_string
;
...
...
@@ -846,18 +845,16 @@ class Connection implements DriverConnection
/**
* Prepares an SQL statement.
*
* @param string $statement The SQL statement to prepare.
*
* @return DriverStatement The prepared statement.
* @param string $sql The SQL statement to prepare.
*
* @throws DBALException
*/
public
function
prepare
(
$statement
)
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
try
{
$stmt
=
new
Statement
(
$s
tatement
,
$this
);
$stmt
=
new
Statement
(
$s
ql
,
$this
);
}
catch
(
Throwable
$ex
)
{
throw
DBALException
::
driverExceptionDuringQuery
(
$this
->
_driver
,
$ex
,
$s
tatement
);
throw
DBALException
::
driverExceptionDuringQuery
(
$this
->
_driver
,
$ex
,
$s
ql
);
}
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
...
...
@@ -880,7 +877,7 @@ class Connection implements DriverConnection
*
* @throws DBALException
*/
public
function
executeQuery
(
$query
,
array
$params
=
[],
$types
=
[],
?
QueryCacheProfile
$qcp
=
null
)
public
function
executeQuery
(
string
$query
,
array
$params
=
[],
$types
=
[],
?
QueryCacheProfile
$qcp
=
null
)
:
ResultStatement
{
if
(
$qcp
!==
null
)
{
return
$this
->
executeCacheQuery
(
$query
,
$params
,
$types
,
$qcp
);
...
...
@@ -924,11 +921,9 @@ class Connection implements DriverConnection
* @param int[]|string[] $types The types the previous parameters are in.
* @param QueryCacheProfile $qcp The query cache profile.
*
* @return ResultStatement
*
* @throws CacheException
*/
public
function
executeCacheQuery
(
$query
,
$params
,
$types
,
QueryCacheProfile
$qcp
)
public
function
executeCacheQuery
(
$query
,
$params
,
$types
,
QueryCacheProfile
$qcp
)
:
ResultStatement
{
$resultCache
=
$qcp
->
getResultCacheDriver
()
?:
$this
->
_config
->
getResultCacheImpl
();
if
(
!
$resultCache
)
{
...
...
@@ -987,7 +982,7 @@ class Connection implements DriverConnection
/**
* {@inheritDoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$this
->
connect
();
...
...
@@ -1017,11 +1012,9 @@ class Connection implements DriverConnection
* @param mixed[] $params The query parameters.
* @param int[]|string[] $types The parameter types.
*
* @return int The number of affected rows.
*
* @throws DBALException
*/
public
function
executeUpdate
(
$query
,
array
$params
=
[],
array
$types
=
[])
public
function
executeUpdate
(
string
$query
,
array
$params
=
[],
array
$types
=
[])
:
int
{
$this
->
connect
();
...
...
@@ -1053,15 +1046,9 @@ class Connection implements DriverConnection
}
/**
* Executes an SQL statement and return the number of affected rows.
*
* @param string $statement
*
* @return int The number of affected rows.
*
* @throws DBALException
* {@inheritDoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
$this
->
connect
();
...
...
@@ -1470,13 +1457,13 @@ class Connection implements DriverConnection
* @internal Duck-typing used on the $stmt parameter to support driver statements as well as
* raw PDOStatement instances.
*
* @param
\Doctrine\DBAL\Driver\
Statement $stmt The statement to bind the values to.
* @param mixed[]
$params The map/list of named/positional parameters.
* @param int[]|string[]
$types The parameter types (PDO binding types or DBAL mapping types).
* @param
Driver
Statement $stmt The statement to bind the values to.
* @param mixed[] $params The map/list of named/positional parameters.
* @param int[]|string[] $types The parameter types (PDO binding types or DBAL mapping types).
*
* @return void
*/
private
function
_bindTypedValues
(
$stmt
,
array
$params
,
array
$types
)
private
function
_bindTypedValues
(
DriverStatement
$stmt
,
array
$params
,
array
$types
)
:
void
{
// Check whether parameters are positional or named. Mixing is not allowed, just like in PDO.
if
(
is_int
(
key
(
$params
)))
{
...
...
lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
View file @
0346d393
...
...
@@ -7,12 +7,13 @@ use Doctrine\DBAL\Configuration;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\Connection
as
DriverConnection
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\Statement
;
use
Doctrine\DBAL\Event\ConnectionEventArgs
;
use
Doctrine\DBAL\Events
;
use
InvalidArgumentException
;
use
function
array_rand
;
use
function
count
;
use
function
func_get_args
;
/**
* Master-Slave Connection
...
...
@@ -218,7 +219,7 @@ class MasterSlaveConnection extends Connection
/**
* {@inheritDoc}
*/
public
function
executeUpdate
(
$query
,
array
$params
=
[],
array
$types
=
[])
public
function
executeUpdate
(
string
$query
,
array
$params
=
[],
array
$types
=
[])
:
int
{
$this
->
connect
(
'master'
);
...
...
@@ -301,7 +302,7 @@ class MasterSlaveConnection extends Connection
/**
* {@inheritDoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
$this
->
connect
(
'master'
);
...
...
@@ -341,7 +342,7 @@ class MasterSlaveConnection extends Connection
/**
* {@inheritDoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$this
->
connect
(
'master'
);
...
...
@@ -358,10 +359,10 @@ class MasterSlaveConnection extends Connection
/**
* {@inheritDoc}
*/
public
function
prepare
(
$statement
)
public
function
prepare
(
string
$sql
)
:
Statement
{
$this
->
connect
(
'master'
);
return
parent
::
prepare
(
$s
tatement
);
return
parent
::
prepare
(
$s
ql
);
}
}
lib/Doctrine/DBAL/Driver/Connection.php
View file @
0346d393
...
...
@@ -15,21 +15,15 @@ interface Connection
{
/**
* Prepares a statement for execution and returns a Statement object.
*
* @param string $prepareString
*
* @return Statement
*/
public
function
prepare
(
$prepareString
)
;
public
function
prepare
(
string
$sql
)
:
Statement
;
/**
* Executes an SQL statement, returning a result set as a Statement object.
*
* @return Statement
*
* @throws DBALException
*/
public
function
query
(
string
$sql
);
public
function
query
(
string
$sql
)
:
ResultStatement
;
/**
* Quotes a string for use in a query.
...
...
@@ -44,11 +38,9 @@ interface Connection
/**
* Executes an SQL statement and return the number of affected rows.
*
* @param string $statement
*
* @return int
* @throws DBALException
*/
public
function
exec
(
$statement
)
;
public
function
exec
(
string
$statement
)
:
int
;
/**
* Returns the ID of the last inserted row or sequence value.
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
View file @
0346d393
...
...
@@ -3,7 +3,9 @@
namespace
Doctrine\DBAL\Driver\IBMDB2
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
Doctrine\DBAL\ParameterType
;
use
stdClass
;
use
const
DB2_AUTOCOMMIT_OFF
;
...
...
@@ -22,7 +24,6 @@ use function db2_prepare;
use
function
db2_rollback
;
use
function
db2_server_info
;
use
function
db2_stmt_errormsg
;
use
function
func_get_args
;
class
DB2Connection
implements
Connection
,
ServerInfoAwareConnection
{
...
...
@@ -73,7 +74,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
prepare
(
$sql
)
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
$stmt
=
@
db2_prepare
(
$this
->
conn
,
$sql
);
if
(
!
$stmt
)
{
...
...
@@ -86,7 +87,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
...
...
@@ -111,7 +112,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
$stmt
=
@
db2_exec
(
$this
->
conn
,
$statement
);
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
View file @
0346d393
...
...
@@ -356,7 +356,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
@
db2_num_rows
(
$this
->
stmt
)
?
:
0
;
}
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
View file @
0346d393
...
...
@@ -4,7 +4,9 @@ namespace Doctrine\DBAL\Driver\Mysqli;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\PingableConnection
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
Doctrine\DBAL\ParameterType
;
use
mysqli
;
use
const
MYSQLI_INIT_COMMAND
;
...
...
@@ -15,7 +17,6 @@ use const MYSQLI_READ_DEFAULT_GROUP;
use
const
MYSQLI_SERVER_PUBLIC_KEY
;
use
function
defined
;
use
function
floor
;
use
function
func_get_args
;
use
function
in_array
;
use
function
ini_get
;
use
function
mysqli_errno
;
...
...
@@ -126,15 +127,15 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
/**
* {@inheritdoc}
*/
public
function
prepare
(
$prepareString
)
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
return
new
MysqliStatement
(
$this
->
conn
,
$
prepareString
);
return
new
MysqliStatement
(
$this
->
conn
,
$
sql
);
}
/**
* {@inheritdoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
...
...
@@ -153,7 +154,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
/**
* {@inheritdoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
if
(
$this
->
conn
->
query
(
$statement
)
===
false
)
{
throw
new
MysqliException
(
$this
->
conn
->
error
,
$this
->
conn
->
sqlstate
,
$this
->
conn
->
errno
);
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
0346d393
...
...
@@ -420,7 +420,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
if
(
$this
->
_columnNames
===
false
)
{
return
$this
->
_stmt
->
affected_rows
;
...
...
lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
View file @
0346d393
...
...
@@ -3,7 +3,9 @@
namespace
Doctrine\DBAL\Driver\OCI8
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
Doctrine\DBAL\ParameterType
;
use
UnexpectedValueException
;
use
const
OCI_COMMIT_ON_SUCCESS
;
...
...
@@ -12,7 +14,6 @@ use const OCI_NO_AUTO_COMMIT;
use
function
addcslashes
;
use
function
define
;
use
function
defined
;
use
function
func_get_args
;
use
function
is_float
;
use
function
is_int
;
use
function
oci_commit
;
...
...
@@ -95,15 +96,15 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
prepare
(
$prepareString
)
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
return
new
OCI8Statement
(
$this
->
dbh
,
$
prepareString
,
$this
);
return
new
OCI8Statement
(
$this
->
dbh
,
$
sql
,
$this
);
}
/**
* {@inheritdoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
...
...
@@ -127,7 +128,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
$stmt
=
$this
->
prepare
(
$statement
);
$stmt
->
execute
();
...
...
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
View file @
0346d393
...
...
@@ -502,7 +502,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
oci_num_rows
(
$this
->
_sth
);
}
...
...
lib/Doctrine/DBAL/Driver/PDOConnection.php
View file @
0346d393
...
...
@@ -36,7 +36,7 @@ class PDOConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
try
{
return
$this
->
connection
->
exec
(
$statement
);
...
...
@@ -56,11 +56,11 @@ class PDOConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
prepare
(
$prepareString
)
public
function
prepare
(
string
$sql
)
:
Statement
{
try
{
return
$this
->
createStatement
(
$this
->
connection
->
prepare
(
$
prepareString
)
$this
->
connection
->
prepare
(
$
sql
)
);
}
catch
(
\PDOException
$exception
)
{
throw
new
PDOException
(
$exception
);
...
...
@@ -70,7 +70,7 @@ class PDOConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
try
{
return
$this
->
createStatement
(
...
...
lib/Doctrine/DBAL/Driver/PDOStatement.php
View file @
0346d393
...
...
@@ -137,7 +137,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
$this
->
stmt
->
rowCount
();
}
...
...
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
View file @
0346d393
...
...
@@ -3,10 +3,11 @@
namespace
Doctrine\DBAL\Driver\SQLAnywhere
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
Doctrine\DBAL\ParameterType
;
use
function
assert
;
use
function
func_get_args
;
use
function
is_float
;
use
function
is_int
;
use
function
is_resource
;
...
...
@@ -112,7 +113,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
if
(
sasql_real_query
(
$this
->
connection
,
$statement
)
===
false
)
{
throw
SQLAnywhereException
::
fromSQLAnywhereError
(
$this
->
connection
);
...
...
@@ -148,15 +149,15 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public
function
prepare
(
$prepareString
)
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
return
new
SQLAnywhereStatement
(
$this
->
connection
,
$
prepareString
);
return
new
SQLAnywhereStatement
(
$this
->
connection
,
$
sql
);
}
/**
* {@inheritdoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
...
...
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
View file @
0346d393
...
...
@@ -291,7 +291,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
sasql_stmt_affected_rows
(
$this
->
stmt
);
}
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
View file @
0346d393
...
...
@@ -3,7 +3,9 @@
namespace
Doctrine\DBAL\Driver\SQLSrv
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
Doctrine\DBAL\ParameterType
;
use
const
SQLSRV_ERR_ERRORS
;
use
function
is_float
;
...
...
@@ -71,7 +73,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritDoc}
*/
public
function
prepare
(
$sql
)
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
return
new
SQLSrvStatement
(
$this
->
conn
,
$sql
,
$this
->
lastInsertId
);
}
...
...
@@ -79,7 +81,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritDoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
...
...
@@ -104,7 +106,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
/**
* {@inheritDoc}
*/
public
function
exec
(
$statement
)
public
function
exec
(
string
$statement
)
:
int
{
$stmt
=
sqlsrv_query
(
$this
->
conn
,
$statement
);
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
View file @
0346d393
...
...
@@ -407,7 +407,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
sqlsrv_rows_affected
(
$this
->
stmt
);
}
...
...
lib/Doctrine/DBAL/Driver/Statement.php
View file @
0346d393
...
...
@@ -100,5 +100,5 @@ interface Statement extends ResultStatement
*
* @return int The number of rows.
*/
public
function
rowCount
();
public
function
rowCount
()
:
int
;
}
lib/Doctrine/DBAL/Portability/Connection.php
View file @
0346d393
...
...
@@ -5,6 +5,8 @@ namespace Doctrine\DBAL\Portability;
use
Doctrine\DBAL\Cache\QueryCacheProfile
;
use
Doctrine\DBAL\ColumnCase
;
use
Doctrine\DBAL\Driver\PDOConnection
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
PDO
;
use
const
CASE_LOWER
;
use
const
CASE_UPPER
;
...
...
@@ -93,7 +95,7 @@ class Connection extends \Doctrine\DBAL\Connection
/**
* {@inheritdoc}
*/
public
function
executeQuery
(
$query
,
array
$params
=
[],
$types
=
[],
?
QueryCacheProfile
$qcp
=
null
)
public
function
executeQuery
(
string
$query
,
array
$params
=
[],
$types
=
[],
?
QueryCacheProfile
$qcp
=
null
)
:
ResultStatement
{
$stmt
=
new
Statement
(
parent
::
executeQuery
(
$query
,
$params
,
$types
,
$qcp
),
$this
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
...
...
@@ -104,9 +106,9 @@ class Connection extends \Doctrine\DBAL\Connection
/**
* {@inheritdoc}
*/
public
function
prepare
(
$statement
)
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
$stmt
=
new
Statement
(
parent
::
prepare
(
$s
tatement
),
$this
);
$stmt
=
new
Statement
(
parent
::
prepare
(
$s
ql
),
$this
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
return
$stmt
;
...
...
@@ -115,7 +117,7 @@ class Connection extends \Doctrine\DBAL\Connection
/**
* {@inheritdoc}
*/
public
function
query
(
string
$sql
)
public
function
query
(
string
$sql
)
:
ResultStatement
{
$this
->
connect
();
...
...
lib/Doctrine/DBAL/Portability/Statement.php
View file @
0346d393
...
...
@@ -221,7 +221,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
* {@inheritdoc}
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
$this
->
stmt
->
rowCount
();
}
...
...
lib/Doctrine/DBAL/Statement.php
View file @
0346d393
...
...
@@ -250,7 +250,7 @@ class Statement implements IteratorAggregate, DriverStatement
*
* @return int The number of affected rows.
*/
public
function
rowCount
()
public
function
rowCount
()
:
int
{
return
$this
->
stmt
->
rowCount
();
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
View file @
0346d393
...
...
@@ -27,7 +27,7 @@ class StatementTest extends DbalFunctionalTestCase
public
function
testFailureToPrepareResultsInException
()
{
// use the driver connection directly to avoid having exception wrapped
$stmt
=
$this
->
connection
->
getWrappedConnection
()
->
prepare
(
null
);
$stmt
=
$this
->
connection
->
getWrappedConnection
()
->
prepare
(
''
);
// it's impossible to prepare the statement without bound variables for SQL Server,
// so the preparation happens before the first execution when variables are already in place
...
...
tests/Doctrine/Tests/DBAL/StatementTest.php
View file @
0346d393
...
...
@@ -6,6 +6,7 @@ use Doctrine\DBAL\Configuration;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\Connection
as
DriverConnection
;
use
Doctrine\DBAL\Driver\Statement
as
DriverStatement
;
use
Doctrine\DBAL\Logging\SQLLogger
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\Statement
;
...
...
@@ -23,26 +24,23 @@ class StatementTest extends DbalTestCase
private
$configuration
;
/** @var PDOStatement */
private
$
pdo
Statement
;
private
$
driver
Statement
;
protected
function
setUp
()
{
$this
->
pdoStatement
=
$this
->
getMockBuilder
(
PDOStatement
::
class
)
->
setMethods
([
'execute'
,
'bindParam'
,
'bindValue'
])
->
getMock
();
$platform
=
new
MockPlatform
();
$driverConnection
=
$this
->
createMock
(
DriverConnection
::
class
);
$driverConnection
->
expects
(
$this
->
any
())
->
method
(
'prepare'
)
->
will
(
$this
->
returnValue
(
$this
->
pdoStatement
));
$driver
=
$this
->
createMock
(
Driver
::
class
);
$constructorArgs
=
[
[
'platform'
=>
$platform
],
$driver
,
];
$this
->
conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setConstructorArgs
(
$constructorArgs
)
$this
->
driverStatement
=
$this
->
createMock
(
DriverStatement
::
class
);
$driverConnection
=
$this
->
createConfiguredMock
(
DriverConnection
::
class
,
[
'prepare'
=>
$this
->
driverStatement
,
]);
$driver
=
$this
->
createMock
(
Driver
::
class
);
$this
->
conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setConstructorArgs
([
[
'platform'
=>
new
MockPlatform
()],
$driver
,
])
->
getMock
();
$this
->
conn
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getWrappedConnection'
)
...
...
@@ -146,7 +144,7 @@ class StatementTest extends DbalTestCase
$logger
->
expects
(
$this
->
once
())
->
method
(
'stopQuery'
);
$this
->
pdo
Statement
->
expects
(
$this
->
once
())
$this
->
driver
Statement
->
expects
(
$this
->
once
())
->
method
(
'execute'
)
->
will
(
$this
->
throwException
(
new
Exception
(
'Mock test exception'
)));
...
...
tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
deleted
100644 → 0
View file @
b888c048
<?php
namespace
Doctrine\Tests\Mocks
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\ParameterType
;
class
DriverConnectionMock
implements
Connection
{
public
function
prepare
(
$prepareString
)
{
}
public
function
query
(
string
$sql
)
{
}
public
function
quote
(
$input
,
$type
=
ParameterType
::
STRING
)
{
}
public
function
exec
(
$statement
)
{
}
public
function
lastInsertId
(
$name
=
null
)
{
}
public
function
beginTransaction
()
{
}
public
function
commit
()
{
}
public
function
rollBack
()
{
}
public
function
errorCode
()
{
}
public
function
errorInfo
()
{
}
}
tests/Doctrine/Tests/Mocks/DriverMock.php
View file @
0346d393
...
...
@@ -3,6 +3,7 @@
namespace
Doctrine\Tests\Mocks
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
...
...
@@ -21,7 +22,7 @@ class DriverMock implements Driver
*/
public
function
connect
(
array
$params
,
$username
=
null
,
$password
=
null
,
array
$driverOptions
=
[])
{
return
new
DriverConnectionMock
(
);
throw
new
DBALException
(
'Not implemented'
);
}
public
function
getDatabasePlatform
()
...
...
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