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
ff1bc0d7
Unverified
Commit
ff1bc0d7
authored
May 23, 2019
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3552 from morozov/statement-types
Enforced parameter and return value types in Statement classes
parents
ac2252d2
94af8191
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
207 additions
and
242 deletions
+207
-242
ArrayStatement.php
lib/Doctrine/DBAL/Cache/ArrayStatement.php
+5
-5
QueryCacheProfile.php
lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
+8
-34
ResultCacheStatement.php
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+6
-11
DB2Statement.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+20
-18
MysqliStatement.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+18
-20
OCI8Statement.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+35
-35
Statement.php
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
+3
-3
PDOStatement.php
lib/Doctrine/DBAL/Driver/PDOStatement.php
+9
-9
ResultStatement.php
lib/Doctrine/DBAL/Driver/ResultStatement.php
+7
-7
SQLAnywhereStatement.php
...Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
+17
-14
SQLSrvStatement.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+15
-22
Statement.php
lib/Doctrine/DBAL/Driver/Statement.php
+17
-17
Statement.php
lib/Doctrine/DBAL/Portability/Statement.php
+12
-14
Statement.php
lib/Doctrine/DBAL/Statement.php
+33
-30
OCI8StatementTest.php
tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
+1
-2
ResultCacheTest.php
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
+1
-1
No files found.
lib/Doctrine/DBAL/Cache/ArrayStatement.php
View file @
ff1bc0d7
...
@@ -55,7 +55,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
...
@@ -55,7 +55,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
$this
->
columnCount
;
return
$this
->
columnCount
;
}
}
...
@@ -75,7 +75,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
...
@@ -75,7 +75,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
if
(
count
(
$args
)
>
0
)
{
if
(
count
(
$args
)
>
0
)
{
throw
new
InvalidArgumentException
(
'Caching layer does not support 2nd/3rd argument to setFetchMode().'
);
throw
new
InvalidArgumentException
(
'Caching layer does not support 2nd/3rd argument to setFetchMode().'
);
...
@@ -97,7 +97,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
...
@@ -97,7 +97,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
if
(
!
isset
(
$this
->
data
[
$this
->
num
]))
{
if
(
!
isset
(
$this
->
data
[
$this
->
num
]))
{
return
false
;
return
false
;
...
@@ -130,7 +130,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
...
@@ -130,7 +130,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$rows
=
[];
$rows
=
[];
while
(
$row
=
$this
->
fetch
(
$fetchMode
,
...
$args
))
{
while
(
$row
=
$this
->
fetch
(
$fetchMode
,
...
$args
))
{
...
@@ -143,7 +143,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
...
@@ -143,7 +143,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
...
...
lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
View file @
ff1bc0d7
...
@@ -26,39 +26,27 @@ class QueryCacheProfile
...
@@ -26,39 +26,27 @@ class QueryCacheProfile
/** @var string|null */
/** @var string|null */
private
$cacheKey
;
private
$cacheKey
;
/**
public
function
__construct
(
int
$lifetime
=
0
,
?
string
$cacheKey
=
null
,
?
Cache
$resultCache
=
null
)
* @param int $lifetime
* @param string|null $cacheKey
*/
public
function
__construct
(
$lifetime
=
0
,
$cacheKey
=
null
,
?
Cache
$resultCache
=
null
)
{
{
$this
->
lifetime
=
$lifetime
;
$this
->
lifetime
=
$lifetime
;
$this
->
cacheKey
=
$cacheKey
;
$this
->
cacheKey
=
$cacheKey
;
$this
->
resultCacheDriver
=
$resultCache
;
$this
->
resultCacheDriver
=
$resultCache
;
}
}
/**
public
function
getResultCacheDriver
()
:
?
Cache
* @return Cache|null
*/
public
function
getResultCacheDriver
()
{
{
return
$this
->
resultCacheDriver
;
return
$this
->
resultCacheDriver
;
}
}
/**
public
function
getLifetime
()
:
int
* @return int
*/
public
function
getLifetime
()
{
{
return
$this
->
lifetime
;
return
$this
->
lifetime
;
}
}
/**
/**
* @return string
*
* @throws CacheException
* @throws CacheException
*/
*/
public
function
getCacheKey
()
public
function
getCacheKey
()
:
string
{
{
if
(
$this
->
cacheKey
===
null
)
{
if
(
$this
->
cacheKey
===
null
)
{
throw
NoCacheKey
::
new
();
throw
NoCacheKey
::
new
();
...
@@ -70,14 +58,13 @@ class QueryCacheProfile
...
@@ -70,14 +58,13 @@ class QueryCacheProfile
/**
/**
* Generates the real cache key from query, params, types and connection parameters.
* Generates the real cache key from query, params, types and connection parameters.
*
*
* @param string $query
* @param mixed[] $params
* @param mixed[] $params
* @param int[]|string[] $types
* @param int[]|string[] $types
* @param mixed[] $connectionParams
* @param mixed[] $connectionParams
*
*
* @return string[]
* @return string[]
*/
*/
public
function
generateCacheKeys
(
$query
,
$params
,
$types
,
array
$connectionParams
=
[])
public
function
generateCacheKeys
(
string
$query
,
array
$params
,
array
$types
,
array
$connectionParams
=
[])
:
array
{
{
$realCacheKey
=
'query='
.
$query
.
$realCacheKey
=
'query='
.
$query
.
'¶ms='
.
serialize
(
$params
)
.
'¶ms='
.
serialize
(
$params
)
.
...
@@ -94,30 +81,17 @@ class QueryCacheProfile
...
@@ -94,30 +81,17 @@ class QueryCacheProfile
return
[
$cacheKey
,
$realCacheKey
];
return
[
$cacheKey
,
$realCacheKey
];
}
}
/**
public
function
setResultCacheDriver
(
Cache
$cache
)
:
self
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/
public
function
setResultCacheDriver
(
Cache
$cache
)
{
{
return
new
QueryCacheProfile
(
$this
->
lifetime
,
$this
->
cacheKey
,
$cache
);
return
new
QueryCacheProfile
(
$this
->
lifetime
,
$this
->
cacheKey
,
$cache
);
}
}
/**
public
function
setCacheKey
(
?
string
$cacheKey
)
:
self
* @param string|null $cacheKey
*
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/
public
function
setCacheKey
(
$cacheKey
)
{
{
return
new
QueryCacheProfile
(
$this
->
lifetime
,
$cacheKey
,
$this
->
resultCacheDriver
);
return
new
QueryCacheProfile
(
$this
->
lifetime
,
$cacheKey
,
$this
->
resultCacheDriver
);
}
}
/**
public
function
setLifetime
(
int
$lifetime
)
:
self
* @param int $lifetime
*
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/
public
function
setLifetime
(
$lifetime
)
{
{
return
new
QueryCacheProfile
(
$lifetime
,
$this
->
cacheKey
,
$this
->
resultCacheDriver
);
return
new
QueryCacheProfile
(
$lifetime
,
$this
->
cacheKey
,
$this
->
resultCacheDriver
);
}
}
...
...
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
View file @
ff1bc0d7
...
@@ -60,12 +60,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -60,12 +60,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
/** @var int */
/** @var int */
private
$defaultFetchMode
=
FetchMode
::
MIXED
;
private
$defaultFetchMode
=
FetchMode
::
MIXED
;
/**
public
function
__construct
(
ResultStatement
$stmt
,
Cache
$resultCache
,
string
$cacheKey
,
string
$realKey
,
int
$lifetime
)
* @param string $cacheKey
* @param string $realKey
* @param int $lifetime
*/
public
function
__construct
(
ResultStatement
$stmt
,
Cache
$resultCache
,
$cacheKey
,
$realKey
,
$lifetime
)
{
{
$this
->
statement
=
$stmt
;
$this
->
statement
=
$stmt
;
$this
->
resultCache
=
$resultCache
;
$this
->
resultCache
=
$resultCache
;
...
@@ -98,7 +93,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -98,7 +93,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
$this
->
statement
->
columnCount
();
return
$this
->
statement
->
columnCount
();
}
}
...
@@ -106,7 +101,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -106,7 +101,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
defaultFetchMode
=
$fetchMode
;
$this
->
defaultFetchMode
=
$fetchMode
;
}
}
...
@@ -124,7 +119,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -124,7 +119,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
if
(
$this
->
data
===
null
)
{
if
(
$this
->
data
===
null
)
{
$this
->
data
=
[];
$this
->
data
=
[];
...
@@ -164,7 +159,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -164,7 +159,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$data
=
$this
->
statement
->
fetchAll
(
$fetchMode
,
...
$args
);
$data
=
$this
->
statement
->
fetchAll
(
$fetchMode
,
...
$args
);
...
@@ -183,7 +178,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -183,7 +178,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
View file @
ff1bc0d7
...
@@ -22,6 +22,7 @@ use const DB2_PARAM_FILE;
...
@@ -22,6 +22,7 @@ use const DB2_PARAM_FILE;
use
const
DB2_PARAM_IN
;
use
const
DB2_PARAM_IN
;
use
function
array_change_key_case
;
use
function
array_change_key_case
;
use
function
array_key_exists
;
use
function
array_key_exists
;
use
function
assert
;
use
function
count
;
use
function
count
;
use
function
db2_bind_param
;
use
function
db2_bind_param
;
use
function
db2_execute
;
use
function
db2_execute
;
...
@@ -36,6 +37,7 @@ use function error_get_last;
...
@@ -36,6 +37,7 @@ use function error_get_last;
use
function
fclose
;
use
function
fclose
;
use
function
fwrite
;
use
function
fwrite
;
use
function
gettype
;
use
function
gettype
;
use
function
is_int
;
use
function
is_object
;
use
function
is_object
;
use
function
is_resource
;
use
function
is_resource
;
use
function
is_string
;
use
function
is_string
;
...
@@ -89,7 +91,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -89,7 +91,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
$this
->
bindParam
(
$param
,
$value
,
$type
);
$this
->
bindParam
(
$param
,
$value
,
$type
);
}
}
...
@@ -97,29 +99,31 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -97,29 +99,31 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
{
{
assert
(
is_int
(
$param
));
switch
(
$type
)
{
switch
(
$type
)
{
case
ParameterType
::
INTEGER
:
case
ParameterType
::
INTEGER
:
$this
->
bind
(
$
column
,
$variable
,
DB2_PARAM_IN
,
DB2_LONG
);
$this
->
bind
(
$
param
,
$variable
,
DB2_PARAM_IN
,
DB2_LONG
);
break
;
break
;
case
ParameterType
::
LARGE_OBJECT
:
case
ParameterType
::
LARGE_OBJECT
:
if
(
isset
(
$this
->
lobs
[
$
column
]))
{
if
(
isset
(
$this
->
lobs
[
$
param
]))
{
[,
$handle
]
=
$this
->
lobs
[
$
column
];
[,
$handle
]
=
$this
->
lobs
[
$
param
];
fclose
(
$handle
);
fclose
(
$handle
);
}
}
$handle
=
$this
->
createTemporaryFile
();
$handle
=
$this
->
createTemporaryFile
();
$path
=
stream_get_meta_data
(
$handle
)[
'uri'
];
$path
=
stream_get_meta_data
(
$handle
)[
'uri'
];
$this
->
bind
(
$
column
,
$path
,
DB2_PARAM_FILE
,
DB2_BINARY
);
$this
->
bind
(
$
param
,
$path
,
DB2_PARAM_FILE
,
DB2_BINARY
);
$this
->
lobs
[
$
column
]
=
[
&
$variable
,
$handle
];
$this
->
lobs
[
$
param
]
=
[
&
$variable
,
$handle
];
break
;
break
;
default
:
default
:
$this
->
bind
(
$
column
,
$variable
,
DB2_PARAM_IN
,
DB2_CHAR
);
$this
->
bind
(
$
param
,
$variable
,
DB2_PARAM_IN
,
DB2_CHAR
);
break
;
break
;
}
}
}
}
...
@@ -130,7 +134,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -130,7 +134,7 @@ class DB2Statement implements IteratorAggregate, Statement
*
*
* @throws DB2Exception
* @throws DB2Exception
*/
*/
private
function
bind
(
$position
,
&
$variable
,
int
$parameterType
,
int
$dataType
)
:
void
private
function
bind
(
int
$position
,
&
$variable
,
int
$parameterType
,
int
$dataType
)
:
void
{
{
$this
->
bindParam
[
$position
]
=&
$variable
;
$this
->
bindParam
[
$position
]
=&
$variable
;
...
@@ -158,7 +162,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -158,7 +162,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
db2_num_fields
(
$this
->
stmt
)
?:
0
;
return
db2_num_fields
(
$this
->
stmt
)
?:
0
;
}
}
...
@@ -166,7 +170,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -166,7 +170,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
if
(
$params
===
null
)
{
if
(
$params
===
null
)
{
ksort
(
$this
->
bindParam
);
ksort
(
$this
->
bindParam
);
...
@@ -206,7 +210,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -206,7 +210,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
defaultFetchMode
=
$fetchMode
;
$this
->
defaultFetchMode
=
$fetchMode
;
...
@@ -232,7 +236,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -232,7 +236,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
// do not try fetching from the statement if it's not expected to contain result
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
// in order to prevent exceptional situation
...
@@ -282,7 +286,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -282,7 +286,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$rows
=
[];
$rows
=
[];
...
@@ -309,7 +313,7 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -309,7 +313,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
...
@@ -339,11 +343,9 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -339,11 +343,9 @@ class DB2Statement implements IteratorAggregate, Statement
* @param string|object $destinationClass Name of the class or class instance to cast to.
* @param string|object $destinationClass Name of the class or class instance to cast to.
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
*
*
* @return object
*
* @throws DB2Exception
* @throws DB2Exception
*/
*/
private
function
castObject
(
stdClass
$sourceObject
,
$destinationClass
,
array
$ctorArgs
=
[])
private
function
castObject
(
stdClass
$sourceObject
,
$destinationClass
,
array
$ctorArgs
=
[])
:
object
{
{
if
(
!
is_string
(
$destinationClass
))
{
if
(
!
is_string
(
$destinationClass
))
{
if
(
!
is_object
(
$destinationClass
))
{
if
(
!
is_object
(
$destinationClass
))
{
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
ff1bc0d7
...
@@ -80,15 +80,13 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -80,15 +80,13 @@ class MysqliStatement implements IteratorAggregate, Statement
private
$result
=
false
;
private
$result
=
false
;
/**
/**
* @param string $prepareString
*
* @throws MysqliException
* @throws MysqliException
*/
*/
public
function
__construct
(
mysqli
$conn
,
$prepareString
)
public
function
__construct
(
mysqli
$conn
,
string
$sql
)
{
{
$this
->
_conn
=
$conn
;
$this
->
_conn
=
$conn
;
$stmt
=
$conn
->
prepare
(
$
prepareString
);
$stmt
=
$conn
->
prepare
(
$
sql
);
if
(
$stmt
===
false
)
{
if
(
$stmt
===
false
)
{
throw
ConnectionError
::
new
(
$this
->
_conn
);
throw
ConnectionError
::
new
(
$this
->
_conn
);
...
@@ -108,22 +106,22 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -108,22 +106,22 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
{
{
assert
(
is_int
(
$
column
));
assert
(
is_int
(
$
param
));
if
(
!
isset
(
self
::
$_paramTypeMap
[
$type
]))
{
if
(
!
isset
(
self
::
$_paramTypeMap
[
$type
]))
{
throw
UnknownType
::
new
(
$type
);
throw
UnknownType
::
new
(
$type
);
}
}
$this
->
_bindedValues
[
$
column
]
=&
$variable
;
$this
->
_bindedValues
[
$
param
]
=&
$variable
;
$this
->
types
[
$
column
-
1
]
=
self
::
$_paramTypeMap
[
$type
];
$this
->
types
[
$
param
-
1
]
=
self
::
$_paramTypeMap
[
$type
];
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
assert
(
is_int
(
$param
));
assert
(
is_int
(
$param
));
...
@@ -139,7 +137,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -139,7 +137,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
if
(
$params
!==
null
&&
count
(
$params
)
>
0
)
{
if
(
$params
!==
null
&&
count
(
$params
)
>
0
)
{
if
(
!
$this
->
bindUntypedValues
(
$params
))
{
if
(
!
$this
->
bindUntypedValues
(
$params
))
{
...
@@ -209,7 +207,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -209,7 +207,7 @@ class MysqliStatement implements IteratorAggregate, Statement
*
*
* @throws DriverException
* @throws DriverException
*/
*/
private
function
bindTypedParameters
()
private
function
bindTypedParameters
()
:
void
{
{
$streams
=
$values
=
[];
$streams
=
$values
=
[];
$types
=
$this
->
types
;
$types
=
$this
->
types
;
...
@@ -245,9 +243,11 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -245,9 +243,11 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* Handle $this->_longData after regular query parameters have been bound
* Handle $this->_longData after regular query parameters have been bound
*
*
* @param resource[] $streams
*
* @throws MysqliException
* @throws MysqliException
*/
*/
private
function
sendLongData
(
$streams
)
private
function
sendLongData
(
array
$streams
)
:
void
{
{
foreach
(
$streams
as
$paramNr
=>
$stream
)
{
foreach
(
$streams
as
$paramNr
=>
$stream
)
{
while
(
!
feof
(
$stream
))
{
while
(
!
feof
(
$stream
))
{
...
@@ -268,10 +268,8 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -268,10 +268,8 @@ class MysqliStatement implements IteratorAggregate, Statement
* Binds a array of values to bound parameters.
* Binds a array of values to bound parameters.
*
*
* @param mixed[] $values
* @param mixed[] $values
*
* @return bool
*/
*/
private
function
bindUntypedValues
(
array
$values
)
private
function
bindUntypedValues
(
array
$values
)
:
bool
{
{
$params
=
[];
$params
=
[];
$types
=
str_repeat
(
's'
,
count
(
$values
));
$types
=
str_repeat
(
's'
,
count
(
$values
));
...
@@ -305,7 +303,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -305,7 +303,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
// do not try fetching from the statement if it's not expected to contain result
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
// in order to prevent exceptional situation
...
@@ -355,7 +353,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -355,7 +353,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$fetchMode
=
$fetchMode
?:
$this
->
_defaultFetchMode
;
$fetchMode
=
$fetchMode
?:
$this
->
_defaultFetchMode
;
...
@@ -377,7 +375,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -377,7 +375,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
...
@@ -416,7 +414,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -416,7 +414,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
$this
->
_stmt
->
field_count
;
return
$this
->
_stmt
->
field_count
;
}
}
...
@@ -424,7 +422,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -424,7 +422,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
_defaultFetchMode
=
$fetchMode
;
$this
->
_defaultFetchMode
=
$fetchMode
;
}
}
...
...
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
View file @
ff1bc0d7
...
@@ -103,7 +103,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -103,7 +103,7 @@ class OCI8Statement implements IteratorAggregate, Statement
* @param resource $dbh The connection handle.
* @param resource $dbh The connection handle.
* @param string $query The SQL query.
* @param string $query The SQL query.
*/
*/
public
function
__construct
(
$dbh
,
$query
,
OCI8Connection
$conn
)
public
function
__construct
(
$dbh
,
string
$query
,
OCI8Connection
$conn
)
{
{
[
$query
,
$paramMap
]
=
self
::
convertPositionalToNamedPlaceholders
(
$query
);
[
$query
,
$paramMap
]
=
self
::
convertPositionalToNamedPlaceholders
(
$query
);
...
@@ -137,14 +137,14 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -137,14 +137,14 @@ class OCI8Statement implements IteratorAggregate, Statement
* @todo extract into utility class in Doctrine\DBAL\Util namespace
* @todo extract into utility class in Doctrine\DBAL\Util namespace
* @todo review and test for lost spaces. we experienced missing spaces with oci8 in some sql statements.
* @todo review and test for lost spaces. we experienced missing spaces with oci8 in some sql statements.
*/
*/
public
static
function
convertPositionalToNamedPlaceholders
(
$statement
)
public
static
function
convertPositionalToNamedPlaceholders
(
string
$statement
)
:
array
{
{
$fragmentOffset
=
$tokenOffset
=
0
;
$fragmentOffset
=
$tokenOffset
=
0
;
$fragments
=
$paramMap
=
[];
$fragments
=
$paramMap
=
[];
$currentLiteralDelimiter
=
null
;
$currentLiteralDelimiter
=
null
;
do
{
do
{
if
(
!
$currentLiteralDelimiter
)
{
if
(
$currentLiteralDelimiter
===
null
)
{
$result
=
self
::
findPlaceholderOrOpeningQuote
(
$result
=
self
::
findPlaceholderOrOpeningQuote
(
$statement
,
$statement
,
$tokenOffset
,
$tokenOffset
,
...
@@ -175,23 +175,23 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -175,23 +175,23 @@ class OCI8Statement implements IteratorAggregate, Statement
* Finds next placeholder or opening quote.
* Finds next placeholder or opening quote.
*
*
* @param string $statement The SQL statement to parse
* @param string $statement The SQL statement to parse
* @param
string
$tokenOffset The offset to start searching from
* @param
int
$tokenOffset The offset to start searching from
* @param int $fragmentOffset The offset to build the next fragment from
* @param int $fragmentOffset The offset to build the next fragment from
* @param string[] $fragments Fragments of the original statement not containing placeholders
* @param string[] $fragments Fragments of the original statement not containing placeholders
* @param string|null $currentLiteralDelimiter The delimiter of the current string literal
* @param string|null $currentLiteralDelimiter The delimiter of the current string literal
* or NULL if not currently in a literal
* or NULL if not currently in a literal
* @param
array<int, string>
$paramMap Mapping of the original parameter positions to their named replacements
* @param
string[]
$paramMap Mapping of the original parameter positions to their named replacements
*
*
* @return bool Whether the token was found
* @return bool Whether the token was found
*/
*/
private
static
function
findPlaceholderOrOpeningQuote
(
private
static
function
findPlaceholderOrOpeningQuote
(
$statement
,
string
$statement
,
&
$tokenOffset
,
int
&
$tokenOffset
,
&
$fragmentOffset
,
int
&
$fragmentOffset
,
&
$fragments
,
array
&
$fragments
,
&
$currentLiteralDelimiter
,
?
string
&
$currentLiteralDelimiter
,
&
$paramMap
array
&
$paramMap
)
{
)
:
bool
{
$token
=
self
::
findToken
(
$statement
,
$tokenOffset
,
'/[?\'"]/'
);
$token
=
self
::
findToken
(
$statement
,
$tokenOffset
,
'/[?\'"]/'
);
if
(
!
$token
)
{
if
(
!
$token
)
{
...
@@ -220,16 +220,16 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -220,16 +220,16 @@ class OCI8Statement implements IteratorAggregate, Statement
* Finds closing quote
* Finds closing quote
*
*
* @param string $statement The SQL statement to parse
* @param string $statement The SQL statement to parse
* @param
string
$tokenOffset The offset to start searching from
* @param
int
$tokenOffset The offset to start searching from
* @param string $currentLiteralDelimiter The delimiter of the current string literal
* @param string $currentLiteralDelimiter The delimiter of the current string literal
*
*
* @return bool Whether the token was found
* @return bool Whether the token was found
*/
*/
private
static
function
findClosingQuote
(
private
static
function
findClosingQuote
(
$statement
,
string
$statement
,
&
$tokenOffset
,
int
&
$tokenOffset
,
&
$currentLiteralDelimiter
string
&
$currentLiteralDelimiter
)
{
)
:
bool
{
$token
=
self
::
findToken
(
$token
=
self
::
findToken
(
$statement
,
$statement
,
$tokenOffset
,
$tokenOffset
,
...
@@ -240,7 +240,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -240,7 +240,7 @@ class OCI8Statement implements IteratorAggregate, Statement
return
false
;
return
false
;
}
}
$currentLiteralDelimiter
=
false
;
$currentLiteralDelimiter
=
null
;
++
$tokenOffset
;
++
$tokenOffset
;
return
true
;
return
true
;
...
@@ -256,7 +256,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -256,7 +256,7 @@ class OCI8Statement implements IteratorAggregate, Statement
*
*
* @return string|null Token or NULL if not found
* @return string|null Token or NULL if not found
*/
*/
private
static
function
findToken
(
$statement
,
&
$offset
,
$regex
)
private
static
function
findToken
(
string
$statement
,
int
&
$offset
,
string
$regex
)
:
?
string
{
{
if
(
preg_match
(
$regex
,
$statement
,
$matches
,
PREG_OFFSET_CAPTURE
,
$offset
))
{
if
(
preg_match
(
$regex
,
$statement
,
$matches
,
PREG_OFFSET_CAPTURE
,
$offset
))
{
$offset
=
$matches
[
0
][
1
];
$offset
=
$matches
[
0
][
1
];
...
@@ -270,7 +270,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -270,7 +270,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
$this
->
bindParam
(
$param
,
$value
,
$type
,
null
);
$this
->
bindParam
(
$param
,
$value
,
$type
,
null
);
}
}
...
@@ -278,9 +278,9 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -278,9 +278,9 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
{
{
$
column
=
$this
->
_paramMap
[
$column
];
$
param
=
$this
->
_paramMap
[
$param
];
if
(
$type
===
ParameterType
::
LARGE_OBJECT
)
{
if
(
$type
===
ParameterType
::
LARGE_OBJECT
)
{
$lob
=
oci_new_descriptor
(
$this
->
_dbh
,
OCI_D_LOB
);
$lob
=
oci_new_descriptor
(
$this
->
_dbh
,
OCI_D_LOB
);
...
@@ -293,11 +293,11 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -293,11 +293,11 @@ class OCI8Statement implements IteratorAggregate, Statement
$variable
=&
$lob
;
$variable
=&
$lob
;
}
}
$this
->
boundValues
[
$
column
]
=&
$variable
;
$this
->
boundValues
[
$
param
]
=&
$variable
;
if
(
!
oci_bind_by_name
(
if
(
!
oci_bind_by_name
(
$this
->
_sth
,
$this
->
_sth
,
$
column
,
$
param
,
$variable
,
$variable
,
$length
??
-
1
,
$length
??
-
1
,
$this
->
convertParameterType
(
$type
)
$this
->
convertParameterType
(
$type
)
...
@@ -341,7 +341,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -341,7 +341,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
oci_num_fields
(
$this
->
_sth
)
?:
0
;
return
oci_num_fields
(
$this
->
_sth
)
?:
0
;
}
}
...
@@ -349,7 +349,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -349,7 +349,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
if
(
$params
)
{
if
(
$params
)
{
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
...
@@ -376,7 +376,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -376,7 +376,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
_defaultFetchMode
=
$fetchMode
;
$this
->
_defaultFetchMode
=
$fetchMode
;
}
}
...
@@ -392,7 +392,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -392,7 +392,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
// do not try fetching from the statement if it's not expected to contain result
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
// in order to prevent exceptional situation
...
@@ -423,7 +423,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -423,7 +423,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$fetchMode
=
$fetchMode
?:
$this
->
_defaultFetchMode
;
$fetchMode
=
$fetchMode
?:
$this
->
_defaultFetchMode
;
...
@@ -477,7 +477,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -477,7 +477,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
// do not try fetching from the statement if it's not expected to contain result
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
// in order to prevent exceptional situation
...
...
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
View file @
ff1bc0d7
...
@@ -16,7 +16,7 @@ class Statement extends PDOStatement
...
@@ -16,7 +16,7 @@ class Statement extends PDOStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
,
$driverOptions
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
,
$driverOptions
=
null
)
:
void
{
{
if
((
$type
===
ParameterType
::
LARGE_OBJECT
||
$type
===
ParameterType
::
BINARY
)
if
((
$type
===
ParameterType
::
LARGE_OBJECT
||
$type
===
ParameterType
::
BINARY
)
&&
$driverOptions
===
null
&&
$driverOptions
===
null
...
@@ -24,13 +24,13 @@ class Statement extends PDOStatement
...
@@ -24,13 +24,13 @@ class Statement extends PDOStatement
$driverOptions
=
PDO
::
SQLSRV_ENCODING_BINARY
;
$driverOptions
=
PDO
::
SQLSRV_ENCODING_BINARY
;
}
}
parent
::
bindParam
(
$
column
,
$variable
,
$type
,
$length
,
$driverOptions
);
parent
::
bindParam
(
$
param
,
$variable
,
$type
,
$length
,
$driverOptions
);
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
$this
->
bindParam
(
$param
,
$value
,
$type
);
$this
->
bindParam
(
$param
,
$value
,
$type
);
}
}
...
...
lib/Doctrine/DBAL/Driver/PDOStatement.php
View file @
ff1bc0d7
...
@@ -53,7 +53,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -53,7 +53,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$fetchMode
=
$this
->
convertFetchMode
(
$fetchMode
);
$fetchMode
=
$this
->
convertFetchMode
(
$fetchMode
);
...
@@ -67,7 +67,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -67,7 +67,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
$type
=
$this
->
convertParamType
(
$type
);
$type
=
$this
->
convertParamType
(
$type
);
...
@@ -81,7 +81,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -81,7 +81,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
,
$driverOptions
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
,
$driverOptions
=
null
)
:
void
{
{
$type
=
$this
->
convertParamType
(
$type
);
$type
=
$this
->
convertParamType
(
$type
);
$extraParameters
=
array_slice
(
func_get_args
(),
3
);
$extraParameters
=
array_slice
(
func_get_args
(),
3
);
...
@@ -91,7 +91,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -91,7 +91,7 @@ class PDOStatement implements IteratorAggregate, Statement
}
}
try
{
try
{
$this
->
stmt
->
bindParam
(
$
column
,
$variable
,
$type
,
...
$extraParameters
);
$this
->
stmt
->
bindParam
(
$
param
,
$variable
,
$type
,
...
$extraParameters
);
}
catch
(
\PDOException
$exception
)
{
}
catch
(
\PDOException
$exception
)
{
throw
new
PDOException
(
$exception
);
throw
new
PDOException
(
$exception
);
}
}
...
@@ -108,7 +108,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -108,7 +108,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
$this
->
stmt
->
columnCount
();
return
$this
->
stmt
->
columnCount
();
}
}
...
@@ -116,7 +116,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -116,7 +116,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
try
{
try
{
$this
->
stmt
->
execute
(
$params
);
$this
->
stmt
->
execute
(
$params
);
...
@@ -136,7 +136,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -136,7 +136,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
try
{
try
{
if
(
$fetchMode
===
null
)
{
if
(
$fetchMode
===
null
)
{
...
@@ -154,7 +154,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -154,7 +154,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
try
{
try
{
if
(
$fetchMode
===
null
)
{
if
(
$fetchMode
===
null
)
{
...
@@ -177,7 +177,7 @@ class PDOStatement implements IteratorAggregate, Statement
...
@@ -177,7 +177,7 @@ class PDOStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
try
{
try
{
$value
=
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
$value
=
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
...
...
lib/Doctrine/DBAL/Driver/ResultStatement.php
View file @
ff1bc0d7
...
@@ -20,10 +20,10 @@ interface ResultStatement extends Traversable
...
@@ -20,10 +20,10 @@ interface ResultStatement extends Traversable
* Returns the number of columns in the result set
* Returns the number of columns in the result set
*
*
* @return int The number of columns in the result set represented
* @return int The number of columns in the result set represented
*
by the PDOStatement objec
t. If there is no result set,
*
by the statemen
t. If there is no result set,
* this method should return 0.
* this method should return 0.
*/
*/
public
function
columnCount
();
public
function
columnCount
()
:
int
;
/**
/**
* Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
...
@@ -43,7 +43,7 @@ interface ResultStatement extends Traversable
...
@@ -43,7 +43,7 @@ interface ResultStatement extends Traversable
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
* @param mixed ...$args Optional mode-specific arguments (see {@link self::fetchAll()}).
* @param mixed ...$args Optional mode-specific arguments (see {@link self::fetchAll()}).
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
;
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
;
/**
/**
* Returns the next row of a result set.
* Returns the next row of a result set.
...
@@ -56,7 +56,7 @@ interface ResultStatement extends Traversable
...
@@ -56,7 +56,7 @@ interface ResultStatement extends Traversable
* @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is
* @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is
* returned on failure.
* returned on failure.
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
);
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
);
/**
/**
* Returns an array containing all of the result set rows.
* Returns an array containing all of the result set rows.
...
@@ -73,7 +73,7 @@ interface ResultStatement extends Traversable
...
@@ -73,7 +73,7 @@ interface ResultStatement extends Traversable
*
*
* @return mixed[]
* @return mixed[]
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
;
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
;
/**
/**
* Returns a single column from the next row of a result set or FALSE if there are no more rows.
* Returns a single column from the next row of a result set or FALSE if there are no more rows.
...
@@ -83,5 +83,5 @@ interface ResultStatement extends Traversable
...
@@ -83,5 +83,5 @@ interface ResultStatement extends Traversable
*
*
* @return mixed|false A single column in the next row of a result set, or FALSE if there are no more rows.
* @return mixed|false A single column in the next row of a result set, or FALSE if there are no more rows.
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
);
public
function
fetchColumn
(
int
$columnIndex
=
0
);
}
}
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
View file @
ff1bc0d7
...
@@ -16,6 +16,7 @@ use ReflectionObject;
...
@@ -16,6 +16,7 @@ use ReflectionObject;
use
stdClass
;
use
stdClass
;
use
const
SASQL_BOTH
;
use
const
SASQL_BOTH
;
use
function
array_key_exists
;
use
function
array_key_exists
;
use
function
assert
;
use
function
count
;
use
function
count
;
use
function
func_get_args
;
use
function
func_get_args
;
use
function
is_array
;
use
function
is_array
;
...
@@ -70,7 +71,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -70,7 +71,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*
*
* @throws SQLAnywhereException
* @throws SQLAnywhereException
*/
*/
public
function
__construct
(
$conn
,
$sql
)
public
function
__construct
(
$conn
,
string
$sql
)
{
{
if
(
!
is_resource
(
$conn
))
{
if
(
!
is_resource
(
$conn
))
{
throw
new
SQLAnywhereException
(
sprintf
(
throw
new
SQLAnywhereException
(
sprintf
(
...
@@ -92,8 +93,10 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -92,8 +93,10 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*
*
* @throws SQLAnywhereException
* @throws SQLAnywhereException
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
{
{
assert
(
is_int
(
$param
));
switch
(
$type
)
{
switch
(
$type
)
{
case
ParameterType
::
INTEGER
:
case
ParameterType
::
INTEGER
:
case
ParameterType
::
BOOLEAN
:
case
ParameterType
::
BOOLEAN
:
...
@@ -114,9 +117,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -114,9 +117,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
throw
new
SQLAnywhereException
(
sprintf
(
'Unknown type %d.'
,
$type
));
throw
new
SQLAnywhereException
(
sprintf
(
'Unknown type %d.'
,
$type
));
}
}
$this
->
boundValues
[
$
column
]
=&
$variable
;
$this
->
boundValues
[
$
param
]
=&
$variable
;
if
(
!
sasql_stmt_bind_param_ex
(
$this
->
stmt
,
$
column
-
1
,
$variable
,
$type
,
$variable
===
null
))
{
if
(
!
sasql_stmt_bind_param_ex
(
$this
->
stmt
,
$
param
-
1
,
$variable
,
$type
,
$variable
===
null
))
{
throw
SQLAnywhereException
::
fromSQLAnywhereError
(
$this
->
conn
,
$this
->
stmt
);
throw
SQLAnywhereException
::
fromSQLAnywhereError
(
$this
->
conn
,
$this
->
stmt
);
}
}
}
}
...
@@ -124,7 +127,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -124,7 +127,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
$this
->
bindParam
(
$param
,
$value
,
$type
);
$this
->
bindParam
(
$param
,
$value
,
$type
);
}
}
...
@@ -140,7 +143,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -140,7 +143,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
sasql_stmt_field_count
(
$this
->
stmt
);
return
sasql_stmt_field_count
(
$this
->
stmt
);
}
}
...
@@ -150,7 +153,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -150,7 +153,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*
*
* @throws SQLAnywhereException
* @throws SQLAnywhereException
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
if
(
is_array
(
$params
))
{
if
(
is_array
(
$params
))
{
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
...
@@ -176,7 +179,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -176,7 +179,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*
*
* @throws SQLAnywhereException
* @throws SQLAnywhereException
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
if
(
!
is_resource
(
$this
->
result
))
{
if
(
!
is_resource
(
$this
->
result
))
{
return
false
;
return
false
;
...
@@ -225,7 +228,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -225,7 +228,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$rows
=
[];
$rows
=
[];
...
@@ -254,7 +257,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -254,7 +257,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
...
@@ -265,6 +268,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -265,6 +268,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
if
(
!
array_key_exists
(
$columnIndex
,
$row
))
{
if
(
!
array_key_exists
(
$columnIndex
,
$row
))
{
throw
InvalidColumnIndex
::
new
(
$columnIndex
,
count
(
$row
));
throw
InvalidColumnIndex
::
new
(
$columnIndex
,
count
(
$row
));
}
}
return
$row
[
$columnIndex
];
}
}
/**
/**
...
@@ -286,7 +291,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -286,7 +291,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
defaultFetchMode
=
$fetchMode
;
$this
->
defaultFetchMode
=
$fetchMode
;
...
@@ -308,11 +313,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -308,11 +313,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
* @param string|object $destinationClass Name of the class or class instance to cast to.
* @param string|object $destinationClass Name of the class or class instance to cast to.
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
*
*
* @return object
*
* @throws SQLAnywhereException
* @throws SQLAnywhereException
*/
*/
private
function
castObject
(
stdClass
$sourceObject
,
$destinationClass
,
array
$ctorArgs
=
[])
private
function
castObject
(
stdClass
$sourceObject
,
$destinationClass
,
array
$ctorArgs
=
[])
:
object
{
{
if
(
!
is_string
(
$destinationClass
))
{
if
(
!
is_string
(
$destinationClass
))
{
if
(
!
is_object
(
$destinationClass
))
{
if
(
!
is_object
(
$destinationClass
))
{
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
View file @
ff1bc0d7
...
@@ -16,10 +16,10 @@ use const SQLSRV_FETCH_BOTH;
...
@@ -16,10 +16,10 @@ use const SQLSRV_FETCH_BOTH;
use
const
SQLSRV_FETCH_NUMERIC
;
use
const
SQLSRV_FETCH_NUMERIC
;
use
const
SQLSRV_PARAM_IN
;
use
const
SQLSRV_PARAM_IN
;
use
function
array_key_exists
;
use
function
array_key_exists
;
use
function
assert
;
use
function
count
;
use
function
count
;
use
function
in_array
;
use
function
in_array
;
use
function
is_int
;
use
function
is_int
;
use
function
is_numeric
;
use
function
sqlsrv_execute
;
use
function
sqlsrv_execute
;
use
function
sqlsrv_fetch
;
use
function
sqlsrv_fetch
;
use
function
sqlsrv_fetch_array
;
use
function
sqlsrv_fetch_array
;
...
@@ -129,9 +129,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -129,9 +129,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* @param resource $conn
* @param resource $conn
* @param string $sql
*/
*/
public
function
__construct
(
$conn
,
$sql
,
?
LastInsertId
$lastInsertId
=
null
)
public
function
__construct
(
$conn
,
string
$sql
,
?
LastInsertId
$lastInsertId
=
null
)
{
{
$this
->
conn
=
$conn
;
$this
->
conn
=
$conn
;
$this
->
sql
=
$sql
;
$this
->
sql
=
$sql
;
...
@@ -147,13 +146,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -147,13 +146,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
if
(
!
is_numeric
(
$param
))
{
assert
(
is_int
(
$param
));
throw
new
SQLSrvException
(
'sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead.'
);
}
$this
->
variables
[
$param
]
=
$value
;
$this
->
variables
[
$param
]
=
$value
;
$this
->
types
[
$param
]
=
$type
;
$this
->
types
[
$param
]
=
$type
;
...
@@ -162,14 +157,12 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -162,14 +157,12 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
{
{
if
(
!
is_numeric
(
$column
))
{
assert
(
is_int
(
$param
));
throw
new
SQLSrvException
(
'sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead.'
);
}
$this
->
variables
[
$
column
]
=&
$variable
;
$this
->
variables
[
$
param
]
=&
$variable
;
$this
->
types
[
$
column
]
=
$type
;
$this
->
types
[
$
param
]
=
$type
;
// unset the statement resource if it exists as the new one will need to be bound to the new variable
// unset the statement resource if it exists as the new one will need to be bound to the new variable
$this
->
stmt
=
null
;
$this
->
stmt
=
null
;
...
@@ -189,7 +182,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -189,7 +182,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
// @link http://php.net/manual/en/pdostatement.closecursor.php
// @link http://php.net/manual/en/pdostatement.closecursor.php
// @link https://github.com/php/php-src/blob/php-7.0.11/ext/pdo/pdo_stmt.c#L2075
// @link https://github.com/php/php-src/blob/php-7.0.11/ext/pdo/pdo_stmt.c#L2075
// deliberately do not consider multiple result sets, since doctrine/dbal doesn't support them
// deliberately do not consider multiple result sets, since doctrine/dbal doesn't support them
while
(
sqlsrv_fetch
(
$this
->
stmt
))
{
while
(
sqlsrv_fetch
(
$this
->
stmt
)
!==
false
)
{
}
}
$this
->
result
=
false
;
$this
->
result
=
false
;
...
@@ -198,7 +191,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -198,7 +191,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
if
(
$this
->
stmt
===
null
)
{
if
(
$this
->
stmt
===
null
)
{
return
0
;
return
0
;
...
@@ -210,7 +203,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -210,7 +203,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
if
(
$params
)
{
if
(
$params
)
{
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
...
@@ -289,7 +282,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -289,7 +282,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
defaultFetchMode
=
$fetchMode
;
$this
->
defaultFetchMode
=
$fetchMode
;
...
@@ -317,7 +310,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -317,7 +310,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*
*
* @throws SQLSrvException
* @throws SQLSrvException
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
// do not try fetching from the statement if it's not expected to contain result
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
// in order to prevent exceptional situation
...
@@ -353,7 +346,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -353,7 +346,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$rows
=
[];
$rows
=
[];
...
@@ -382,7 +375,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -382,7 +375,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
$row
=
$this
->
fetch
(
FetchMode
::
NUMERIC
);
...
...
lib/Doctrine/DBAL/Driver/Statement.php
View file @
ff1bc0d7
...
@@ -21,7 +21,7 @@ interface Statement extends ResultStatement
...
@@ -21,7 +21,7 @@ interface Statement extends ResultStatement
* As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
* As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
* fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
* fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
*
*
* @param
mixed
$param Parameter identifier. For a prepared statement using named placeholders,
* @param
string|int
$param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter.
* using question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $value The value to bind to the parameter.
* @param mixed $value The value to bind to the parameter.
...
@@ -30,7 +30,7 @@ interface Statement extends ResultStatement
...
@@ -30,7 +30,7 @@ interface Statement extends ResultStatement
*
*
* @throws DriverException
* @throws DriverException
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
;
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
;
/**
/**
* Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question
* Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question
...
@@ -46,10 +46,10 @@ interface Statement extends ResultStatement
...
@@ -46,10 +46,10 @@ interface Statement extends ResultStatement
* of stored procedures that return data as output parameters, and some also as input/output
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
* parameters that both send in data and are updated to receive it.
*
*
* @param
mixed $column
Parameter identifier. For a prepared statement using named placeholders,
* @param
string|int $param
Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement using
* this will be a parameter name of the form :name. For a prepared statement using
* question mark placeholders, this will be the 1-indexed position of the parameter.
* question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed
$variable Name of the PHP variable to bind to the SQL statement
parameter.
* @param mixed
$variable The variable to bind to the
parameter.
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
* constants.
* constants.
* @param int|null $length You must specify maxlength when using an OUT bind
* @param int|null $length You must specify maxlength when using an OUT bind
...
@@ -57,7 +57,7 @@ interface Statement extends ResultStatement
...
@@ -57,7 +57,7 @@ interface Statement extends ResultStatement
*
*
* @throws DriverException
* @throws DriverException
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
;
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
;
/**
/**
* Executes a prepared statement
* Executes a prepared statement
...
@@ -73,5 +73,5 @@ interface Statement extends ResultStatement
...
@@ -73,5 +73,5 @@ interface Statement extends ResultStatement
*
*
* @throws DriverException
* @throws DriverException
*/
*/
public
function
execute
(
$params
=
null
)
:
void
;
public
function
execute
(
?
array
$params
=
null
)
:
void
;
}
}
lib/Doctrine/DBAL/Portability/Statement.php
View file @
ff1bc0d7
...
@@ -47,17 +47,17 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -47,17 +47,17 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindParam
(
$
column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
{
{
assert
(
$this
->
stmt
instanceof
DriverStatement
);
assert
(
$this
->
stmt
instanceof
DriverStatement
);
$this
->
stmt
->
bindParam
(
$
column
,
$variable
,
$type
,
$length
);
$this
->
stmt
->
bindParam
(
$
param
,
$variable
,
$type
,
$length
);
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$param
,
$value
,
int
$type
=
ParameterType
::
STRING
)
:
void
{
{
assert
(
$this
->
stmt
instanceof
DriverStatement
);
assert
(
$this
->
stmt
instanceof
DriverStatement
);
...
@@ -75,7 +75,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -75,7 +75,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
$this
->
stmt
->
columnCount
();
return
$this
->
stmt
->
columnCount
();
}
}
...
@@ -83,7 +83,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -83,7 +83,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
assert
(
$this
->
stmt
instanceof
DriverStatement
);
assert
(
$this
->
stmt
instanceof
DriverStatement
);
...
@@ -93,7 +93,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -93,7 +93,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
defaultFetchMode
=
$fetchMode
;
$this
->
defaultFetchMode
=
$fetchMode
;
...
@@ -111,13 +111,13 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -111,13 +111,13 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
$fetchMode
=
$fetchMode
?:
$this
->
defaultFetchMode
;
$fetchMode
=
$fetchMode
?:
$this
->
defaultFetchMode
;
$row
=
$this
->
stmt
->
fetch
(
$fetchMode
,
...
$args
);
$row
=
$this
->
stmt
->
fetch
(
$fetchMode
,
...
$args
);
$iterateRow
=
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
)
;
$iterateRow
=
(
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
))
!==
0
;
$fixCase
=
$this
->
case
!==
null
$fixCase
=
$this
->
case
!==
null
&&
(
$fetchMode
===
FetchMode
::
ASSOCIATIVE
||
$fetchMode
===
FetchMode
::
MIXED
)
&&
(
$fetchMode
===
FetchMode
::
ASSOCIATIVE
||
$fetchMode
===
FetchMode
::
MIXED
)
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
);
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
);
...
@@ -130,13 +130,13 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -130,13 +130,13 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$fetchMode
=
$fetchMode
?:
$this
->
defaultFetchMode
;
$fetchMode
=
$fetchMode
?:
$this
->
defaultFetchMode
;
$rows
=
$this
->
stmt
->
fetchAll
(
$fetchMode
,
...
$args
);
$rows
=
$this
->
stmt
->
fetchAll
(
$fetchMode
,
...
$args
);
$iterateRow
=
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
)
;
$iterateRow
=
(
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
))
!==
0
;
$fixCase
=
$this
->
case
!==
null
$fixCase
=
$this
->
case
!==
null
&&
(
$fetchMode
===
FetchMode
::
ASSOCIATIVE
||
$fetchMode
===
FetchMode
::
MIXED
)
&&
(
$fetchMode
===
FetchMode
::
ASSOCIATIVE
||
$fetchMode
===
FetchMode
::
MIXED
)
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
);
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
);
...
@@ -166,12 +166,10 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -166,12 +166,10 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* @param mixed $row
* @param mixed $row
* @param int $iterateRow
* @param bool $fixCase
*
*
* @return mixed
* @return mixed
*/
*/
protected
function
fixRow
(
$row
,
$iterateRow
,
$fixCase
)
protected
function
fixRow
(
$row
,
bool
$iterateRow
,
bool
$fixCase
)
{
{
if
(
!
$row
)
{
if
(
!
$row
)
{
return
$row
;
return
$row
;
...
@@ -197,7 +195,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -197,7 +195,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
$value
=
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
$value
=
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
...
...
lib/Doctrine/DBAL/Statement.php
View file @
ff1bc0d7
...
@@ -36,14 +36,14 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -36,14 +36,14 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* The parameter types.
* The parameter types.
*
*
* @var int[]|string[]
* @var int[]|string[]
|Type[]
*/
*/
protected
$types
=
[];
protected
$types
=
[];
/**
/**
* The underlying driver statement.
* The underlying driver statement.
*
*
* @var
\Doctrine\DBAL\Driver\
Statement
* @var
Driver
Statement
*/
*/
protected
$stmt
;
protected
$stmt
;
...
@@ -67,7 +67,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -67,7 +67,7 @@ class Statement implements IteratorAggregate, DriverStatement
* @param string $sql The SQL of the statement.
* @param string $sql The SQL of the statement.
* @param Connection $conn The connection on which the statement should be executed.
* @param Connection $conn The connection on which the statement should be executed.
*/
*/
public
function
__construct
(
$sql
,
Connection
$conn
)
public
function
__construct
(
string
$sql
,
Connection
$conn
)
{
{
$this
->
sql
=
$sql
;
$this
->
sql
=
$sql
;
$this
->
stmt
=
$conn
->
getWrappedConnection
()
->
prepare
(
$sql
);
$this
->
stmt
=
$conn
->
getWrappedConnection
()
->
prepare
(
$sql
);
...
@@ -83,17 +83,21 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -83,17 +83,21 @@ class Statement implements IteratorAggregate, DriverStatement
* type and the value undergoes the conversion routines of the mapping type before
* type and the value undergoes the conversion routines of the mapping type before
* being bound.
* being bound.
*
*
* @param string|int $name The name or position of the parameter.
* @param string|int $param Parameter identifier. For a prepared statement using named placeholders,
* @param mixed $value The value of the parameter.
* this will be a parameter name of the form :name. For a prepared statement
* @param mixed $type Either a PDO binding type or a DBAL mapping type name or instance.
* using question mark placeholders, this will be the 1-indexed position
* of the parameter.
* @param mixed $value The value to bind to the parameter.
* @param string|int|Type $type Either one of the constants defined in {@link \Doctrine\DBAL\ParameterType}
* or a DBAL mapping type name or instance.
*
*
* @throws DBALException
* @throws DBALException
* @throws DriverException
* @throws DriverException
*/
*/
public
function
bindValue
(
$
name
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
public
function
bindValue
(
$
param
,
$value
,
$type
=
ParameterType
::
STRING
)
:
void
{
{
$this
->
params
[
$
name
]
=
$value
;
$this
->
params
[
$
param
]
=
$value
;
$this
->
types
[
$
name
]
=
$type
;
$this
->
types
[
$
param
]
=
$type
;
if
(
is_string
(
$type
))
{
if
(
is_string
(
$type
))
{
$type
=
Type
::
getType
(
$type
);
$type
=
Type
::
getType
(
$type
);
...
@@ -106,7 +110,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -106,7 +110,7 @@ class Statement implements IteratorAggregate, DriverStatement
$bindingType
=
$type
;
$bindingType
=
$type
;
}
}
$this
->
stmt
->
bindValue
(
$
name
,
$value
,
$bindingType
);
$this
->
stmt
->
bindValue
(
$
param
,
$value
,
$bindingType
);
}
}
/**
/**
...
@@ -114,20 +118,23 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -114,20 +118,23 @@ class Statement implements IteratorAggregate, DriverStatement
*
*
* Binding a parameter by reference does not support DBAL mapping types.
* Binding a parameter by reference does not support DBAL mapping types.
*
*
* @param string|int $name The name or position of the parameter.
* @param string|int $param Parameter identifier. For a prepared statement using named placeholders,
* @param mixed $var The reference to the variable to bind.
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position
* of the parameter.
* @param mixed $variable The variable to bind to the parameter.
* @param int $type The PDO binding type.
* @param int $type The PDO binding type.
* @param int|null $length Must be specified when using an OUT bind
* @param int|null $length Must be specified when using an OUT bind
* so that PHP allocates enough memory to hold the returned value.
* so that PHP allocates enough memory to hold the returned value.
*
*
* @throws DriverException
* @throws DriverException
*/
*/
public
function
bindParam
(
$
name
,
&
$var
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
:
void
public
function
bindParam
(
$
param
,
&
$variable
,
int
$type
=
ParameterType
::
STRING
,
?
int
$length
=
null
)
:
void
{
{
$this
->
params
[
$
name
]
=
$var
;
$this
->
params
[
$
param
]
=
$variable
;
$this
->
types
[
$
name
]
=
$type
;
$this
->
types
[
$
param
]
=
$type
;
$this
->
stmt
->
bindParam
(
$
name
,
$var
,
$type
,
$length
);
$this
->
stmt
->
bindParam
(
$
param
,
$variable
,
$type
,
$length
);
}
}
/**
/**
...
@@ -135,7 +142,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -135,7 +142,7 @@ class Statement implements IteratorAggregate, DriverStatement
*
*
* @throws DBALException
* @throws DBALException
*/
*/
public
function
execute
(
$params
=
null
)
:
void
public
function
execute
(
?
array
$params
=
null
)
:
void
{
{
if
(
is_array
(
$params
))
{
if
(
is_array
(
$params
))
{
$this
->
params
=
$params
;
$this
->
params
=
$params
;
...
@@ -171,10 +178,8 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -171,10 +178,8 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* Returns the number of columns in the result set.
* Returns the number of columns in the result set.
*
* @return int
*/
*/
public
function
columnCount
()
public
function
columnCount
()
:
int
{
{
return
$this
->
stmt
->
columnCount
();
return
$this
->
stmt
->
columnCount
();
}
}
...
@@ -182,7 +187,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -182,7 +187,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
stmt
->
setFetchMode
(
$fetchMode
,
...
$args
);
$this
->
stmt
->
setFetchMode
(
$fetchMode
,
...
$args
);
}
}
...
@@ -200,7 +205,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -200,7 +205,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetchMode
=
null
,
...
$args
)
public
function
fetch
(
?
int
$fetchMode
=
null
,
...
$args
)
{
{
return
$this
->
stmt
->
fetch
(
$fetchMode
,
...
$args
);
return
$this
->
stmt
->
fetch
(
$fetchMode
,
...
$args
);
}
}
...
@@ -208,7 +213,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -208,7 +213,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetchMode
=
null
,
...
$args
)
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
return
$this
->
stmt
->
fetchAll
(
$fetchMode
,
...
$args
);
return
$this
->
stmt
->
fetchAll
(
$fetchMode
,
...
$args
);
}
}
...
@@ -216,7 +221,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -216,7 +221,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
int
$columnIndex
=
0
)
{
{
return
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
return
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
}
}
...
@@ -233,10 +238,8 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -233,10 +238,8 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* Gets the wrapped driver statement.
* Gets the wrapped driver statement.
*
* @return \Doctrine\DBAL\Driver\Statement
*/
*/
public
function
getWrappedStatement
()
public
function
getWrappedStatement
()
:
DriverStatement
{
{
return
$this
->
stmt
;
return
$this
->
stmt
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
View file @
ff1bc0d7
...
@@ -52,8 +52,7 @@ class OCI8StatementTest extends DbalTestCase
...
@@ -52,8 +52,7 @@ class OCI8StatementTest extends DbalTestCase
->
with
(
->
with
(
$this
->
equalTo
(
$index
+
1
),
$this
->
equalTo
(
$index
+
1
),
$this
->
equalTo
(
$value
)
$this
->
equalTo
(
$value
)
)
);
->
willReturn
(
true
);
}
}
// can't pass to constructor since we don't have a real database handle,
// can't pass to constructor since we don't have a real database handle,
...
...
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
View file @
ff1bc0d7
...
@@ -184,7 +184,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
...
@@ -184,7 +184,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
$query
=
$this
->
connection
->
getDatabasePlatform
()
$query
=
$this
->
connection
->
getDatabasePlatform
()
->
getDummySelectSQL
(
'1'
);
->
getDummySelectSQL
(
'1'
);
$qcp
=
new
QueryCacheProfile
(
0
,
0
,
new
ArrayCache
());
$qcp
=
new
QueryCacheProfile
(
0
,
null
,
new
ArrayCache
());
$stmt
=
$this
->
connection
->
executeCacheQuery
(
$query
,
[],
[],
$qcp
);
$stmt
=
$this
->
connection
->
executeCacheQuery
(
$query
,
[],
[],
$qcp
);
$stmt
->
fetchAll
(
FetchMode
::
COLUMN
);
$stmt
->
fetchAll
(
FetchMode
::
COLUMN
);
...
...
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