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
cc386883
Unverified
Commit
cc386883
authored
Jan 11, 2020
by
Sergei Morozov
Committed by
GitHub
Jan 11, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3590 from jwage/final-classes
Make classes final where applicable.
parents
69cd77e0
5bcd3563
Changes
27
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
221 additions
and
249 deletions
+221
-249
UPGRADE.md
UPGRADE.md
+33
-0
ArrayStatement.php
lib/Doctrine/DBAL/Cache/ArrayStatement.php
+1
-1
ResultCacheStatement.php
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+1
-1
DB2Connection.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
+2
-2
DB2Driver.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
+1
-1
DB2Statement.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+16
-16
Driver.php
lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
+1
-1
MysqliStatement.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+58
-58
Driver.php
lib/Doctrine/DBAL/Driver/OCI8/Driver.php
+3
-3
Driver.php
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
+2
-2
Driver.php
lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
+1
-1
Driver.php
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
+3
-3
Driver.php
lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
+7
-7
Driver.php
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
+3
-3
Statement.php
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
+1
-1
Driver.php
lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
+1
-1
SQLAnywhereConnection.php
...octrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
+1
-1
SQLAnywhereStatement.php
...Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
+1
-1
Driver.php
lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
+1
-1
SQLSrvConnection.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
+3
-3
SQLSrvStatement.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+46
-46
StatementIterator.php
lib/Doctrine/DBAL/Driver/StatementIterator.php
+1
-1
TableGeneratorSchemaVisitor.php
lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php
+1
-1
Statement.php
lib/Doctrine/DBAL/Portability/Statement.php
+29
-29
SingleDatabaseSynchronizer.php
...e/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php
+1
-1
RemoveNamespacedAssets.php
lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
+1
-1
StatementIteratorTest.php
tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php
+2
-63
No files found.
UPGRADE.md
View file @
cc386883
...
@@ -44,6 +44,39 @@ If you are using any of the legacy versions, you have to upgrade to newer MariaD
...
@@ -44,6 +44,39 @@ If you are using any of the legacy versions, you have to upgrade to newer MariaD
Table columns are no longer indexed by column name. Use the
`name`
attribute of the column instead.
Table columns are no longer indexed by column name. Use the
`name`
attribute of the column instead.
## BC BREAK: Classes made final
-
Class constant
`SQLSrvStatement::LAST_INSERT_ID_SQL`
was changed from public to private.
-
Class
`Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser`
was made final.
-
Class
`Doctrine\DBAL\Sharding\SQLAzure\Schema\MultiTenantVisitor`
was made final.
-
Class
`Doctrine\DBAL\Sharding\SQLAzure\SQLAzureFederationsSynchronizer`
was made final.
-
Class
`Doctrine\DBAL\Sharding\PoolingShardManager`
was made final.
-
Class
`Doctrine\DBAL\Id\TableGeneratorSchemaVisitor`
was made final.
-
Class
`Doctrine\DBAL\Driver\OCI8\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\Mysqli\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\Mysqli\MysqliStatement`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOSqlsrv\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOSqlsrv\Statement`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOMySql\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\IBMDB2\DB2Connection`
was made final.
-
Class
`Doctrine\DBAL\Driver\IBMDB2\DB2Statement`
was made final.
-
Class
`Doctrine\DBAL\Driver\IBMDB2\DB2Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\SQLSrv\SQLSrvStatement`
was made final.
-
Class
`Doctrine\DBAL\Driver\SQLSrv\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection`
was made final.
-
Class
`Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection`
was made final.
-
Class
`Doctrine\DBAL\Driver\SQLAnywhere\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereStatement`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOPgSql\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOOracle\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\PDOSqlite\Driver`
was made final.
-
Class
`Doctrine\DBAL\Driver\StatementIterator`
was made final.
-
Class
`Doctrine\DBAL\Cache\ResultCacheStatement`
was made final.
-
Class
`Doctrine\DBAL\Cache\ArrayStatement`
was made final.
-
Class
`Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer`
was made final.
-
Class
`Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets`
was made final.
-
Class
`Doctrine\DBAL\Portability\Statement`
was made final.
## BC BREAK: Changes in the `Doctrine\DBAL\Schema` API
## BC BREAK: Changes in the `Doctrine\DBAL\Schema` API
-
Column precision no longer defaults to 10. The default value is NULL.
-
Column precision no longer defaults to 10. The default value is NULL.
...
...
lib/Doctrine/DBAL/Cache/ArrayStatement.php
View file @
cc386883
...
@@ -17,7 +17,7 @@ use function count;
...
@@ -17,7 +17,7 @@ use function count;
use
function
reset
;
use
function
reset
;
use
function
sprintf
;
use
function
sprintf
;
class
ArrayStatement
implements
IteratorAggregate
,
ResultStatement
final
class
ArrayStatement
implements
IteratorAggregate
,
ResultStatement
{
{
/** @var mixed[] */
/** @var mixed[] */
private
$data
;
private
$data
;
...
...
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
View file @
cc386883
...
@@ -30,7 +30,7 @@ use function reset;
...
@@ -30,7 +30,7 @@ use function reset;
* Also you have to realize that the cache will load the whole result into memory at once to ensure 2.
* Also you have to realize that the cache will load the whole result into memory at once to ensure 2.
* This means that the memory usage for cached results might increase by using this feature.
* This means that the memory usage for cached results might increase by using this feature.
*/
*/
class
ResultCacheStatement
implements
IteratorAggregate
,
ResultStatement
final
class
ResultCacheStatement
implements
IteratorAggregate
,
ResultStatement
{
{
/** @var Cache */
/** @var Cache */
private
$resultCache
;
private
$resultCache
;
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
View file @
cc386883
...
@@ -22,10 +22,10 @@ use function db2_prepare;
...
@@ -22,10 +22,10 @@ use function db2_prepare;
use
function
db2_rollback
;
use
function
db2_rollback
;
use
function
db2_server_info
;
use
function
db2_server_info
;
class
DB2Connection
implements
ServerInfoAwareConnection
final
class
DB2Connection
implements
ServerInfoAwareConnection
{
{
/** @var resource */
/** @var resource */
private
$conn
=
null
;
private
$conn
;
/**
/**
* @param array<string, mixed> $params
* @param array<string, mixed> $params
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
View file @
cc386883
...
@@ -14,7 +14,7 @@ use function sprintf;
...
@@ -14,7 +14,7 @@ use function sprintf;
/**
/**
* IBM DB2 Driver.
* IBM DB2 Driver.
*/
*/
class
DB2Driver
extends
AbstractDB2Driver
final
class
DB2Driver
extends
AbstractDB2Driver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
View file @
cc386883
...
@@ -48,7 +48,7 @@ use function stream_get_meta_data;
...
@@ -48,7 +48,7 @@ use function stream_get_meta_data;
use
function
strtolower
;
use
function
strtolower
;
use
function
tmpfile
;
use
function
tmpfile
;
class
DB2Statement
implements
IteratorAggregate
,
Statement
final
class
DB2Statement
implements
IteratorAggregate
,
Statement
{
{
/** @var resource */
/** @var resource */
private
$stmt
;
private
$stmt
;
...
@@ -128,21 +128,6 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -128,21 +128,6 @@ class DB2Statement implements IteratorAggregate, Statement
}
}
}
}
/**
* @param int $position Parameter position
* @param mixed $variable
*
* @throws DB2Exception
*/
private
function
bind
(
int
$position
,
&
$variable
,
int
$parameterType
,
int
$dataType
)
:
void
{
$this
->
bindParam
[
$position
]
=&
$variable
;
if
(
!
db2_bind_param
(
$this
->
stmt
,
$position
,
'variable'
,
$parameterType
,
$dataType
))
{
throw
DB2Exception
::
fromStatementError
(
$this
->
stmt
);
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
@@ -336,6 +321,21 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -336,6 +321,21 @@ class DB2Statement implements IteratorAggregate, Statement
return
@
db2_num_rows
(
$this
->
stmt
)
?
:
0
;
return
@
db2_num_rows
(
$this
->
stmt
)
?
:
0
;
}
}
/**
* @param int $position Parameter position
* @param mixed $variable
*
* @throws DB2Exception
*/
private
function
bind
(
int
$position
,
&
$variable
,
int
$parameterType
,
int
$dataType
)
:
void
{
$this
->
bindParam
[
$position
]
=&
$variable
;
if
(
!
db2_bind_param
(
$this
->
stmt
,
$position
,
'variable'
,
$parameterType
,
$dataType
))
{
throw
DB2Exception
::
fromStatementError
(
$this
->
stmt
);
}
}
/**
/**
* Casts a stdClass object to the given class name mapping its' properties.
* Casts a stdClass object to the given class name mapping its' properties.
*
*
...
...
lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
View file @
cc386883
...
@@ -8,7 +8,7 @@ use Doctrine\DBAL\DBALException;
...
@@ -8,7 +8,7 @@ use Doctrine\DBAL\DBALException;
use
Doctrine\DBAL\Driver\AbstractMySQLDriver
;
use
Doctrine\DBAL\Driver\AbstractMySQLDriver
;
use
Doctrine\DBAL\Driver\Connection
;
use
Doctrine\DBAL\Driver\Connection
;
class
Driver
extends
AbstractMySQLDriver
final
class
Driver
extends
AbstractMySQLDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
cc386883
...
@@ -32,10 +32,10 @@ use function is_int;
...
@@ -32,10 +32,10 @@ use function is_int;
use
function
is_resource
;
use
function
is_resource
;
use
function
str_repeat
;
use
function
str_repeat
;
class
MysqliStatement
implements
IteratorAggregate
,
Statement
final
class
MysqliStatement
implements
IteratorAggregate
,
Statement
{
{
/** @var string[] */
/** @var string[] */
pr
otected
static
$_
paramTypeMap
=
[
pr
ivate
static
$
paramTypeMap
=
[
ParameterType
::
STRING
=>
's'
,
ParameterType
::
STRING
=>
's'
,
ParameterType
::
BINARY
=>
's'
,
ParameterType
::
BINARY
=>
's'
,
ParameterType
::
BOOLEAN
=>
'i'
,
ParameterType
::
BOOLEAN
=>
'i'
,
...
@@ -45,32 +45,32 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -45,32 +45,32 @@ class MysqliStatement implements IteratorAggregate, Statement
];
];
/** @var mysqli */
/** @var mysqli */
pr
otected
$_
conn
;
pr
ivate
$
conn
;
/** @var mysqli_stmt */
/** @var mysqli_stmt */
pr
otected
$_
stmt
;
pr
ivate
$
stmt
;
/** @var string[]|false|null */
/** @var string[]|false|null */
pr
otected
$_
columnNames
;
pr
ivate
$
columnNames
;
/** @var mixed[] */
/** @var mixed[] */
pr
otected
$_rowBinde
dValues
=
[];
pr
ivate
$rowBoun
dValues
=
[];
/** @var mixed[] */
/** @var mixed[] */
pr
otected
$_binde
dValues
=
[];
pr
ivate
$boun
dValues
=
[];
/** @var string */
/** @var string */
pr
otected
$types
;
pr
ivate
$types
;
/**
/**
* Contains ref values for bindValue().
* Contains ref values for bindValue().
*
*
* @var mixed[]
* @var mixed[]
*/
*/
pr
otected
$_
values
=
[];
pr
ivate
$
values
=
[];
/** @var int */
/** @var int */
pr
otected
$_
defaultFetchMode
=
FetchMode
::
MIXED
;
pr
ivate
$
defaultFetchMode
=
FetchMode
::
MIXED
;
/**
/**
* Indicates whether the statement is in the state when fetching results is possible
* Indicates whether the statement is in the state when fetching results is possible
...
@@ -84,23 +84,23 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -84,23 +84,23 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
*/
public
function
__construct
(
mysqli
$conn
,
string
$sql
)
public
function
__construct
(
mysqli
$conn
,
string
$sql
)
{
{
$this
->
_
conn
=
$conn
;
$this
->
conn
=
$conn
;
$stmt
=
$conn
->
prepare
(
$sql
);
$stmt
=
$conn
->
prepare
(
$sql
);
if
(
$stmt
===
false
)
{
if
(
$stmt
===
false
)
{
throw
ConnectionError
::
new
(
$this
->
_
conn
);
throw
ConnectionError
::
new
(
$this
->
conn
);
}
}
$this
->
_
stmt
=
$stmt
;
$this
->
stmt
=
$stmt
;
$paramCount
=
$this
->
_
stmt
->
param_count
;
$paramCount
=
$this
->
stmt
->
param_count
;
if
(
0
>=
$paramCount
)
{
if
(
0
>=
$paramCount
)
{
return
;
return
;
}
}
$this
->
types
=
str_repeat
(
's'
,
$paramCount
);
$this
->
types
=
str_repeat
(
's'
,
$paramCount
);
$this
->
_binde
dValues
=
array_fill
(
1
,
$paramCount
,
null
);
$this
->
boun
dValues
=
array_fill
(
1
,
$paramCount
,
null
);
}
}
/**
/**
...
@@ -110,12 +110,12 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -110,12 +110,12 @@ class MysqliStatement implements IteratorAggregate, Statement
{
{
assert
(
is_int
(
$param
));
assert
(
is_int
(
$param
));
if
(
!
isset
(
self
::
$
_
paramTypeMap
[
$type
]))
{
if
(
!
isset
(
self
::
$paramTypeMap
[
$type
]))
{
throw
UnknownType
::
new
(
$type
);
throw
UnknownType
::
new
(
$type
);
}
}
$this
->
_binde
dValues
[
$param
]
=&
$variable
;
$this
->
boun
dValues
[
$param
]
=&
$variable
;
$this
->
types
[
$param
-
1
]
=
self
::
$_
paramTypeMap
[
$type
];
$this
->
types
[
$param
-
1
]
=
self
::
$
paramTypeMap
[
$type
];
}
}
/**
/**
...
@@ -125,13 +125,13 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -125,13 +125,13 @@ class MysqliStatement implements IteratorAggregate, Statement
{
{
assert
(
is_int
(
$param
));
assert
(
is_int
(
$param
));
if
(
!
isset
(
self
::
$
_
paramTypeMap
[
$type
]))
{
if
(
!
isset
(
self
::
$paramTypeMap
[
$type
]))
{
throw
UnknownType
::
new
(
$type
);
throw
UnknownType
::
new
(
$type
);
}
}
$this
->
_values
[
$param
]
=
$value
;
$this
->
values
[
$param
]
=
$value
;
$this
->
_bindedValues
[
$param
]
=&
$this
->
_
values
[
$param
];
$this
->
boundValues
[
$param
]
=&
$this
->
values
[
$param
];
$this
->
types
[
$param
-
1
]
=
self
::
$_
paramTypeMap
[
$type
];
$this
->
types
[
$param
-
1
]
=
self
::
$
paramTypeMap
[
$type
];
}
}
/**
/**
...
@@ -141,18 +141,18 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -141,18 +141,18 @@ class MysqliStatement implements IteratorAggregate, Statement
{
{
if
(
$params
!==
null
&&
count
(
$params
)
>
0
)
{
if
(
$params
!==
null
&&
count
(
$params
)
>
0
)
{
if
(
!
$this
->
bindUntypedValues
(
$params
))
{
if
(
!
$this
->
bindUntypedValues
(
$params
))
{
throw
StatementError
::
new
(
$this
->
_
stmt
);
throw
StatementError
::
new
(
$this
->
stmt
);
}
}
}
else
{
}
else
{
$this
->
bindTypedParameters
();
$this
->
bindTypedParameters
();
}
}
if
(
!
$this
->
_
stmt
->
execute
())
{
if
(
!
$this
->
stmt
->
execute
())
{
throw
StatementError
::
new
(
$this
->
_
stmt
);
throw
StatementError
::
new
(
$this
->
stmt
);
}
}
if
(
$this
->
_
columnNames
===
null
)
{
if
(
$this
->
columnNames
===
null
)
{
$meta
=
$this
->
_
stmt
->
result_metadata
();
$meta
=
$this
->
stmt
->
result_metadata
();
if
(
$meta
!==
false
)
{
if
(
$meta
!==
false
)
{
$fields
=
$meta
->
fetch_fields
();
$fields
=
$meta
->
fetch_fields
();
assert
(
is_array
(
$fields
));
assert
(
is_array
(
$fields
));
...
@@ -164,17 +164,17 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -164,17 +164,17 @@ class MysqliStatement implements IteratorAggregate, Statement
$meta
->
free
();
$meta
->
free
();
$this
->
_
columnNames
=
$columnNames
;
$this
->
columnNames
=
$columnNames
;
}
else
{
}
else
{
$this
->
_
columnNames
=
false
;
$this
->
columnNames
=
false
;
}
}
}
}
if
(
$this
->
_
columnNames
!==
false
)
{
if
(
$this
->
columnNames
!==
false
)
{
// Store result of every execution which has it. Otherwise it will be impossible
// Store result of every execution which has it. Otherwise it will be impossible
// to execute a new statement in case if the previous one has non-fetched rows
// to execute a new statement in case if the previous one has non-fetched rows
// @link http://dev.mysql.com/doc/refman/5.7/en/commands-out-of-sync.html
// @link http://dev.mysql.com/doc/refman/5.7/en/commands-out-of-sync.html
$this
->
_
stmt
->
store_result
();
$this
->
stmt
->
store_result
();
// Bind row values _after_ storing the result. Otherwise, if mysqli is compiled with libmysql,
// Bind row values _after_ storing the result. Otherwise, if mysqli is compiled with libmysql,
// it will have to allocate as much memory as it may be needed for the given column type
// it will have to allocate as much memory as it may be needed for the given column type
...
@@ -187,15 +187,15 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -187,15 +187,15 @@ class MysqliStatement implements IteratorAggregate, Statement
// It's also important that row values are bound after _each_ call to store_result(). Otherwise,
// It's also important that row values are bound after _each_ call to store_result(). Otherwise,
// if mysqli is compiled with libmysql, subsequently fetched string values will get truncated
// if mysqli is compiled with libmysql, subsequently fetched string values will get truncated
// to the length of the ones fetched during the previous execution.
// to the length of the ones fetched during the previous execution.
$this
->
_rowBindedValues
=
array_fill
(
0
,
count
(
$this
->
_
columnNames
),
null
);
$this
->
rowBoundValues
=
array_fill
(
0
,
count
(
$this
->
columnNames
),
null
);
$refs
=
[];
$refs
=
[];
foreach
(
$this
->
_rowBinde
dValues
as
$key
=>
&
$value
)
{
foreach
(
$this
->
rowBoun
dValues
as
$key
=>
&
$value
)
{
$refs
[
$key
]
=&
$value
;
$refs
[
$key
]
=&
$value
;
}
}
if
(
!
$this
->
_
stmt
->
bind_result
(
...
$refs
))
{
if
(
!
$this
->
stmt
->
bind_result
(
...
$refs
))
{
throw
StatementError
::
new
(
$this
->
_
stmt
);
throw
StatementError
::
new
(
$this
->
stmt
);
}
}
}
}
...
@@ -212,12 +212,12 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -212,12 +212,12 @@ class MysqliStatement implements IteratorAggregate, Statement
$streams
=
$values
=
[];
$streams
=
$values
=
[];
$types
=
$this
->
types
;
$types
=
$this
->
types
;
foreach
(
$this
->
_binde
dValues
as
$parameter
=>
$value
)
{
foreach
(
$this
->
boun
dValues
as
$parameter
=>
$value
)
{
if
(
!
isset
(
$types
[
$parameter
-
1
]))
{
if
(
!
isset
(
$types
[
$parameter
-
1
]))
{
$types
[
$parameter
-
1
]
=
s
tatic
::
$_
paramTypeMap
[
ParameterType
::
STRING
];
$types
[
$parameter
-
1
]
=
s
elf
::
$
paramTypeMap
[
ParameterType
::
STRING
];
}
}
if
(
$types
[
$parameter
-
1
]
===
s
tatic
::
$_
paramTypeMap
[
ParameterType
::
LARGE_OBJECT
])
{
if
(
$types
[
$parameter
-
1
]
===
s
elf
::
$
paramTypeMap
[
ParameterType
::
LARGE_OBJECT
])
{
if
(
is_resource
(
$value
))
{
if
(
is_resource
(
$value
))
{
if
(
get_resource_type
(
$value
)
!==
'stream'
)
{
if
(
get_resource_type
(
$value
)
!==
'stream'
)
{
throw
new
InvalidArgumentException
(
'Resources passed with the LARGE_OBJECT parameter type must be stream resources.'
);
throw
new
InvalidArgumentException
(
'Resources passed with the LARGE_OBJECT parameter type must be stream resources.'
);
...
@@ -227,14 +227,14 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -227,14 +227,14 @@ class MysqliStatement implements IteratorAggregate, Statement
continue
;
continue
;
}
}
$types
[
$parameter
-
1
]
=
s
tatic
::
$_
paramTypeMap
[
ParameterType
::
STRING
];
$types
[
$parameter
-
1
]
=
s
elf
::
$
paramTypeMap
[
ParameterType
::
STRING
];
}
}
$values
[
$parameter
]
=
$value
;
$values
[
$parameter
]
=
$value
;
}
}
if
(
count
(
$values
)
>
0
&&
!
$this
->
_
stmt
->
bind_param
(
$types
,
...
$values
))
{
if
(
count
(
$values
)
>
0
&&
!
$this
->
stmt
->
bind_param
(
$types
,
...
$values
))
{
throw
StatementError
::
new
(
$this
->
_
stmt
);
throw
StatementError
::
new
(
$this
->
stmt
);
}
}
$this
->
sendLongData
(
$streams
);
$this
->
sendLongData
(
$streams
);
...
@@ -257,8 +257,8 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -257,8 +257,8 @@ class MysqliStatement implements IteratorAggregate, Statement
throw
FailedReadingStreamOffset
::
new
(
$paramNr
);
throw
FailedReadingStreamOffset
::
new
(
$paramNr
);
}
}
if
(
!
$this
->
_
stmt
->
send_long_data
(
$paramNr
-
1
,
$chunk
))
{
if
(
!
$this
->
stmt
->
send_long_data
(
$paramNr
-
1
,
$chunk
))
{
throw
StatementError
::
new
(
$this
->
_
stmt
);
throw
StatementError
::
new
(
$this
->
stmt
);
}
}
}
}
}
}
...
@@ -278,7 +278,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -278,7 +278,7 @@ class MysqliStatement implements IteratorAggregate, Statement
$params
[]
=&
$v
;
$params
[]
=&
$v
;
}
}
return
$this
->
_
stmt
->
bind_param
(
$types
,
...
$params
);
return
$this
->
stmt
->
bind_param
(
$types
,
...
$params
);
}
}
/**
/**
...
@@ -286,11 +286,11 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -286,11 +286,11 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
*/
private
function
_fetch
()
private
function
_fetch
()
{
{
$ret
=
$this
->
_
stmt
->
fetch
();
$ret
=
$this
->
stmt
->
fetch
();
if
(
$ret
===
true
)
{
if
(
$ret
===
true
)
{
$values
=
[];
$values
=
[];
foreach
(
$this
->
_rowBinde
dValues
as
$v
)
{
foreach
(
$this
->
rowBoun
dValues
as
$v
)
{
$values
[]
=
$v
;
$values
[]
=
$v
;
}
}
...
@@ -311,7 +311,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -311,7 +311,7 @@ class MysqliStatement implements IteratorAggregate, Statement
return
false
;
return
false
;
}
}
$fetchMode
=
$fetchMode
?:
$this
->
_
defaultFetchMode
;
$fetchMode
=
$fetchMode
?:
$this
->
defaultFetchMode
;
if
(
$fetchMode
===
FetchMode
::
COLUMN
)
{
if
(
$fetchMode
===
FetchMode
::
COLUMN
)
{
return
$this
->
fetchColumn
();
return
$this
->
fetchColumn
();
...
@@ -324,15 +324,15 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -324,15 +324,15 @@ class MysqliStatement implements IteratorAggregate, Statement
}
}
if
(
$values
===
false
)
{
if
(
$values
===
false
)
{
throw
StatementError
::
new
(
$this
->
_
stmt
);
throw
StatementError
::
new
(
$this
->
stmt
);
}
}
if
(
$fetchMode
===
FetchMode
::
NUMERIC
)
{
if
(
$fetchMode
===
FetchMode
::
NUMERIC
)
{
return
$values
;
return
$values
;
}
}
assert
(
is_array
(
$this
->
_
columnNames
));
assert
(
is_array
(
$this
->
columnNames
));
$assoc
=
array_combine
(
$this
->
_
columnNames
,
$values
);
$assoc
=
array_combine
(
$this
->
columnNames
,
$values
);
assert
(
is_array
(
$assoc
));
assert
(
is_array
(
$assoc
));
switch
(
$fetchMode
)
{
switch
(
$fetchMode
)
{
...
@@ -355,7 +355,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -355,7 +355,7 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
*/
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
public
function
fetchAll
(
?
int
$fetchMode
=
null
,
...
$args
)
:
array
{
{
$fetchMode
=
$fetchMode
?:
$this
->
_
defaultFetchMode
;
$fetchMode
=
$fetchMode
?:
$this
->
defaultFetchMode
;
$rows
=
[];
$rows
=
[];
...
@@ -395,7 +395,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -395,7 +395,7 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
*/
public
function
closeCursor
()
:
void
public
function
closeCursor
()
:
void
{
{
$this
->
_
stmt
->
free_result
();
$this
->
stmt
->
free_result
();
$this
->
result
=
false
;
$this
->
result
=
false
;
}
}
...
@@ -404,11 +404,11 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -404,11 +404,11 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
*/
public
function
rowCount
()
:
int
public
function
rowCount
()
:
int
{
{
if
(
$this
->
_
columnNames
===
false
)
{
if
(
$this
->
columnNames
===
false
)
{
return
$this
->
_
stmt
->
affected_rows
;
return
$this
->
stmt
->
affected_rows
;
}
}
return
$this
->
_
stmt
->
num_rows
;
return
$this
->
stmt
->
num_rows
;
}
}
/**
/**
...
@@ -416,7 +416,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -416,7 +416,7 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
*/
public
function
columnCount
()
:
int
public
function
columnCount
()
:
int
{
{
return
$this
->
_
stmt
->
field_count
;
return
$this
->
stmt
->
field_count
;
}
}
/**
/**
...
@@ -424,7 +424,7 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -424,7 +424,7 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
*/
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
public
function
setFetchMode
(
int
$fetchMode
,
...
$args
)
:
void
{
{
$this
->
_
defaultFetchMode
=
$fetchMode
;
$this
->
defaultFetchMode
=
$fetchMode
;
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Driver/OCI8/Driver.php
View file @
cc386883
...
@@ -12,7 +12,7 @@ use const OCI_DEFAULT;
...
@@ -12,7 +12,7 @@ use const OCI_DEFAULT;
/**
/**
* A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
* A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
*/
*/
class
Driver
extends
AbstractOracleDriver
final
class
Driver
extends
AbstractOracleDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
@@ -27,7 +27,7 @@ class Driver extends AbstractOracleDriver
...
@@ -27,7 +27,7 @@ class Driver extends AbstractOracleDriver
return
new
OCI8Connection
(
return
new
OCI8Connection
(
$username
,
$username
,
$password
,
$password
,
$this
->
_
constructDsn
(
$params
),
$this
->
constructDsn
(
$params
),
$params
[
'charset'
]
??
''
,
$params
[
'charset'
]
??
''
,
$params
[
'sessionMode'
]
??
OCI_DEFAULT
,
$params
[
'sessionMode'
]
??
OCI_DEFAULT
,
$params
[
'persistent'
]
??
false
$params
[
'persistent'
]
??
false
...
@@ -44,7 +44,7 @@ class Driver extends AbstractOracleDriver
...
@@ -44,7 +44,7 @@ class Driver extends AbstractOracleDriver
*
*
* @return string The DSN.
* @return string The DSN.
*/
*/
pr
otected
function
_
constructDsn
(
array
$params
)
:
string
pr
ivate
function
constructDsn
(
array
$params
)
:
string
{
{
return
$this
->
getEasyConnectString
(
$params
);
return
$this
->
getEasyConnectString
(
$params
);
}
}
...
...
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
View file @
cc386883
...
@@ -14,7 +14,7 @@ use PDO;
...
@@ -14,7 +14,7 @@ use PDO;
/**
/**
* PDO MySql driver.
* PDO MySql driver.
*/
*/
class
Driver
extends
AbstractMySQLDriver
final
class
Driver
extends
AbstractMySQLDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
@@ -50,7 +50,7 @@ class Driver extends AbstractMySQLDriver
...
@@ -50,7 +50,7 @@ class Driver extends AbstractMySQLDriver
*
*
* @return string The DSN.
* @return string The DSN.
*/
*/
pr
otected
function
constructPdoDsn
(
array
$params
)
:
string
pr
ivate
function
constructPdoDsn
(
array
$params
)
:
string
{
{
$dsn
=
'mysql:'
;
$dsn
=
'mysql:'
;
if
(
isset
(
$params
[
'host'
])
&&
$params
[
'host'
]
!==
''
)
{
if
(
isset
(
$params
[
'host'
])
&&
$params
[
'host'
]
!==
''
)
{
...
...
lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
View file @
cc386883
...
@@ -19,7 +19,7 @@ use PDO;
...
@@ -19,7 +19,7 @@ use PDO;
* which leads us to the recommendation to use the "oci8" driver to connect
* which leads us to the recommendation to use the "oci8" driver to connect
* to Oracle instead.
* to Oracle instead.
*/
*/
class
Driver
extends
AbstractOracleDriver
final
class
Driver
extends
AbstractOracleDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
...
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
View file @
cc386883
...
@@ -15,7 +15,7 @@ use function defined;
...
@@ -15,7 +15,7 @@ use function defined;
/**
/**
* Driver that connects through pdo_pgsql.
* Driver that connects through pdo_pgsql.
*/
*/
class
Driver
extends
AbstractPostgreSQLDriver
final
class
Driver
extends
AbstractPostgreSQLDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
@@ -32,7 +32,7 @@ class Driver extends AbstractPostgreSQLDriver
...
@@ -32,7 +32,7 @@ class Driver extends AbstractPostgreSQLDriver
try
{
try
{
$connection
=
new
PDOConnection
(
$connection
=
new
PDOConnection
(
$this
->
_
constructPdoDsn
(
$params
),
$this
->
constructPdoDsn
(
$params
),
$username
,
$username
,
$password
,
$password
,
$driverOptions
$driverOptions
...
@@ -67,7 +67,7 @@ class Driver extends AbstractPostgreSQLDriver
...
@@ -67,7 +67,7 @@ class Driver extends AbstractPostgreSQLDriver
*
*
* @return string The DSN.
* @return string The DSN.
*/
*/
private
function
_
constructPdoDsn
(
array
$params
)
:
string
private
function
constructPdoDsn
(
array
$params
)
:
string
{
{
$dsn
=
'pgsql:'
;
$dsn
=
'pgsql:'
;
...
...
lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
View file @
cc386883
...
@@ -15,10 +15,10 @@ use function array_merge;
...
@@ -15,10 +15,10 @@ use function array_merge;
/**
/**
* The PDO Sqlite driver.
* The PDO Sqlite driver.
*/
*/
class
Driver
extends
AbstractSQLiteDriver
final
class
Driver
extends
AbstractSQLiteDriver
{
{
/** @var mixed[] */
/** @var mixed[] */
pr
otected
$_
userDefinedFunctions
=
[
pr
ivate
$
userDefinedFunctions
=
[
'sqrt'
=>
[
'callback'
=>
[
SqlitePlatform
::
class
,
'udfSqrt'
],
'numArgs'
=>
1
],
'sqrt'
=>
[
'callback'
=>
[
SqlitePlatform
::
class
,
'udfSqrt'
],
'numArgs'
=>
1
],
'mod'
=>
[
'callback'
=>
[
SqlitePlatform
::
class
,
'udfMod'
],
'numArgs'
=>
2
],
'mod'
=>
[
'callback'
=>
[
SqlitePlatform
::
class
,
'udfMod'
],
'numArgs'
=>
2
],
'locate'
=>
[
'callback'
=>
[
SqlitePlatform
::
class
,
'udfLocate'
],
'numArgs'
=>
-
1
],
'locate'
=>
[
'callback'
=>
[
SqlitePlatform
::
class
,
'udfLocate'
],
'numArgs'
=>
-
1
],
...
@@ -34,8 +34,8 @@ class Driver extends AbstractSQLiteDriver
...
@@ -34,8 +34,8 @@ class Driver extends AbstractSQLiteDriver
array
$driverOptions
=
[]
array
$driverOptions
=
[]
)
:
Connection
{
)
:
Connection
{
if
(
isset
(
$driverOptions
[
'userDefinedFunctions'
]))
{
if
(
isset
(
$driverOptions
[
'userDefinedFunctions'
]))
{
$this
->
_
userDefinedFunctions
=
array_merge
(
$this
->
userDefinedFunctions
=
array_merge
(
$this
->
_
userDefinedFunctions
,
$this
->
userDefinedFunctions
,
$driverOptions
[
'userDefinedFunctions'
]
$driverOptions
[
'userDefinedFunctions'
]
);
);
unset
(
$driverOptions
[
'userDefinedFunctions'
]);
unset
(
$driverOptions
[
'userDefinedFunctions'
]);
...
@@ -43,7 +43,7 @@ class Driver extends AbstractSQLiteDriver
...
@@ -43,7 +43,7 @@ class Driver extends AbstractSQLiteDriver
try
{
try
{
$connection
=
new
PDOConnection
(
$connection
=
new
PDOConnection
(
$this
->
_
constructPdoDsn
(
$params
),
$this
->
constructPdoDsn
(
$params
),
$username
,
$username
,
$password
,
$password
,
$driverOptions
$driverOptions
...
@@ -54,7 +54,7 @@ class Driver extends AbstractSQLiteDriver
...
@@ -54,7 +54,7 @@ class Driver extends AbstractSQLiteDriver
$pdo
=
$connection
->
getWrappedConnection
();
$pdo
=
$connection
->
getWrappedConnection
();
foreach
(
$this
->
_
userDefinedFunctions
as
$fn
=>
$data
)
{
foreach
(
$this
->
userDefinedFunctions
as
$fn
=>
$data
)
{
$pdo
->
sqliteCreateFunction
(
$fn
,
$data
[
'callback'
],
$data
[
'numArgs'
]);
$pdo
->
sqliteCreateFunction
(
$fn
,
$data
[
'callback'
],
$data
[
'numArgs'
]);
}
}
...
@@ -68,7 +68,7 @@ class Driver extends AbstractSQLiteDriver
...
@@ -68,7 +68,7 @@ class Driver extends AbstractSQLiteDriver
*
*
* @return string The DSN.
* @return string The DSN.
*/
*/
pr
otected
function
_
constructPdoDsn
(
array
$params
)
:
string
pr
ivate
function
constructPdoDsn
(
array
$params
)
:
string
{
{
$dsn
=
'sqlite:'
;
$dsn
=
'sqlite:'
;
if
(
isset
(
$params
[
'path'
]))
{
if
(
isset
(
$params
[
'path'
]))
{
...
...
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
View file @
cc386883
...
@@ -13,7 +13,7 @@ use function sprintf;
...
@@ -13,7 +13,7 @@ use function sprintf;
/**
/**
* The PDO-based Sqlsrv driver.
* The PDO-based Sqlsrv driver.
*/
*/
class
Driver
extends
AbstractSQLServerDriver
final
class
Driver
extends
AbstractSQLServerDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
@@ -39,7 +39,7 @@ class Driver extends AbstractSQLServerDriver
...
@@ -39,7 +39,7 @@ class Driver extends AbstractSQLServerDriver
}
}
return
new
Connection
(
return
new
Connection
(
$this
->
_
constructPdoDsn
(
$params
,
$dsnOptions
),
$this
->
constructPdoDsn
(
$params
,
$dsnOptions
),
$username
,
$username
,
$password
,
$password
,
$pdoOptions
$pdoOptions
...
@@ -54,7 +54,7 @@ class Driver extends AbstractSQLServerDriver
...
@@ -54,7 +54,7 @@ class Driver extends AbstractSQLServerDriver
*
*
* @return string The DSN.
* @return string The DSN.
*/
*/
private
function
_
constructPdoDsn
(
array
$params
,
array
$connectionOptions
)
:
string
private
function
constructPdoDsn
(
array
$params
,
array
$connectionOptions
)
:
string
{
{
$dsn
=
'sqlsrv:server='
;
$dsn
=
'sqlsrv:server='
;
...
...
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
View file @
cc386883
...
@@ -11,7 +11,7 @@ use PDO;
...
@@ -11,7 +11,7 @@ use PDO;
/**
/**
* PDO SQL Server Statement
* PDO SQL Server Statement
*/
*/
class
Statement
extends
PDOStatement
final
class
Statement
extends
PDOStatement
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
...
lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
View file @
cc386883
...
@@ -16,7 +16,7 @@ use function sprintf;
...
@@ -16,7 +16,7 @@ use function sprintf;
/**
/**
* A Doctrine DBAL driver for the SAP Sybase SQL Anywhere PHP extension.
* A Doctrine DBAL driver for the SAP Sybase SQL Anywhere PHP extension.
*/
*/
class
Driver
extends
AbstractSQLAnywhereDriver
final
class
Driver
extends
AbstractSQLAnywhereDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
...
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
View file @
cc386883
...
@@ -23,7 +23,7 @@ use function sasql_set_option;
...
@@ -23,7 +23,7 @@ use function sasql_set_option;
/**
/**
* SAP Sybase SQL Anywhere implementation of the Connection interface.
* SAP Sybase SQL Anywhere implementation of the Connection interface.
*/
*/
class
SQLAnywhereConnection
implements
ServerInfoAwareConnection
final
class
SQLAnywhereConnection
implements
ServerInfoAwareConnection
{
{
/** @var resource The SQL Anywhere connection resource. */
/** @var resource The SQL Anywhere connection resource. */
private
$connection
;
private
$connection
;
...
...
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
View file @
cc386883
...
@@ -40,7 +40,7 @@ use function sprintf;
...
@@ -40,7 +40,7 @@ use function sprintf;
/**
/**
* SAP SQL Anywhere implementation of the Statement interface.
* SAP SQL Anywhere implementation of the Statement interface.
*/
*/
class
SQLAnywhereStatement
implements
IteratorAggregate
,
Statement
final
class
SQLAnywhereStatement
implements
IteratorAggregate
,
Statement
{
{
/** @var resource The connection resource. */
/** @var resource The connection resource. */
private
$conn
;
private
$conn
;
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
View file @
cc386883
...
@@ -10,7 +10,7 @@ use Doctrine\DBAL\Driver\Connection;
...
@@ -10,7 +10,7 @@ use Doctrine\DBAL\Driver\Connection;
/**
/**
* Driver for ext/sqlsrv.
* Driver for ext/sqlsrv.
*/
*/
class
Driver
extends
AbstractSQLServerDriver
final
class
Driver
extends
AbstractSQLServerDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
View file @
cc386883
...
@@ -20,13 +20,13 @@ use function str_replace;
...
@@ -20,13 +20,13 @@ use function str_replace;
/**
/**
* SQL Server implementation for the Connection interface.
* SQL Server implementation for the Connection interface.
*/
*/
class
SQLSrvConnection
implements
ServerInfoAwareConnection
final
class
SQLSrvConnection
implements
ServerInfoAwareConnection
{
{
/** @var resource */
/** @var resource */
pr
otected
$conn
;
pr
ivate
$conn
;
/** @var LastInsertId */
/** @var LastInsertId */
pr
otected
$lastInsertId
;
pr
ivate
$lastInsertId
;
/**
/**
* @param array<string, mixed> $connectionOptions
* @param array<string, mixed> $connectionOptions
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
View file @
cc386883
...
@@ -37,7 +37,7 @@ use function stripos;
...
@@ -37,7 +37,7 @@ use function stripos;
/**
/**
* SQL Server Statement.
* SQL Server Statement.
*/
*/
class
SQLSrvStatement
implements
IteratorAggregate
,
Statement
final
class
SQLSrvStatement
implements
IteratorAggregate
,
Statement
{
{
/**
/**
* The SQLSRV Resource.
* The SQLSRV Resource.
...
@@ -232,51 +232,6 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -232,51 +232,6 @@ class SQLSrvStatement implements IteratorAggregate, Statement
$this
->
result
=
true
;
$this
->
result
=
true
;
}
}
/**
* Prepares SQL Server statement resource
*
* @return resource
*
* @throws SQLSrvException
*/
private
function
prepare
()
{
$params
=
[];
foreach
(
$this
->
variables
as
$column
=>
&
$variable
)
{
switch
(
$this
->
types
[
$column
])
{
case
ParameterType
::
LARGE_OBJECT
:
$params
[
$column
-
1
]
=
[
&
$variable
,
SQLSRV_PARAM_IN
,
SQLSRV_PHPTYPE_STREAM
(
SQLSRV_ENC_BINARY
),
SQLSRV_SQLTYPE_VARBINARY
(
'max'
),
];
break
;
case
ParameterType
::
BINARY
:
$params
[
$column
-
1
]
=
[
&
$variable
,
SQLSRV_PARAM_IN
,
SQLSRV_PHPTYPE_STRING
(
SQLSRV_ENC_BINARY
),
];
break
;
default
:
$params
[
$column
-
1
]
=&
$variable
;
break
;
}
}
$stmt
=
sqlsrv_prepare
(
$this
->
conn
,
$this
->
sql
,
$params
);
if
(
!
$stmt
)
{
throw
SQLSrvException
::
fromSqlSrvErrors
();
}
return
$stmt
;
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
@@ -399,4 +354,49 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -399,4 +354,49 @@ class SQLSrvStatement implements IteratorAggregate, Statement
return
sqlsrv_rows_affected
(
$this
->
stmt
)
?:
0
;
return
sqlsrv_rows_affected
(
$this
->
stmt
)
?:
0
;
}
}
/**
* Prepares SQL Server statement resource
*
* @return resource
*
* @throws SQLSrvException
*/
private
function
prepare
()
{
$params
=
[];
foreach
(
$this
->
variables
as
$column
=>
&
$variable
)
{
switch
(
$this
->
types
[
$column
])
{
case
ParameterType
::
LARGE_OBJECT
:
$params
[
$column
-
1
]
=
[
&
$variable
,
SQLSRV_PARAM_IN
,
SQLSRV_PHPTYPE_STREAM
(
SQLSRV_ENC_BINARY
),
SQLSRV_SQLTYPE_VARBINARY
(
'max'
),
];
break
;
case
ParameterType
::
BINARY
:
$params
[
$column
-
1
]
=
[
&
$variable
,
SQLSRV_PARAM_IN
,
SQLSRV_PHPTYPE_STRING
(
SQLSRV_ENC_BINARY
),
];
break
;
default
:
$params
[
$column
-
1
]
=&
$variable
;
break
;
}
}
$stmt
=
sqlsrv_prepare
(
$this
->
conn
,
$this
->
sql
,
$params
);
if
(
!
$stmt
)
{
throw
SQLSrvException
::
fromSqlSrvErrors
();
}
return
$stmt
;
}
}
}
lib/Doctrine/DBAL/Driver/StatementIterator.php
View file @
cc386883
...
@@ -6,7 +6,7 @@ namespace Doctrine\DBAL\Driver;
...
@@ -6,7 +6,7 @@ namespace Doctrine\DBAL\Driver;
use
IteratorAggregate
;
use
IteratorAggregate
;
class
StatementIterator
implements
IteratorAggregate
final
class
StatementIterator
implements
IteratorAggregate
{
{
/** @var ResultStatement */
/** @var ResultStatement */
private
$statement
;
private
$statement
;
...
...
lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php
View file @
cc386883
...
@@ -12,7 +12,7 @@ use Doctrine\DBAL\Schema\Sequence;
...
@@ -12,7 +12,7 @@ use Doctrine\DBAL\Schema\Sequence;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\Visitor\Visitor
;
use
Doctrine\DBAL\Schema\Visitor\Visitor
;
class
TableGeneratorSchemaVisitor
implements
Visitor
final
class
TableGeneratorSchemaVisitor
implements
Visitor
{
{
/** @var string */
/** @var string */
private
$generatorTableName
;
private
$generatorTableName
;
...
...
lib/Doctrine/DBAL/Portability/Statement.php
View file @
cc386883
...
@@ -18,7 +18,7 @@ use function rtrim;
...
@@ -18,7 +18,7 @@ use function rtrim;
/**
/**
* Portability wrapper for a Statement.
* Portability wrapper for a Statement.
*/
*/
class
Statement
implements
IteratorAggregate
,
DriverStatement
final
class
Statement
implements
IteratorAggregate
,
DriverStatement
{
{
/** @var int */
/** @var int */
private
$portability
;
private
$portability
;
...
@@ -164,34 +164,6 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -164,34 +164,6 @@ class Statement implements IteratorAggregate, DriverStatement
return
$rows
;
return
$rows
;
}
}
/**
* @param mixed $row
*
* @return mixed
*/
protected
function
fixRow
(
$row
,
bool
$iterateRow
,
bool
$fixCase
)
{
if
(
!
$row
)
{
return
$row
;
}
if
(
$fixCase
)
{
$row
=
array_change_key_case
(
$row
,
$this
->
case
);
}
if
(
$iterateRow
)
{
foreach
(
$row
as
$k
=>
$v
)
{
if
((
$this
->
portability
&
Connection
::
PORTABILITY_EMPTY_TO_NULL
)
&&
$v
===
''
)
{
$row
[
$k
]
=
null
;
}
elseif
((
$this
->
portability
&
Connection
::
PORTABILITY_RTRIM
)
&&
is_string
(
$v
))
{
$row
[
$k
]
=
rtrim
(
$v
);
}
}
}
return
$row
;
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
@@ -219,4 +191,32 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -219,4 +191,32 @@ class Statement implements IteratorAggregate, DriverStatement
return
$this
->
stmt
->
rowCount
();
return
$this
->
stmt
->
rowCount
();
}
}
/**
* @param mixed $row
*
* @return mixed
*/
private
function
fixRow
(
$row
,
bool
$iterateRow
,
bool
$fixCase
)
{
if
(
!
$row
)
{
return
$row
;
}
if
(
$fixCase
)
{
$row
=
array_change_key_case
(
$row
,
$this
->
case
);
}
if
(
$iterateRow
)
{
foreach
(
$row
as
$k
=>
$v
)
{
if
((
$this
->
portability
&
Connection
::
PORTABILITY_EMPTY_TO_NULL
)
&&
$v
===
''
)
{
$row
[
$k
]
=
null
;
}
elseif
((
$this
->
portability
&
Connection
::
PORTABILITY_RTRIM
)
&&
is_string
(
$v
))
{
$row
[
$k
]
=
rtrim
(
$v
);
}
}
}
return
$row
;
}
}
}
lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php
View file @
cc386883
...
@@ -14,7 +14,7 @@ use function count;
...
@@ -14,7 +14,7 @@ use function count;
/**
/**
* Schema Synchronizer for Default DBAL Connection.
* Schema Synchronizer for Default DBAL Connection.
*/
*/
class
SingleDatabaseSynchronizer
extends
AbstractSchemaSynchronizer
final
class
SingleDatabaseSynchronizer
extends
AbstractSchemaSynchronizer
{
{
/** @var AbstractPlatform */
/** @var AbstractPlatform */
private
$platform
;
private
$platform
;
...
...
lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
View file @
cc386883
...
@@ -20,7 +20,7 @@ use Doctrine\DBAL\Schema\Table;
...
@@ -20,7 +20,7 @@ use Doctrine\DBAL\Schema\Table;
* This visitor filters all these non-default namespaced tables and sequences
* This visitor filters all these non-default namespaced tables and sequences
* and removes them from the SChema instance.
* and removes them from the SChema instance.
*/
*/
class
RemoveNamespacedAssets
extends
AbstractVisitor
final
class
RemoveNamespacedAssets
extends
AbstractVisitor
{
{
/** @var Schema */
/** @var Schema */
private
$schema
;
private
$schema
;
...
...
tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php
View file @
cc386883
...
@@ -4,35 +4,14 @@ declare(strict_types=1);
...
@@ -4,35 +4,14 @@ declare(strict_types=1);
namespace
Doctrine\Tests\DBAL\Driver
;
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Driver\IBMDB2\DB2Statement
;
use
Doctrine\DBAL\Driver\Mysqli\MysqliStatement
;
use
Doctrine\DBAL\Driver\OCI8\OCI8Statement
;
use
Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereStatement
;
use
Doctrine\DBAL\Driver\SQLSrv\SQLSrvStatement
;
use
Doctrine\DBAL\Driver\Statement
;
use
Doctrine\DBAL\Driver\Statement
;
use
Doctrine\DBAL\Driver\StatementIterator
;
use
Doctrine\DBAL\Driver\StatementIterator
;
use
Doctrine\DBAL\Portability\Statement
as
PortabilityStatement
;
use
Doctrine\Tests\DbalTestCase
;
use
Doctrine\Tests\DbalTestCase
;
use
IteratorAggregate
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
function
extension_loaded
;
use
Traversable
;
class
StatementIteratorTest
extends
DbalTestCase
class
StatementIteratorTest
extends
DbalTestCase
{
{
/**
* @dataProvider statementProvider()
*/
public
function
testGettingIteratorDoesNotCallFetch
(
string
$class
)
:
void
{
/** @var IteratorAggregate|MockObject $stmt */
$stmt
=
$this
->
createPartialMock
(
$class
,
[
'fetch'
,
'fetchAll'
,
'fetchColumn'
]);
$stmt
->
expects
(
$this
->
never
())
->
method
(
'fetch'
);
$stmt
->
expects
(
$this
->
never
())
->
method
(
'fetchAll'
);
$stmt
->
expects
(
$this
->
never
())
->
method
(
'fetchColumn'
);
$stmt
->
getIterator
();
}
public
function
testIteratorIterationCallsFetchOncePerStep
()
:
void
public
function
testIteratorIterationCallsFetchOncePerStep
()
:
void
{
{
$stmt
=
$this
->
createMock
(
Statement
::
class
);
$stmt
=
$this
->
createMock
(
Statement
::
class
);
...
@@ -45,20 +24,6 @@ class StatementIteratorTest extends DbalTestCase
...
@@ -45,20 +24,6 @@ class StatementIteratorTest extends DbalTestCase
$this
->
assertIterationCallsFetchOncePerStep
(
$stmtIterator
,
$calls
);
$this
->
assertIterationCallsFetchOncePerStep
(
$stmtIterator
,
$calls
);
}
}
/**
* @dataProvider statementProvider()
*/
public
function
testStatementIterationCallsFetchOncePerStep
(
string
$class
)
:
void
{
/** @var iterable<int, mixed>|MockObject $stmt */
$stmt
=
$this
->
createPartialMock
(
$class
,
[
'fetch'
]);
$calls
=
0
;
$this
->
configureStatement
(
$stmt
,
$calls
);
$this
->
assertIterationCallsFetchOncePerStep
(
$stmt
,
$calls
);
}
private
function
configureStatement
(
MockObject
$stmt
,
int
&
$calls
)
:
void
private
function
configureStatement
(
MockObject
$stmt
,
int
&
$calls
)
:
void
{
{
$values
=
[
'foo'
,
''
,
'bar'
,
'0'
,
'baz'
,
0
,
'qux'
,
null
,
'quz'
,
false
,
'impossible'
];
$values
=
[
'foo'
,
''
,
'bar'
,
'0'
,
'baz'
,
0
,
'qux'
,
null
,
'quz'
,
false
,
'impossible'
];
...
@@ -74,33 +39,7 @@ class StatementIteratorTest extends DbalTestCase
...
@@ -74,33 +39,7 @@ class StatementIteratorTest extends DbalTestCase
});
});
}
}
/**
private
function
assertIterationCallsFetchOncePerStep
(
Traversable
$iterator
,
int
&
$calls
)
:
void
* @return string[][]
*/
public
static
function
statementProvider
()
:
iterable
{
if
(
extension_loaded
(
'ibm_db2'
))
{
yield
[
DB2Statement
::
class
];
}
yield
[
MysqliStatement
::
class
];
if
(
extension_loaded
(
'oci8'
))
{
yield
[
OCI8Statement
::
class
];
}
yield
[
PortabilityStatement
::
class
];
yield
[
SQLAnywhereStatement
::
class
];
if
(
extension_loaded
(
'sqlsrv'
))
{
yield
[
SQLSrvStatement
::
class
];
}
}
/**
* @param iterable<int, mixed> $iterator
*/
private
function
assertIterationCallsFetchOncePerStep
(
iterable
$iterator
,
int
&
$calls
)
:
void
{
{
foreach
(
$iterator
as
$i
=>
$_
)
{
foreach
(
$iterator
as
$i
=>
$_
)
{
$this
->
assertEquals
(
$i
+
1
,
$calls
);
$this
->
assertEquals
(
$i
+
1
,
$calls
);
...
...
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