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
7336ae0a
Unverified
Commit
7336ae0a
authored
Apr 02, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid implicit conversion to boolean
parent
6c4401f4
Changes
60
Hide whitespace changes
Inline
Side-by-side
Showing
60 changed files
with
252 additions
and
224 deletions
+252
-224
phpstan.neon.dist
phpstan.neon.dist
+9
-0
ArrayStatement.php
src/Cache/ArrayStatement.php
+1
-1
ResultCacheStatement.php
src/Cache/ResultCacheStatement.php
+2
-2
Configuration.php
src/Configuration.php
+2
-2
Connection.php
src/Connection.php
+26
-26
MasterSlaveConnection.php
src/Connections/MasterSlaveConnection.php
+2
-2
DBALException.php
src/DBALException.php
+3
-2
AbstractMySQLDriver.php
src/Driver/AbstractMySQLDriver.php
+4
-4
AbstractPostgreSQLDriver.php
src/Driver/AbstractPostgreSQLDriver.php
+1
-1
AbstractSQLAnywhereDriver.php
src/Driver/AbstractSQLAnywhereDriver.php
+2
-2
DB2Connection.php
src/Driver/IBMDB2/DB2Connection.php
+1
-1
OCI8Connection.php
src/Driver/OCI8/OCI8Connection.php
+1
-1
OCI8Statement.php
src/Driver/OCI8/OCI8Statement.php
+4
-5
SQLAnywhereException.php
src/Driver/SQLAnywhere/SQLAnywhereException.php
+5
-5
SQLAnywhereStatement.php
src/Driver/SQLAnywhere/SQLAnywhereStatement.php
+1
-2
SQLSrvConnection.php
src/Driver/SQLSrv/SQLSrvConnection.php
+1
-1
SQLSrvException.php
src/Driver/SQLSrv/SQLSrvException.php
+1
-1
SQLSrvStatement.php
src/Driver/SQLSrv/SQLSrvStatement.php
+5
-6
DriverManager.php
src/DriverManager.php
+2
-2
MysqlSessionInit.php
src/Event/Listeners/MysqlSessionInit.php
+7
-2
OracleSessionInit.php
src/Event/Listeners/OracleSessionInit.php
+1
-1
AbstractPlatform.php
src/Platforms/AbstractPlatform.php
+8
-9
DB2Platform.php
src/Platforms/DB2Platform.php
+5
-5
ReservedKeywordsValidator.php
src/Platforms/Keywords/ReservedKeywordsValidator.php
+2
-1
MySqlPlatform.php
src/Platforms/MySqlPlatform.php
+5
-5
OraclePlatform.php
src/Platforms/OraclePlatform.php
+17
-13
PostgreSQL94Platform.php
src/Platforms/PostgreSQL94Platform.php
+5
-5
SQLAnywhere16Platform.php
src/Platforms/SQLAnywhere16Platform.php
+4
-4
SQLServer2012Platform.php
src/Platforms/SQLServer2012Platform.php
+13
-11
SqlitePlatform.php
src/Platforms/SqlitePlatform.php
+6
-6
Connection.php
src/Portability/Connection.php
+1
-1
Statement.php
src/Portability/Statement.php
+12
-14
QueryBuilder.php
src/Query/QueryBuilder.php
+5
-5
SQLParserUtils.php
src/SQLParserUtils.php
+3
-3
AbstractAsset.php
src/Schema/AbstractAsset.php
+2
-2
AbstractSchemaManager.php
src/Schema/AbstractSchemaManager.php
+9
-27
ColumnDiff.php
src/Schema/ColumnDiff.php
+1
-1
Comparator.php
src/Schema/Comparator.php
+1
-1
DB2SchemaManager.php
src/Schema/DB2SchemaManager.php
+1
-1
MySqlSchemaManager.php
src/Schema/MySqlSchemaManager.php
+6
-2
OracleSchemaManager.php
src/Schema/OracleSchemaManager.php
+3
-3
PostgreSqlSchemaManager.php
src/Schema/PostgreSqlSchemaManager.php
+30
-9
SQLServerSchemaManager.php
src/Schema/SQLServerSchemaManager.php
+1
-1
SqliteSchemaManager.php
src/Schema/SqliteSchemaManager.php
+2
-2
Table.php
src/Schema/Table.php
+3
-3
Statement.php
src/Statement.php
+4
-5
ReservedWordsCommand.php
src/Tools/Console/Command/ReservedWordsCommand.php
+1
-1
RunSqlCommand.php
src/Tools/Console/Command/RunSqlCommand.php
+5
-1
DateImmutableType.php
src/Types/DateImmutableType.php
+1
-1
DateTimeImmutableType.php
src/Types/DateTimeImmutableType.php
+2
-2
DateTimeType.php
src/Types/DateTimeType.php
+2
-2
DateTimeTzImmutableType.php
src/Types/DateTimeTzImmutableType.php
+1
-1
DateTimeTzType.php
src/Types/DateTimeTzType.php
+1
-1
DateType.php
src/Types/DateType.php
+1
-1
SimpleArrayType.php
src/Types/SimpleArrayType.php
+3
-1
TimeImmutableType.php
src/Types/TimeImmutableType.php
+1
-1
TimeType.php
src/Types/TimeType.php
+1
-1
VarDateTimeImmutableType.php
src/Types/VarDateTimeImmutableType.php
+1
-1
VarDateTimeType.php
src/Types/VarDateTimeType.php
+1
-1
FunctionalTestCase.php
tests/FunctionalTestCase.php
+1
-1
No files found.
phpstan.neon.dist
View file @
7336ae0a
...
@@ -88,5 +88,14 @@ parameters:
...
@@ -88,5 +88,14 @@ parameters:
- %currentWorkingDirectory%/src/Driver/AbstractOracleDriver/EasyConnectString.php
- %currentWorkingDirectory%/src/Driver/AbstractOracleDriver/EasyConnectString.php
- %currentWorkingDirectory%/src/Platforms/*Platform.php
- %currentWorkingDirectory%/src/Platforms/*Platform.php
- %currentWorkingDirectory%/src/Schema/*SchemaManager.php
- %currentWorkingDirectory%/src/Schema/*SchemaManager.php
# In some namespaces, we use array<string,mixed>, some elements of which are actually boolean
-
message: '~^Only booleans are allowed in .*, mixed given~'
paths:
- %currentWorkingDirectory%/src/Driver/*/Driver.php
- %currentWorkingDirectory%/src/Platforms/*Platform.php
- %currentWorkingDirectory%/src/Query/QueryBuilder.php
- %currentWorkingDirectory%/src/Schema/*SchemaManager.php
includes:
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
src/Cache/ArrayStatement.php
View file @
7336ae0a
...
@@ -32,7 +32,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
...
@@ -32,7 +32,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
public
function
__construct
(
array
$data
)
public
function
__construct
(
array
$data
)
{
{
$this
->
data
=
$data
;
$this
->
data
=
$data
;
if
(
!
count
(
$data
)
)
{
if
(
count
(
$data
)
===
0
)
{
return
;
return
;
}
}
...
...
src/Cache/ResultCacheStatement.php
View file @
7336ae0a
...
@@ -82,7 +82,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -82,7 +82,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
}
}
$data
=
$this
->
resultCache
->
fetch
(
$this
->
cacheKey
);
$data
=
$this
->
resultCache
->
fetch
(
$this
->
cacheKey
);
if
(
!
$data
)
{
if
(
$data
===
false
)
{
$data
=
[];
$data
=
[];
}
}
$data
[
$this
->
realKey
]
=
$this
->
data
;
$data
[
$this
->
realKey
]
=
$this
->
data
;
...
@@ -132,7 +132,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
...
@@ -132,7 +132,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
$row
=
$this
->
statement
->
fetch
(
FetchMode
::
ASSOCIATIVE
);
$row
=
$this
->
statement
->
fetch
(
FetchMode
::
ASSOCIATIVE
);
if
(
$row
)
{
if
(
$row
!==
false
)
{
$this
->
data
[]
=
$row
;
$this
->
data
[]
=
$row
;
$fetchMode
=
$fetchMode
??
$this
->
defaultFetchMode
;
$fetchMode
=
$fetchMode
??
$this
->
defaultFetchMode
;
...
...
src/Configuration.php
View file @
7336ae0a
...
@@ -72,14 +72,14 @@ class Configuration
...
@@ -72,14 +72,14 @@ class Configuration
*
*
* @deprecated Use Configuration::setSchemaAssetsFilter() instead
* @deprecated Use Configuration::setSchemaAssetsFilter() instead
*
*
* @param string $filterExpression
* @param string
|null
$filterExpression
*
*
* @return void
* @return void
*/
*/
public
function
setFilterSchemaAssetsExpression
(
$filterExpression
)
public
function
setFilterSchemaAssetsExpression
(
$filterExpression
)
{
{
$this
->
_attributes
[
'filterSchemaAssetsExpression'
]
=
$filterExpression
;
$this
->
_attributes
[
'filterSchemaAssetsExpression'
]
=
$filterExpression
;
if
(
$filterExpression
)
{
if
(
$filterExpression
!==
null
)
{
$this
->
_attributes
[
'filterSchemaAssetsExpressionCallable'
]
=
$this
->
buildSchemaAssetsFilterFromExpression
(
$filterExpression
);
$this
->
_attributes
[
'filterSchemaAssetsExpressionCallable'
]
=
$this
->
buildSchemaAssetsFilterFromExpression
(
$filterExpression
);
}
else
{
}
else
{
$this
->
_attributes
[
'filterSchemaAssetsExpressionCallable'
]
=
null
;
$this
->
_attributes
[
'filterSchemaAssetsExpressionCallable'
]
=
null
;
...
...
src/Connection.php
View file @
7336ae0a
...
@@ -197,11 +197,11 @@ class Connection implements DriverConnection
...
@@ -197,11 +197,11 @@ class Connection implements DriverConnection
}
}
// Create default config and event manager if none given
// Create default config and event manager if none given
if
(
!
$config
)
{
if
(
$config
===
null
)
{
$config
=
new
Configuration
();
$config
=
new
Configuration
();
}
}
if
(
!
$eventManager
)
{
if
(
$eventManager
===
null
)
{
$eventManager
=
new
EventManager
();
$eventManager
=
new
EventManager
();
}
}
...
@@ -884,16 +884,16 @@ class Connection implements DriverConnection
...
@@ -884,16 +884,16 @@ class Connection implements DriverConnection
$connection
=
$this
->
getWrappedConnection
();
$connection
=
$this
->
getWrappedConnection
();
$logger
=
$this
->
_config
->
getSQLLogger
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
$query
,
$params
,
$types
);
$logger
->
startQuery
(
$query
,
$params
,
$types
);
}
}
try
{
try
{
if
(
$params
)
{
if
(
count
(
$params
)
>
0
)
{
[
$query
,
$params
,
$types
]
=
SQLParserUtils
::
expandListParameters
(
$query
,
$params
,
$types
);
[
$query
,
$params
,
$types
]
=
SQLParserUtils
::
expandListParameters
(
$query
,
$params
,
$types
);
$stmt
=
$connection
->
prepare
(
$query
);
$stmt
=
$connection
->
prepare
(
$query
);
if
(
$types
)
{
if
(
count
(
$types
)
>
0
)
{
$this
->
_bindTypedValues
(
$stmt
,
$params
,
$types
);
$this
->
_bindTypedValues
(
$stmt
,
$params
,
$types
);
$stmt
->
execute
();
$stmt
->
execute
();
}
else
{
}
else
{
...
@@ -908,7 +908,7 @@ class Connection implements DriverConnection
...
@@ -908,7 +908,7 @@ class Connection implements DriverConnection
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
...
@@ -993,7 +993,7 @@ class Connection implements DriverConnection
...
@@ -993,7 +993,7 @@ class Connection implements DriverConnection
$connection
=
$this
->
getWrappedConnection
();
$connection
=
$this
->
getWrappedConnection
();
$logger
=
$this
->
_config
->
getSQLLogger
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
$sql
);
$logger
->
startQuery
(
$sql
);
}
}
...
@@ -1005,7 +1005,7 @@ class Connection implements DriverConnection
...
@@ -1005,7 +1005,7 @@ class Connection implements DriverConnection
$statement
->
setFetchMode
(
$this
->
defaultFetchMode
);
$statement
->
setFetchMode
(
$this
->
defaultFetchMode
);
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
...
@@ -1029,17 +1029,17 @@ class Connection implements DriverConnection
...
@@ -1029,17 +1029,17 @@ class Connection implements DriverConnection
$connection
=
$this
->
getWrappedConnection
();
$connection
=
$this
->
getWrappedConnection
();
$logger
=
$this
->
_config
->
getSQLLogger
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
$query
,
$params
,
$types
);
$logger
->
startQuery
(
$query
,
$params
,
$types
);
}
}
try
{
try
{
if
(
$params
)
{
if
(
count
(
$params
)
>
0
)
{
[
$query
,
$params
,
$types
]
=
SQLParserUtils
::
expandListParameters
(
$query
,
$params
,
$types
);
[
$query
,
$params
,
$types
]
=
SQLParserUtils
::
expandListParameters
(
$query
,
$params
,
$types
);
$stmt
=
$connection
->
prepare
(
$query
);
$stmt
=
$connection
->
prepare
(
$query
);
if
(
$types
)
{
if
(
count
(
$types
)
>
0
)
{
$this
->
_bindTypedValues
(
$stmt
,
$params
,
$types
);
$this
->
_bindTypedValues
(
$stmt
,
$params
,
$types
);
$stmt
->
execute
();
$stmt
->
execute
();
}
else
{
}
else
{
...
@@ -1053,7 +1053,7 @@ class Connection implements DriverConnection
...
@@ -1053,7 +1053,7 @@ class Connection implements DriverConnection
throw
DBALException
::
driverExceptionDuringQuery
(
$this
->
_driver
,
$ex
,
$query
,
$this
->
resolveParams
(
$params
,
$types
));
throw
DBALException
::
driverExceptionDuringQuery
(
$this
->
_driver
,
$ex
,
$query
,
$this
->
resolveParams
(
$params
,
$types
));
}
}
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
...
@@ -1068,7 +1068,7 @@ class Connection implements DriverConnection
...
@@ -1068,7 +1068,7 @@ class Connection implements DriverConnection
$connection
=
$this
->
getWrappedConnection
();
$connection
=
$this
->
getWrappedConnection
();
$logger
=
$this
->
_config
->
getSQLLogger
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
$statement
);
$logger
->
startQuery
(
$statement
);
}
}
...
@@ -1078,7 +1078,7 @@ class Connection implements DriverConnection
...
@@ -1078,7 +1078,7 @@ class Connection implements DriverConnection
throw
DBALException
::
driverExceptionDuringQuery
(
$this
->
_driver
,
$ex
,
$statement
);
throw
DBALException
::
driverExceptionDuringQuery
(
$this
->
_driver
,
$ex
,
$statement
);
}
}
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
...
@@ -1217,21 +1217,21 @@ class Connection implements DriverConnection
...
@@ -1217,21 +1217,21 @@ class Connection implements DriverConnection
$logger
=
$this
->
_config
->
getSQLLogger
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$this
->
transactionNestingLevel
===
1
)
{
if
(
$this
->
transactionNestingLevel
===
1
)
{
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
'"START TRANSACTION"'
);
$logger
->
startQuery
(
'"START TRANSACTION"'
);
}
}
$connection
->
beginTransaction
();
$connection
->
beginTransaction
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
}
elseif
(
$this
->
nestTransactionsWithSavepoints
)
{
}
elseif
(
$this
->
nestTransactionsWithSavepoints
)
{
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
'"SAVEPOINT"'
);
$logger
->
startQuery
(
'"SAVEPOINT"'
);
}
}
$this
->
createSavepoint
(
$this
->
_getNestedTransactionSavePointName
());
$this
->
createSavepoint
(
$this
->
_getNestedTransactionSavePointName
());
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
}
}
...
@@ -1261,21 +1261,21 @@ class Connection implements DriverConnection
...
@@ -1261,21 +1261,21 @@ class Connection implements DriverConnection
$logger
=
$this
->
_config
->
getSQLLogger
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$this
->
transactionNestingLevel
===
1
)
{
if
(
$this
->
transactionNestingLevel
===
1
)
{
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
'"COMMIT"'
);
$logger
->
startQuery
(
'"COMMIT"'
);
}
}
$result
=
$connection
->
commit
();
$result
=
$connection
->
commit
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
}
elseif
(
$this
->
nestTransactionsWithSavepoints
)
{
}
elseif
(
$this
->
nestTransactionsWithSavepoints
)
{
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
'"RELEASE SAVEPOINT"'
);
$logger
->
startQuery
(
'"RELEASE SAVEPOINT"'
);
}
}
$this
->
releaseSavepoint
(
$this
->
_getNestedTransactionSavePointName
());
$this
->
releaseSavepoint
(
$this
->
_getNestedTransactionSavePointName
());
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
}
}
...
@@ -1327,13 +1327,13 @@ class Connection implements DriverConnection
...
@@ -1327,13 +1327,13 @@ class Connection implements DriverConnection
$logger
=
$this
->
_config
->
getSQLLogger
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$this
->
transactionNestingLevel
===
1
)
{
if
(
$this
->
transactionNestingLevel
===
1
)
{
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
'"ROLLBACK"'
);
$logger
->
startQuery
(
'"ROLLBACK"'
);
}
}
$this
->
transactionNestingLevel
=
0
;
$this
->
transactionNestingLevel
=
0
;
$connection
->
rollBack
();
$connection
->
rollBack
();
$this
->
isRollbackOnly
=
false
;
$this
->
isRollbackOnly
=
false
;
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
...
@@ -1341,12 +1341,12 @@ class Connection implements DriverConnection
...
@@ -1341,12 +1341,12 @@ class Connection implements DriverConnection
$this
->
beginTransaction
();
$this
->
beginTransaction
();
}
}
}
elseif
(
$this
->
nestTransactionsWithSavepoints
)
{
}
elseif
(
$this
->
nestTransactionsWithSavepoints
)
{
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
'"ROLLBACK TO SAVEPOINT"'
);
$logger
->
startQuery
(
'"ROLLBACK TO SAVEPOINT"'
);
}
}
$this
->
rollbackSavepoint
(
$this
->
_getNestedTransactionSavePointName
());
$this
->
rollbackSavepoint
(
$this
->
_getNestedTransactionSavePointName
());
--
$this
->
transactionNestingLevel
;
--
$this
->
transactionNestingLevel
;
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
}
else
{
}
else
{
...
...
src/Connections/MasterSlaveConnection.php
View file @
7336ae0a
...
@@ -351,7 +351,7 @@ class MasterSlaveConnection extends Connection
...
@@ -351,7 +351,7 @@ class MasterSlaveConnection extends Connection
assert
(
$this
->
_conn
instanceof
DriverConnection
);
assert
(
$this
->
_conn
instanceof
DriverConnection
);
$logger
=
$this
->
getConfiguration
()
->
getSQLLogger
();
$logger
=
$this
->
getConfiguration
()
->
getSQLLogger
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
$sql
);
$logger
->
startQuery
(
$sql
);
}
}
...
@@ -359,7 +359,7 @@ class MasterSlaveConnection extends Connection
...
@@ -359,7 +359,7 @@ class MasterSlaveConnection extends Connection
$statement
->
setFetchMode
(
$this
->
defaultFetchMode
);
$statement
->
setFetchMode
(
$this
->
defaultFetchMode
);
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
...
...
src/DBALException.php
View file @
7336ae0a
...
@@ -11,6 +11,7 @@ use Exception;
...
@@ -11,6 +11,7 @@ use Exception;
use
Throwable
;
use
Throwable
;
use
function
array_map
;
use
function
array_map
;
use
function
bin2hex
;
use
function
bin2hex
;
use
function
count
;
use
function
get_class
;
use
function
get_class
;
use
function
gettype
;
use
function
gettype
;
use
function
implode
;
use
function
implode
;
...
@@ -103,7 +104,7 @@ class DBALException extends Exception
...
@@ -103,7 +104,7 @@ class DBALException extends Exception
*/
*/
public
static
function
driverRequired
(
$url
=
null
)
public
static
function
driverRequired
(
$url
=
null
)
{
{
if
(
$url
)
{
if
(
$url
!==
null
)
{
return
new
self
(
return
new
self
(
sprintf
(
sprintf
(
"The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme "
.
"The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme "
.
...
@@ -138,7 +139,7 @@ class DBALException extends Exception
...
@@ -138,7 +139,7 @@ class DBALException extends Exception
public
static
function
driverExceptionDuringQuery
(
Driver
$driver
,
Throwable
$driverEx
,
$sql
,
array
$params
=
[])
public
static
function
driverExceptionDuringQuery
(
Driver
$driver
,
Throwable
$driverEx
,
$sql
,
array
$params
=
[])
{
{
$msg
=
"An exception occurred while executing '"
.
$sql
.
"'"
;
$msg
=
"An exception occurred while executing '"
.
$sql
.
"'"
;
if
(
$params
)
{
if
(
count
(
$params
)
>
0
)
{
$msg
.=
' with params '
.
self
::
formatParameters
(
$params
);
$msg
.=
' with params '
.
self
::
formatParameters
(
$params
);
}
}
$msg
.=
":
\n\n
"
.
$driverEx
->
getMessage
();
$msg
.=
":
\n\n
"
.
$driverEx
->
getMessage
();
...
...
src/Driver/AbstractMySQLDriver.php
View file @
7336ae0a
...
@@ -140,11 +140,11 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
...
@@ -140,11 +140,11 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
*/
*/
private
function
getOracleMysqlVersionNumber
(
string
$versionString
)
:
string
private
function
getOracleMysqlVersionNumber
(
string
$versionString
)
:
string
{
{
if
(
!
preg_match
(
if
(
preg_match
(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/'
,
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/'
,
$versionString
,
$versionString
,
$versionParts
$versionParts
))
{
)
===
0
)
{
throw
DBALException
::
invalidPlatformVersionSpecified
(
throw
DBALException
::
invalidPlatformVersionSpecified
(
$versionString
,
$versionString
,
'<major_version>.<minor_version>.<patch_version>'
'<major_version>.<minor_version>.<patch_version>'
...
@@ -171,11 +171,11 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
...
@@ -171,11 +171,11 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
*/
*/
private
function
getMariaDbMysqlVersionNumber
(
string
$versionString
)
:
string
private
function
getMariaDbMysqlVersionNumber
(
string
$versionString
)
:
string
{
{
if
(
!
preg_match
(
if
(
preg_match
(
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i'
,
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i'
,
$versionString
,
$versionString
,
$versionParts
$versionParts
))
{
)
===
0
)
{
throw
DBALException
::
invalidPlatformVersionSpecified
(
throw
DBALException
::
invalidPlatformVersionSpecified
(
$versionString
,
$versionString
,
'^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'
'^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'
...
...
src/Driver/AbstractPostgreSQLDriver.php
View file @
7336ae0a
...
@@ -80,7 +80,7 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
...
@@ -80,7 +80,7 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
*/
*/
public
function
createDatabasePlatformForVersion
(
$version
)
public
function
createDatabasePlatformForVersion
(
$version
)
{
{
if
(
!
preg_match
(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/'
,
$version
,
$versionParts
)
)
{
if
(
preg_match
(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/'
,
$version
,
$versionParts
)
===
0
)
{
throw
DBALException
::
invalidPlatformVersionSpecified
(
throw
DBALException
::
invalidPlatformVersionSpecified
(
$version
,
$version
,
'<major_version>.<minor_version>.<patch_version>'
'<major_version>.<minor_version>.<patch_version>'
...
...
src/Driver/AbstractSQLAnywhereDriver.php
View file @
7336ae0a
...
@@ -65,11 +65,11 @@ abstract class AbstractSQLAnywhereDriver implements ExceptionConverterDriver, Ve
...
@@ -65,11 +65,11 @@ abstract class AbstractSQLAnywhereDriver implements ExceptionConverterDriver, Ve
*/
*/
public
function
createDatabasePlatformForVersion
(
$version
)
public
function
createDatabasePlatformForVersion
(
$version
)
{
{
if
(
!
preg_match
(
if
(
preg_match
(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/'
,
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/'
,
$version
,
$version
,
$versionParts
$versionParts
))
{
)
===
0
)
{
throw
DBALException
::
invalidPlatformVersionSpecified
(
throw
DBALException
::
invalidPlatformVersionSpecified
(
$version
,
$version
,
'<major_version>.<minor_version>.<patch_version>.<build_version>'
'<major_version>.<minor_version>.<patch_version>.<build_version>'
...
...
src/Driver/IBMDB2/DB2Connection.php
View file @
7336ae0a
...
@@ -81,7 +81,7 @@ class DB2Connection implements ServerInfoAwareConnection
...
@@ -81,7 +81,7 @@ class DB2Connection implements ServerInfoAwareConnection
public
function
prepare
(
string
$sql
)
:
DriverStatement
public
function
prepare
(
string
$sql
)
:
DriverStatement
{
{
$stmt
=
@
db2_prepare
(
$this
->
conn
,
$sql
);
$stmt
=
@
db2_prepare
(
$this
->
conn
,
$sql
);
if
(
!
$stmt
)
{
if
(
$stmt
===
false
)
{
throw
new
DB2Exception
(
db2_stmt_errormsg
());
throw
new
DB2Exception
(
db2_stmt_errormsg
());
}
}
...
...
src/Driver/OCI8/OCI8Connection.php
View file @
7336ae0a
...
@@ -80,7 +80,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
...
@@ -80,7 +80,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
throw
OCI8Exception
::
fromErrorInfo
(
oci_error
(
$this
->
dbh
));
throw
OCI8Exception
::
fromErrorInfo
(
oci_error
(
$this
->
dbh
));
}
}
if
(
!
preg_match
(
'/\s+(\d+\.\d+\.\d+\.\d+\.\d+)\s+/'
,
$version
,
$matches
)
)
{
if
(
preg_match
(
'/\s+(\d+\.\d+\.\d+\.\d+\.\d+)\s+/'
,
$version
,
$matches
)
===
0
)
{
throw
new
UnexpectedValueException
(
throw
new
UnexpectedValueException
(
sprintf
(
sprintf
(
'Unexpected database version string "%s". Cannot parse an appropriate version number from it. '
.
'Unexpected database version string "%s". Cannot parse an appropriate version number from it. '
.
...
...
src/Driver/OCI8/OCI8Statement.php
View file @
7336ae0a
...
@@ -191,7 +191,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -191,7 +191,7 @@ class OCI8Statement implements IteratorAggregate, Statement
)
{
)
{
$token
=
self
::
findToken
(
$statement
,
$tokenOffset
,
'/[?\'"]/'
);
$token
=
self
::
findToken
(
$statement
,
$tokenOffset
,
'/[?\'"]/'
);
if
(
!
$token
)
{
if
(
$token
===
null
)
{
return
false
;
return
false
;
}
}
...
@@ -233,7 +233,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -233,7 +233,7 @@ class OCI8Statement implements IteratorAggregate, Statement
'/'
.
preg_quote
(
$currentLiteralDelimiter
,
'/'
)
.
'/'
'/'
.
preg_quote
(
$currentLiteralDelimiter
,
'/'
)
.
'/'
);
);
if
(
!
$token
)
{
if
(
$token
===
null
)
{
return
false
;
return
false
;
}
}
...
@@ -255,7 +255,7 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -255,7 +255,7 @@ class OCI8Statement implements IteratorAggregate, Statement
*/
*/
private
static
function
findToken
(
$statement
,
&
$offset
,
$regex
)
private
static
function
findToken
(
$statement
,
&
$offset
,
$regex
)
{
{
if
(
preg_match
(
$regex
,
$statement
,
$matches
,
PREG_OFFSET_CAPTURE
,
$offset
))
{
if
(
preg_match
(
$regex
,
$statement
,
$matches
,
PREG_OFFSET_CAPTURE
,
$offset
)
===
1
)
{
$offset
=
$matches
[
0
][
1
];
$offset
=
$matches
[
0
][
1
];
return
$matches
[
0
][
0
];
return
$matches
[
0
][
0
];
...
@@ -387,9 +387,8 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -387,9 +387,8 @@ class OCI8Statement implements IteratorAggregate, Statement
*/
*/
public
function
execute
(
$params
=
null
)
public
function
execute
(
$params
=
null
)
{
{
if
(
$params
)
{
if
(
$params
!==
null
)
{
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
foreach
(
$params
as
$key
=>
$val
)
{
foreach
(
$params
as
$key
=>
$val
)
{
if
(
$hasZeroIndex
&&
is_int
(
$key
))
{
if
(
$hasZeroIndex
&&
is_int
(
$key
))
{
$this
->
bindValue
(
$key
+
1
,
$val
);
$this
->
bindValue
(
$key
+
1
,
$val
);
...
...
src/Driver/SQLAnywhere/SQLAnywhereException.php
View file @
7336ae0a
...
@@ -27,14 +27,14 @@ class SQLAnywhereException extends AbstractDriverException
...
@@ -27,14 +27,14 @@ class SQLAnywhereException extends AbstractDriverException
*/
*/
public
static
function
fromSQLAnywhereError
(
$conn
=
null
,
$stmt
=
null
)
public
static
function
fromSQLAnywhereError
(
$conn
=
null
,
$stmt
=
null
)
{
{
$state
=
$conn
?
sasql_sqlstate
(
$conn
)
:
sasql_sqlstate
();
$state
=
$conn
!==
null
?
sasql_sqlstate
(
$conn
)
:
sasql_sqlstate
();
$code
=
null
;
$code
=
0
;
$message
=
null
;
$message
=
null
;
/**
/**
* Try retrieving the last error from statement resource if given
* Try retrieving the last error from statement resource if given
*/
*/
if
(
$stmt
)
{
if
(
$stmt
!==
null
)
{
$code
=
sasql_stmt_errno
(
$stmt
);
$code
=
sasql_stmt_errno
(
$stmt
);
$message
=
sasql_stmt_error
(
$stmt
);
$message
=
sasql_stmt_error
(
$stmt
);
}
}
...
@@ -47,7 +47,7 @@ class SQLAnywhereException extends AbstractDriverException
...
@@ -47,7 +47,7 @@ class SQLAnywhereException extends AbstractDriverException
* it from the connection resource even though it occurred during
* it from the connection resource even though it occurred during
* a prepared statement.
* a prepared statement.
*/
*/
if
(
$conn
&&
!
$code
)
{
if
(
$conn
!==
null
&&
$code
===
0
)
{
$code
=
sasql_errorcode
(
$conn
);
$code
=
sasql_errorcode
(
$conn
);
$message
=
sasql_error
(
$conn
);
$message
=
sasql_error
(
$conn
);
}
}
...
@@ -57,7 +57,7 @@ class SQLAnywhereException extends AbstractDriverException
...
@@ -57,7 +57,7 @@ class SQLAnywhereException extends AbstractDriverException
* or the last error could not be retrieved from the given
* or the last error could not be retrieved from the given
* connection / statement resource.
* connection / statement resource.
*/
*/
if
(
!
$conn
||
!
$code
)
{
if
(
$conn
===
null
||
$code
===
0
)
{
$code
=
sasql_errorcode
();
$code
=
sasql_errorcode
();
$message
=
sasql_error
();
$message
=
sasql_error
();
}
}
...
...
src/Driver/SQLAnywhere/SQLAnywhereStatement.php
View file @
7336ae0a
...
@@ -14,7 +14,6 @@ use const SASQL_BOTH;
...
@@ -14,7 +14,6 @@ use const SASQL_BOTH;
use
function
array_key_exists
;
use
function
array_key_exists
;
use
function
count
;
use
function
count
;
use
function
gettype
;
use
function
gettype
;
use
function
is_array
;
use
function
is_int
;
use
function
is_int
;
use
function
is_object
;
use
function
is_object
;
use
function
is_resource
;
use
function
is_resource
;
...
@@ -171,7 +170,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -171,7 +170,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
*/
public
function
execute
(
$params
=
null
)
public
function
execute
(
$params
=
null
)
{
{
if
(
is_array
(
$params
)
)
{
if
(
$params
!==
null
)
{
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
foreach
(
$params
as
$key
=>
$val
)
{
foreach
(
$params
as
$key
=>
$val
)
{
...
...
src/Driver/SQLSrv/SQLSrvConnection.php
View file @
7336ae0a
...
@@ -184,7 +184,7 @@ class SQLSrvConnection implements ServerInfoAwareConnection
...
@@ -184,7 +184,7 @@ class SQLSrvConnection implements ServerInfoAwareConnection
public
function
errorCode
()
public
function
errorCode
()
{
{
$errors
=
sqlsrv_errors
(
SQLSRV_ERR_ERRORS
);
$errors
=
sqlsrv_errors
(
SQLSRV_ERR_ERRORS
);
if
(
$errors
)
{
if
(
$errors
!==
null
)
{
return
$errors
[
0
][
'code'
];
return
$errors
[
0
][
'code'
];
}
}
...
...
src/Driver/SQLSrv/SQLSrvException.php
View file @
7336ae0a
...
@@ -34,7 +34,7 @@ class SQLSrvException extends AbstractDriverException
...
@@ -34,7 +34,7 @@ class SQLSrvException extends AbstractDriverException
$errorCode
=
$error
[
'code'
];
$errorCode
=
$error
[
'code'
];
}
}
if
(
!
$message
)
{
if
(
$message
===
''
)
{
$message
=
'SQL Server error occurred but no error message was retrieved from driver.'
;
$message
=
'SQL Server error occurred but no error message was retrieved from driver.'
;
}
}
...
...
src/Driver/SQLSrv/SQLSrvStatement.php
View file @
7336ae0a
...
@@ -224,7 +224,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -224,7 +224,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
public
function
errorCode
()
public
function
errorCode
()
{
{
$errors
=
sqlsrv_errors
(
SQLSRV_ERR_ERRORS
);
$errors
=
sqlsrv_errors
(
SQLSRV_ERR_ERRORS
);
if
(
$errors
)
{
if
(
$errors
!==
null
)
{
return
$errors
[
0
][
'code'
];
return
$errors
[
0
][
'code'
];
}
}
...
@@ -244,9 +244,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -244,9 +244,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*/
*/
public
function
execute
(
$params
=
null
)
public
function
execute
(
$params
=
null
)
{
{
if
(
$params
)
{
if
(
$params
!==
null
)
{
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
$hasZeroIndex
=
array_key_exists
(
0
,
$params
);
foreach
(
$params
as
$key
=>
$val
)
{
foreach
(
$params
as
$key
=>
$val
)
{
if
(
$hasZeroIndex
&&
is_int
(
$key
))
{
if
(
$hasZeroIndex
&&
is_int
(
$key
))
{
$this
->
bindValue
(
$key
+
1
,
$val
);
$this
->
bindValue
(
$key
+
1
,
$val
);
...
@@ -256,7 +255,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -256,7 +255,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
}
}
}
}
if
(
!
$this
->
stmt
)
{
if
(
$this
->
stmt
===
null
)
{
$this
->
stmt
=
$this
->
prepare
();
$this
->
stmt
=
$this
->
prepare
();
}
}
...
@@ -264,7 +263,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -264,7 +263,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
throw
SQLSrvException
::
fromSqlSrvErrors
();
throw
SQLSrvException
::
fromSqlSrvErrors
();
}
}
if
(
$this
->
lastInsertId
)
{
if
(
$this
->
lastInsertId
!==
null
)
{
sqlsrv_next_result
(
$this
->
stmt
);
sqlsrv_next_result
(
$this
->
stmt
);
sqlsrv_fetch
(
$this
->
stmt
);
sqlsrv_fetch
(
$this
->
stmt
);
$this
->
lastInsertId
->
setId
(
sqlsrv_get_field
(
$this
->
stmt
,
0
));
$this
->
lastInsertId
->
setId
(
sqlsrv_get_field
(
$this
->
stmt
,
0
));
...
@@ -313,7 +312,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -313,7 +312,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
$stmt
=
sqlsrv_prepare
(
$this
->
conn
,
$this
->
sql
,
$params
);
$stmt
=
sqlsrv_prepare
(
$this
->
conn
,
$this
->
sql
,
$params
);
if
(
!
$stmt
)
{
if
(
$stmt
===
false
)
{
throw
SQLSrvException
::
fromSqlSrvErrors
();
throw
SQLSrvException
::
fromSqlSrvErrors
();
}
}
...
...
src/DriverManager.php
View file @
7336ae0a
...
@@ -124,10 +124,10 @@ final class DriverManager
...
@@ -124,10 +124,10 @@ final class DriverManager
?
EventManager
$eventManager
=
null
?
EventManager
$eventManager
=
null
)
:
Connection
{
)
:
Connection
{
// create default config and event manager, if not set
// create default config and event manager, if not set
if
(
!
$config
)
{
if
(
$config
===
null
)
{
$config
=
new
Configuration
();
$config
=
new
Configuration
();
}
}
if
(
!
$eventManager
)
{
if
(
$eventManager
===
null
)
{
$eventManager
=
new
EventManager
();
$eventManager
=
new
EventManager
();
}
}
...
...
src/Event/Listeners/MysqlSessionInit.php
View file @
7336ae0a
...
@@ -44,8 +44,13 @@ class MysqlSessionInit implements EventSubscriber
...
@@ -44,8 +44,13 @@ class MysqlSessionInit implements EventSubscriber
*/
*/
public
function
postConnect
(
ConnectionEventArgs
$args
)
public
function
postConnect
(
ConnectionEventArgs
$args
)
{
{
$collation
=
$this
->
collation
?
' COLLATE '
.
$this
->
collation
:
''
;
$statement
=
'SET NAMES '
.
$this
->
charset
;
$args
->
getConnection
()
->
executeUpdate
(
'SET NAMES '
.
$this
->
charset
.
$collation
);
if
(
$this
->
collation
!==
false
)
{
$statement
.=
' COLLATE '
.
$this
->
collation
;
}
$args
->
getConnection
()
->
executeUpdate
(
$statement
);
}
}
/**
/**
...
...
src/Event/Listeners/OracleSessionInit.php
View file @
7336ae0a
...
@@ -45,7 +45,7 @@ class OracleSessionInit implements EventSubscriber
...
@@ -45,7 +45,7 @@ class OracleSessionInit implements EventSubscriber
*/
*/
public
function
postConnect
(
ConnectionEventArgs
$args
)
public
function
postConnect
(
ConnectionEventArgs
$args
)
{
{
if
(
!
count
(
$this
->
_defaultSessionVars
)
)
{
if
(
count
(
$this
->
_defaultSessionVars
)
===
0
)
{
return
;
return
;
}
}
...
...
src/Platforms/AbstractPlatform.php
View file @
7336ae0a
...
@@ -814,7 +814,7 @@ abstract class AbstractPlatform
...
@@ -814,7 +814,7 @@ abstract class AbstractPlatform
$expression
.=
$char
.
' '
;
$expression
.=
$char
.
' '
;
}
}
if
(
$mode
||
$char
!==
false
)
{
if
(
$mode
!==
TrimMode
::
UNSPECIFIED
||
$char
!==
false
)
{
$expression
.=
'FROM '
;
$expression
.=
'FROM '
;
}
}
...
@@ -2247,19 +2247,18 @@ abstract class AbstractPlatform
...
@@ -2247,19 +2247,18 @@ abstract class AbstractPlatform
}
else
{
}
else
{
$default
=
$this
->
getDefaultValueDeclarationSQL
(
$field
);
$default
=
$this
->
getDefaultValueDeclarationSQL
(
$field
);
$charset
=
isset
(
$field
[
'charset'
])
&&
$field
[
'charset'
]
?
$charset
=
!
empty
(
$field
[
'charset'
])
?
' '
.
$this
->
getColumnCharsetDeclarationSQL
(
$field
[
'charset'
])
:
''
;
' '
.
$this
->
getColumnCharsetDeclarationSQL
(
$field
[
'charset'
])
:
''
;
$collation
=
isset
(
$field
[
'collation'
])
&&
$field
[
'collation'
]
?
$collation
=
!
empty
(
$field
[
'collation'
])
?
' '
.
$this
->
getColumnCollationDeclarationSQL
(
$field
[
'collation'
])
:
''
;
' '
.
$this
->
getColumnCollationDeclarationSQL
(
$field
[
'collation'
])
:
''
;
$notnull
=
isset
(
$field
[
'notnull'
])
&&
$field
[
'notnull'
]
?
' NOT NULL'
:
''
;
$notnull
=
!
empty
(
$field
[
'notnull'
])
?
' NOT NULL'
:
''
;
$unique
=
isset
(
$field
[
'unique'
])
&&
$field
[
'unique'
]
?
$unique
=
!
empty
(
$field
[
'unique'
])
?
' '
.
$this
->
getUniqueFieldDeclarationSQL
()
:
''
;
' '
.
$this
->
getUniqueFieldDeclarationSQL
()
:
''
;
$check
=
isset
(
$field
[
'check'
])
&&
$field
[
'check'
]
?
$check
=
!
empty
(
$field
[
'check'
])
?
' '
.
$field
[
'check'
]
:
''
;
' '
.
$field
[
'check'
]
:
''
;
$typeDecl
=
$field
[
'type'
]
->
getSQLDeclaration
(
$field
,
$this
);
$typeDecl
=
$field
[
'type'
]
->
getSQLDeclaration
(
$field
,
$this
);
$columnDef
=
$typeDecl
.
$charset
.
$default
.
$notnull
.
$unique
.
$check
.
$collation
;
$columnDef
=
$typeDecl
.
$charset
.
$default
.
$notnull
.
$unique
.
$check
.
$collation
;
...
@@ -2557,7 +2556,7 @@ abstract class AbstractPlatform
...
@@ -2557,7 +2556,7 @@ abstract class AbstractPlatform
public
function
getForeignKeyBaseDeclarationSQL
(
ForeignKeyConstraint
$foreignKey
)
public
function
getForeignKeyBaseDeclarationSQL
(
ForeignKeyConstraint
$foreignKey
)
{
{
$sql
=
''
;
$sql
=
''
;
if
(
strlen
(
$foreignKey
->
getName
()))
{
if
(
strlen
(
$foreignKey
->
getName
())
>
0
)
{
$sql
.=
'CONSTRAINT '
.
$foreignKey
->
getQuotedName
(
$this
)
.
' '
;
$sql
.=
'CONSTRAINT '
.
$foreignKey
->
getQuotedName
(
$this
)
.
' '
;
}
}
$sql
.=
'FOREIGN KEY ('
;
$sql
.=
'FOREIGN KEY ('
;
...
@@ -3560,7 +3559,7 @@ abstract class AbstractPlatform
...
@@ -3560,7 +3559,7 @@ abstract class AbstractPlatform
final
public
function
getReservedKeywordsList
()
final
public
function
getReservedKeywordsList
()
{
{
// Check for an existing instantiation of the keywords class.
// Check for an existing instantiation of the keywords class.
if
(
$this
->
_keywords
)
{
if
(
$this
->
_keywords
!==
null
)
{
return
$this
->
_keywords
;
return
$this
->
_keywords
;
}
}
...
...
src/Platforms/DB2Platform.php
View file @
7336ae0a
...
@@ -111,8 +111,8 @@ class DB2Platform extends AbstractPlatform
...
@@ -111,8 +111,8 @@ class DB2Platform extends AbstractPlatform
*/
*/
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
{
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(254)'
)
return
$fixed
?
(
$length
>
0
?
'CHAR('
.
$length
.
')'
:
'CHAR(254)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
:
(
$length
>
0
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
}
}
/**
/**
...
@@ -664,7 +664,7 @@ class DB2Platform extends AbstractPlatform
...
@@ -664,7 +664,7 @@ class DB2Platform extends AbstractPlatform
$alterClause
=
'ALTER COLUMN '
.
$columnDiff
->
column
->
getQuotedName
(
$this
);
$alterClause
=
'ALTER COLUMN '
.
$columnDiff
->
column
->
getQuotedName
(
$this
);
if
(
$column
[
'columnDefinition'
])
{
if
(
$column
[
'columnDefinition'
]
!==
null
)
{
return
[
$alterClause
.
' '
.
$column
[
'columnDefinition'
]];
return
[
$alterClause
.
' '
.
$column
[
'columnDefinition'
]];
}
}
...
@@ -687,7 +687,7 @@ class DB2Platform extends AbstractPlatform
...
@@ -687,7 +687,7 @@ class DB2Platform extends AbstractPlatform
if
(
isset
(
$column
[
'default'
]))
{
if
(
isset
(
$column
[
'default'
]))
{
$defaultClause
=
$this
->
getDefaultValueDeclarationSQL
(
$column
);
$defaultClause
=
$this
->
getDefaultValueDeclarationSQL
(
$column
);
if
(
$defaultClause
)
{
if
(
$defaultClause
!==
''
)
{
$clauses
[]
=
$alterClause
.
' SET'
.
$defaultClause
;
$clauses
[]
=
$alterClause
.
' SET'
.
$defaultClause
;
}
}
}
else
{
}
else
{
...
@@ -753,7 +753,7 @@ class DB2Platform extends AbstractPlatform
...
@@ -753,7 +753,7 @@ class DB2Platform extends AbstractPlatform
return
''
;
return
''
;
}
}
if
(
isset
(
$field
[
'version'
])
&&
$field
[
'version'
]
)
{
if
(
!
empty
(
$field
[
'version'
])
)
{
if
((
string
)
$field
[
'type'
]
!==
'DateTime'
)
{
if
((
string
)
$field
[
'type'
]
!==
'DateTime'
)
{
$field
[
'default'
]
=
'1'
;
$field
[
'default'
]
=
'1'
;
}
}
...
...
src/Platforms/Keywords/ReservedKeywordsValidator.php
View file @
7336ae0a
...
@@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Schema;
...
@@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Schema;
use
Doctrine\DBAL\Schema\Sequence
;
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
;
use
function
count
;
use
function
implode
;
use
function
implode
;
use
function
str_replace
;
use
function
str_replace
;
...
@@ -67,7 +68,7 @@ class ReservedKeywordsValidator implements Visitor
...
@@ -67,7 +68,7 @@ class ReservedKeywordsValidator implements Visitor
*/
*/
private
function
addViolation
(
$asset
,
$violatedPlatforms
)
private
function
addViolation
(
$asset
,
$violatedPlatforms
)
{
{
if
(
!
$violatedPlatforms
)
{
if
(
count
(
$violatedPlatforms
)
===
0
)
{
return
;
return
;
}
}
...
...
src/Platforms/MySqlPlatform.php
View file @
7336ae0a
...
@@ -150,7 +150,7 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -150,7 +150,7 @@ class MySqlPlatform extends AbstractPlatform
*/
*/
public
function
getListTableIndexesSQL
(
$table
,
$currentDatabase
=
null
)
public
function
getListTableIndexesSQL
(
$table
,
$currentDatabase
=
null
)
{
{
if
(
$currentDatabase
)
{
if
(
$currentDatabase
!==
null
)
{
$currentDatabase
=
$this
->
quoteStringLiteral
(
$currentDatabase
);
$currentDatabase
=
$this
->
quoteStringLiteral
(
$currentDatabase
);
$table
=
$this
->
quoteStringLiteral
(
$table
);
$table
=
$this
->
quoteStringLiteral
(
$table
);
...
@@ -224,8 +224,8 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -224,8 +224,8 @@ class MySqlPlatform extends AbstractPlatform
*/
*/
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
{
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
return
$fixed
?
(
$length
>
0
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
:
(
$length
>
0
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
}
}
/**
/**
...
@@ -372,7 +372,7 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -372,7 +372,7 @@ class MySqlPlatform extends AbstractPlatform
{
{
$table
=
$this
->
quoteStringLiteral
(
$table
);
$table
=
$this
->
quoteStringLiteral
(
$table
);
if
(
$database
)
{
if
(
$database
!==
null
)
{
$database
=
$this
->
quoteStringLiteral
(
$database
);
$database
=
$this
->
quoteStringLiteral
(
$database
);
}
else
{
}
else
{
$database
=
'DATABASE()'
;
$database
=
'DATABASE()'
;
...
@@ -394,7 +394,7 @@ FROM information_schema.TABLES
...
@@ -394,7 +394,7 @@ FROM information_schema.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = %s AND TABLE_NAME = %s
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = %s AND TABLE_NAME = %s
SQL
SQL
,
,
$database
?
$this
->
quoteStringLiteral
(
$database
)
:
'DATABASE()'
,
$database
!==
null
?
$this
->
quoteStringLiteral
(
$database
)
:
'DATABASE()'
,
$this
->
quoteStringLiteral
(
$table
)
$this
->
quoteStringLiteral
(
$table
)
);
);
}
}
...
...
src/Platforms/OraclePlatform.php
View file @
7336ae0a
...
@@ -43,7 +43,7 @@ class OraclePlatform extends AbstractPlatform
...
@@ -43,7 +43,7 @@ class OraclePlatform extends AbstractPlatform
*/
*/
public
static
function
assertValidIdentifier
(
$identifier
)
public
static
function
assertValidIdentifier
(
$identifier
)
{
{
if
(
!
preg_match
(
'(^(([a-zA-Z]{1}[a-zA-Z0-9_$#]{0,})|("[^"]+"))$)'
,
$identifier
)
)
{
if
(
preg_match
(
'(^(([a-zA-Z]{1}[a-zA-Z0-9_$#]{0,})|("[^"]+"))$)'
,
$identifier
)
===
0
)
{
throw
new
DBALException
(
'Invalid Oracle identifier'
);
throw
new
DBALException
(
'Invalid Oracle identifier'
);
}
}
}
}
...
@@ -329,8 +329,8 @@ class OraclePlatform extends AbstractPlatform
...
@@ -329,8 +329,8 @@ class OraclePlatform extends AbstractPlatform
*/
*/
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
{
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(2000)'
)
return
$fixed
?
(
$length
>
0
?
'CHAR('
.
$length
.
')'
:
'CHAR(2000)'
)
:
(
$length
?
'VARCHAR2('
.
$length
.
')'
:
'VARCHAR2(4000)'
);
:
(
$length
>
0
?
'VARCHAR2('
.
$length
.
')'
:
'VARCHAR2(4000)'
);
}
}
/**
/**
...
@@ -725,13 +725,17 @@ SQL
...
@@ -725,13 +725,17 @@ SQL
*/
*/
public
function
getAdvancedForeignKeyOptionsSQL
(
ForeignKeyConstraint
$foreignKey
)
public
function
getAdvancedForeignKeyOptionsSQL
(
ForeignKeyConstraint
$foreignKey
)
{
{
$referentialAction
=
null
;
$referentialAction
=
''
;
if
(
$foreignKey
->
hasOption
(
'onDelete'
))
{
if
(
$foreignKey
->
hasOption
(
'onDelete'
))
{
$referentialAction
=
$this
->
getForeignKeyReferentialActionSQL
(
$foreignKey
->
getOption
(
'onDelete'
));
$referentialAction
=
$this
->
getForeignKeyReferentialActionSQL
(
$foreignKey
->
getOption
(
'onDelete'
));
}
}
return
$referentialAction
?
' ON DELETE '
.
$referentialAction
:
''
;
if
(
$referentialAction
!==
''
)
{
return
' ON DELETE '
.
$referentialAction
;
}
return
''
;
}
}
/**
/**
...
@@ -785,7 +789,7 @@ SQL
...
@@ -785,7 +789,7 @@ SQL
$fields
[]
=
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
$fields
[]
=
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
$comment
=
$this
->
getColumnComment
(
$column
);
$comment
=
$this
->
getColumnComment
(
$column
);
if
(
!
$comment
)
{
if
(
$comment
===
null
||
$comment
===
''
)
{
continue
;
continue
;
}
}
...
@@ -796,7 +800,7 @@ SQL
...
@@ -796,7 +800,7 @@ SQL
);
);
}
}
if
(
count
(
$fields
))
{
if
(
count
(
$fields
)
>
0
)
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
getName
(
$this
)
->
getQuotedName
(
$this
)
.
' ADD ('
.
implode
(
', '
,
$fields
)
.
')'
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
getName
(
$this
)
->
getQuotedName
(
$this
)
.
' ADD ('
.
implode
(
', '
,
$fields
)
.
')'
;
}
}
...
@@ -844,7 +848,7 @@ SQL
...
@@ -844,7 +848,7 @@ SQL
);
);
}
}
if
(
count
(
$fields
))
{
if
(
count
(
$fields
)
>
0
)
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
getName
(
$this
)
->
getQuotedName
(
$this
)
.
' MODIFY ('
.
implode
(
', '
,
$fields
)
.
')'
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
getName
(
$this
)
->
getQuotedName
(
$this
)
.
' MODIFY ('
.
implode
(
', '
,
$fields
)
.
')'
;
}
}
...
@@ -868,7 +872,7 @@ SQL
...
@@ -868,7 +872,7 @@ SQL
$fields
[]
=
$column
->
getQuotedName
(
$this
);
$fields
[]
=
$column
->
getQuotedName
(
$this
);
}
}
if
(
count
(
$fields
))
{
if
(
count
(
$fields
)
>
0
)
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
getName
(
$this
)
->
getQuotedName
(
$this
)
.
' DROP ('
.
implode
(
', '
,
$fields
)
.
')'
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
getName
(
$this
)
->
getQuotedName
(
$this
)
.
' DROP ('
.
implode
(
', '
,
$fields
)
.
')'
;
}
}
...
@@ -913,10 +917,10 @@ SQL
...
@@ -913,10 +917,10 @@ SQL
$notnull
=
$field
[
'notnull'
]
?
' NOT NULL'
:
' NULL'
;
$notnull
=
$field
[
'notnull'
]
?
' NOT NULL'
:
' NULL'
;
}
}
$unique
=
isset
(
$field
[
'unique'
])
&&
$field
[
'unique'
]
?
$unique
=
!
empty
(
$field
[
'unique'
])
?
' '
.
$this
->
getUniqueFieldDeclarationSQL
()
:
''
;
' '
.
$this
->
getUniqueFieldDeclarationSQL
()
:
''
;
$check
=
isset
(
$field
[
'check'
])
&&
$field
[
'check'
]
?
$check
=
!
empty
(
$field
[
'check'
])
?
' '
.
$field
[
'check'
]
:
''
;
' '
.
$field
[
'check'
]
:
''
;
$typeDecl
=
$field
[
'type'
]
->
getSQLDeclaration
(
$field
,
$this
);
$typeDecl
=
$field
[
'type'
]
->
getSQLDeclaration
(
$field
,
$this
);
...
@@ -999,8 +1003,8 @@ SQL
...
@@ -999,8 +1003,8 @@ SQL
return
$query
;
return
$query
;
}
}
if
(
preg_match
(
'/^\s*SELECT/i'
,
$query
))
{
if
(
preg_match
(
'/^\s*SELECT/i'
,
$query
)
===
1
)
{
if
(
!
preg_match
(
'/\sFROM\s/i'
,
$query
)
)
{
if
(
preg_match
(
'/\sFROM\s/i'
,
$query
)
===
0
)
{
$query
.=
' FROM dual'
;
$query
.=
' FROM dual'
;
}
}
...
...
src/Platforms/PostgreSQL94Platform.php
View file @
7336ae0a
...
@@ -662,7 +662,7 @@ SQL
...
@@ -662,7 +662,7 @@ SQL
$fromColumn
=
$columnDiff
->
fromColumn
instanceof
Column
?
$columnDiff
->
fromColumn
:
null
;
$fromColumn
=
$columnDiff
->
fromColumn
instanceof
Column
?
$columnDiff
->
fromColumn
:
null
;
if
(
$fromColumn
)
{
if
(
$fromColumn
!==
null
)
{
$fromColumnType
=
$fromColumn
->
getType
();
$fromColumnType
=
$fromColumn
->
getType
();
if
(
!
$fromColumnType
instanceof
BinaryType
&&
!
$fromColumnType
instanceof
BlobType
)
{
if
(
!
$fromColumnType
instanceof
BinaryType
&&
!
$fromColumnType
instanceof
BlobType
)
{
...
@@ -1047,8 +1047,8 @@ SQL
...
@@ -1047,8 +1047,8 @@ SQL
*/
*/
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
{
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
return
$fixed
?
(
$length
>
0
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
:
(
$length
>
0
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
}
}
/**
/**
...
@@ -1277,7 +1277,7 @@ SQL
...
@@ -1277,7 +1277,7 @@ SQL
*/
*/
private
function
typeChangeBreaksDefaultValue
(
ColumnDiff
$columnDiff
)
:
bool
private
function
typeChangeBreaksDefaultValue
(
ColumnDiff
$columnDiff
)
:
bool
{
{
if
(
!
$columnDiff
->
fromColumn
)
{
if
(
$columnDiff
->
fromColumn
===
null
)
{
return
$columnDiff
->
hasChanged
(
'type'
);
return
$columnDiff
->
hasChanged
(
'type'
);
}
}
...
@@ -1296,7 +1296,7 @@ SQL
...
@@ -1296,7 +1296,7 @@ SQL
private
function
getOldColumnComment
(
ColumnDiff
$columnDiff
)
:
?
string
private
function
getOldColumnComment
(
ColumnDiff
$columnDiff
)
:
?
string
{
{
return
$columnDiff
->
fromColumn
?
$this
->
getColumnComment
(
$columnDiff
->
fromColumn
)
:
null
;
return
$columnDiff
->
fromColumn
!==
null
?
$this
->
getColumnComment
(
$columnDiff
->
fromColumn
)
:
null
;
}
}
public
function
getListTableMetadataSQL
(
string
$table
,
?
string
$schema
=
null
)
:
string
public
function
getListTableMetadataSQL
(
string
$table
,
?
string
$schema
=
null
)
:
string
...
...
src/Platforms/SQLAnywhere16Platform.php
View file @
7336ae0a
...
@@ -1132,7 +1132,7 @@ SQL
...
@@ -1132,7 +1132,7 @@ SQL
*/
*/
public
function
getTrimExpression
(
$str
,
$pos
=
TrimMode
::
UNSPECIFIED
,
$char
=
false
)
public
function
getTrimExpression
(
$str
,
$pos
=
TrimMode
::
UNSPECIFIED
,
$char
=
false
)
{
{
if
(
!
$char
)
{
if
(
$char
===
false
)
{
switch
(
$pos
)
{
switch
(
$pos
)
{
case
TrimMode
::
LEADING
:
case
TrimMode
::
LEADING
:
return
$this
->
getLtrimExpression
(
$str
);
return
$this
->
getLtrimExpression
(
$str
);
...
@@ -1389,7 +1389,7 @@ SQL
...
@@ -1389,7 +1389,7 @@ SQL
return
$query
;
return
$query
;
}
}
if
(
!
preg_match
(
'/^\s*(SELECT\s+(DISTINCT\s+)?)(.*)/i'
,
$query
,
$matches
)
)
{
if
(
preg_match
(
'/^\s*(SELECT\s+(DISTINCT\s+)?)(.*)/i'
,
$query
,
$matches
)
===
0
)
{
return
$query
;
return
$query
;
}
}
...
@@ -1543,8 +1543,8 @@ SQL
...
@@ -1543,8 +1543,8 @@ SQL
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
{
return
$fixed
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR('
.
$this
->
getVarcharDefaultLength
()
.
')'
)
?
(
$length
>
0
?
'CHAR('
.
$length
.
')'
:
'CHAR('
.
$this
->
getVarcharDefaultLength
()
.
')'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR('
.
$this
->
getVarcharDefaultLength
()
.
')'
);
:
(
$length
>
0
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR('
.
$this
->
getVarcharDefaultLength
()
.
')'
);
}
}
/**
/**
...
...
src/Platforms/SQLServer2012Platform.php
View file @
7336ae0a
...
@@ -316,7 +316,7 @@ SQL
...
@@ -316,7 +316,7 @@ SQL
// @todo does other code breaks because of this?
// @todo does other code breaks because of this?
// force primary keys to be not null
// force primary keys to be not null
foreach
(
$columns
as
&
$column
)
{
foreach
(
$columns
as
&
$column
)
{
if
(
isset
(
$column
[
'primary'
])
&&
$column
[
'primary'
]
)
{
if
(
!
empty
(
$column
[
'primary'
])
)
{
$column
[
'notnull'
]
=
true
;
$column
[
'notnull'
]
=
true
;
}
}
...
@@ -1123,7 +1123,7 @@ SQL
...
@@ -1123,7 +1123,7 @@ SQL
*/
*/
public
function
getTrimExpression
(
$str
,
$pos
=
TrimMode
::
UNSPECIFIED
,
$char
=
false
)
public
function
getTrimExpression
(
$str
,
$pos
=
TrimMode
::
UNSPECIFIED
,
$char
=
false
)
{
{
if
(
!
$char
)
{
if
(
$char
===
false
)
{
switch
(
$pos
)
{
switch
(
$pos
)
{
case
TrimMode
::
LEADING
:
case
TrimMode
::
LEADING
:
$trimFn
=
'LTRIM'
;
$trimFn
=
'LTRIM'
;
...
@@ -1261,7 +1261,9 @@ SQL
...
@@ -1261,7 +1261,9 @@ SQL
*/
*/
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
{
return
$fixed
?
(
$length
?
'NCHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'NVARCHAR('
.
$length
.
')'
:
'NVARCHAR(255)'
);
return
$fixed
?
(
$length
>
0
?
'NCHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
>
0
?
'NVARCHAR('
.
$length
.
')'
:
'NVARCHAR(255)'
);
}
}
/**
/**
...
@@ -1352,9 +1354,9 @@ SQL
...
@@ -1352,9 +1354,9 @@ SQL
}
}
if
(
$orderByPos
===
false
if
(
$orderByPos
===
false
||
substr_count
(
$query
,
'('
,
$orderByPos
)
-
substr_count
(
$query
,
')'
,
$orderByPos
)
||
substr_count
(
$query
,
'('
,
$orderByPos
)
!==
substr_count
(
$query
,
')'
,
$orderByPos
)
)
{
)
{
if
(
preg_match
(
'/^SELECT\s+DISTINCT/im'
,
$query
))
{
if
(
preg_match
(
'/^SELECT\s+DISTINCT/im'
,
$query
)
>
0
)
{
// SQL Server won't let us order by a non-selected column in a DISTINCT query,
// SQL Server won't let us order by a non-selected column in a DISTINCT query,
// so we have to do this madness. This says, order by the first column in the
// so we have to do this madness. This says, order by the first column in the
// result. SQL Server's docs say that a nonordered query's result order is non-
// result. SQL Server's docs say that a nonordered query's result order is non-
...
@@ -1399,10 +1401,10 @@ SQL
...
@@ -1399,10 +1401,10 @@ SQL
continue
;
continue
;
}
}
$item
[
$key
]
=
$value
?
1
:
0
;
$item
[
$key
]
=
(
int
)
(
bool
)
$value
;
}
}
}
elseif
(
is_bool
(
$item
)
||
is_numeric
(
$item
))
{
}
elseif
(
is_bool
(
$item
)
||
is_numeric
(
$item
))
{
$item
=
$item
?
1
:
0
;
$item
=
(
int
)
(
bool
)
$item
;
}
}
return
$item
;
return
$item
;
...
@@ -1611,15 +1613,15 @@ SQL
...
@@ -1611,15 +1613,15 @@ SQL
if
(
isset
(
$field
[
'columnDefinition'
]))
{
if
(
isset
(
$field
[
'columnDefinition'
]))
{
$columnDef
=
$this
->
getCustomTypeDeclarationSQL
(
$field
);
$columnDef
=
$this
->
getCustomTypeDeclarationSQL
(
$field
);
}
else
{
}
else
{
$collation
=
isset
(
$field
[
'collation'
])
&&
$field
[
'collation'
]
?
$collation
=
!
empty
(
$field
[
'collation'
])
?
' '
.
$this
->
getColumnCollationDeclarationSQL
(
$field
[
'collation'
])
:
''
;
' '
.
$this
->
getColumnCollationDeclarationSQL
(
$field
[
'collation'
])
:
''
;
$notnull
=
isset
(
$field
[
'notnull'
])
&&
$field
[
'notnull'
]
?
' NOT NULL'
:
''
;
$notnull
=
!
empty
(
$field
[
'notnull'
])
?
' NOT NULL'
:
''
;
$unique
=
isset
(
$field
[
'unique'
])
&&
$field
[
'unique'
]
?
$unique
=
!
empty
(
$field
[
'unique'
])
?
' '
.
$this
->
getUniqueFieldDeclarationSQL
()
:
''
;
' '
.
$this
->
getUniqueFieldDeclarationSQL
()
:
''
;
$check
=
isset
(
$field
[
'check'
])
&&
$field
[
'check'
]
?
$check
=
!
empty
(
$field
[
'check'
])
?
' '
.
$field
[
'check'
]
:
''
;
' '
.
$field
[
'check'
]
:
''
;
$typeDecl
=
$field
[
'type'
]
->
getSQLDeclaration
(
$field
,
$this
);
$typeDecl
=
$field
[
'type'
]
->
getSQLDeclaration
(
$field
,
$this
);
...
...
src/Platforms/SqlitePlatform.php
View file @
7336ae0a
...
@@ -394,8 +394,8 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -394,8 +394,8 @@ class SqlitePlatform extends AbstractPlatform
*/
*/
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
{
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
return
$fixed
?
(
$length
>
0
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
:
(
$length
>
0
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
}
}
/**
/**
...
@@ -1109,7 +1109,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -1109,7 +1109,7 @@ class SqlitePlatform extends AbstractPlatform
foreach
(
$diff
->
removedIndexes
as
$index
)
{
foreach
(
$diff
->
removedIndexes
as
$index
)
{
$indexName
=
strtolower
(
$index
->
getName
());
$indexName
=
strtolower
(
$index
->
getName
());
if
(
!
strlen
(
$indexName
)
||
!
isset
(
$indexes
[
$indexName
]))
{
if
(
strlen
(
$indexName
)
===
0
||
!
isset
(
$indexes
[
$indexName
]))
{
continue
;
continue
;
}
}
...
@@ -1118,7 +1118,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -1118,7 +1118,7 @@ class SqlitePlatform extends AbstractPlatform
foreach
(
array_merge
(
$diff
->
changedIndexes
,
$diff
->
addedIndexes
,
$diff
->
renamedIndexes
)
as
$index
)
{
foreach
(
array_merge
(
$diff
->
changedIndexes
,
$diff
->
addedIndexes
,
$diff
->
renamedIndexes
)
as
$index
)
{
$indexName
=
strtolower
(
$index
->
getName
());
$indexName
=
strtolower
(
$index
->
getName
());
if
(
strlen
(
$indexName
))
{
if
(
strlen
(
$indexName
)
>
0
)
{
$indexes
[
$indexName
]
=
$index
;
$indexes
[
$indexName
]
=
$index
;
}
else
{
}
else
{
$indexes
[]
=
$index
;
$indexes
[]
=
$index
;
...
@@ -1167,7 +1167,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -1167,7 +1167,7 @@ class SqlitePlatform extends AbstractPlatform
}
}
$constraintName
=
strtolower
(
$constraint
->
getName
());
$constraintName
=
strtolower
(
$constraint
->
getName
());
if
(
!
strlen
(
$constraintName
)
||
!
isset
(
$foreignKeys
[
$constraintName
]))
{
if
(
strlen
(
$constraintName
)
===
0
||
!
isset
(
$foreignKeys
[
$constraintName
]))
{
continue
;
continue
;
}
}
...
@@ -1176,7 +1176,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -1176,7 +1176,7 @@ class SqlitePlatform extends AbstractPlatform
foreach
(
array_merge
(
$diff
->
changedForeignKeys
,
$diff
->
addedForeignKeys
)
as
$constraint
)
{
foreach
(
array_merge
(
$diff
->
changedForeignKeys
,
$diff
->
addedForeignKeys
)
as
$constraint
)
{
$constraintName
=
strtolower
(
$constraint
->
getName
());
$constraintName
=
strtolower
(
$constraint
->
getName
());
if
(
strlen
(
$constraintName
))
{
if
(
strlen
(
$constraintName
)
>
0
)
{
$foreignKeys
[
$constraintName
]
=
$constraint
;
$foreignKeys
[
$constraintName
]
=
$constraint
;
}
else
{
}
else
{
$foreignKeys
[]
=
$constraint
;
$foreignKeys
[]
=
$constraint
;
...
...
src/Portability/Connection.php
View file @
7336ae0a
...
@@ -63,7 +63,7 @@ class Connection extends \Doctrine\DBAL\Connection
...
@@ -63,7 +63,7 @@ class Connection extends \Doctrine\DBAL\Connection
$this
->
portability
=
$params
[
'portability'
];
$this
->
portability
=
$params
[
'portability'
];
}
}
if
(
isset
(
$params
[
'fetch_case'
])
&&
$this
->
portability
&
self
::
PORTABILITY_FIX_CASE
)
{
if
(
isset
(
$params
[
'fetch_case'
])
&&
(
$this
->
portability
&
self
::
PORTABILITY_FIX_CASE
)
!==
0
)
{
if
(
$this
->
_conn
instanceof
PDOConnection
)
{
if
(
$this
->
_conn
instanceof
PDOConnection
)
{
// make use of c-level support for case handling
// make use of c-level support for case handling
$this
->
_conn
->
getWrappedConnection
()
->
setAttribute
(
PDO
::
ATTR_CASE
,
$params
[
'fetch_case'
]);
$this
->
_conn
->
getWrappedConnection
()
->
setAttribute
(
PDO
::
ATTR_CASE
,
$params
[
'fetch_case'
]);
...
...
src/Portability/Statement.php
View file @
7336ae0a
...
@@ -135,10 +135,10 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -135,10 +135,10 @@ class Statement implements IteratorAggregate, DriverStatement
$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
)
!==
0
;
$row
=
$this
->
fixRow
(
$row
,
$iterateRow
,
$fixCase
);
$row
=
$this
->
fixRow
(
$row
,
$iterateRow
,
$fixCase
);
...
@@ -154,10 +154,10 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -154,10 +154,10 @@ class Statement implements IteratorAggregate, DriverStatement
$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
)
!==
0
;
if
(
!
$iterateRow
&&
!
$fixCase
)
{
if
(
!
$iterateRow
&&
!
$fixCase
)
{
return
$rows
;
return
$rows
;
...
@@ -184,14 +184,14 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -184,14 +184,14 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* @param mixed $row
* @param mixed $row
* @param
int
$iterateRow
* @param
bool
$iterateRow
* @param bool $fixCase
* @param bool $fixCase
*
*
* @return mixed
* @return mixed
*/
*/
protected
function
fixRow
(
$row
,
$iterateRow
,
$fixCase
)
protected
function
fixRow
(
$row
,
$iterateRow
,
$fixCase
)
{
{
if
(
!
$row
)
{
if
(
$row
===
false
)
{
return
$row
;
return
$row
;
}
}
...
@@ -201,9 +201,9 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -201,9 +201,9 @@ class Statement implements IteratorAggregate, DriverStatement
if
(
$iterateRow
)
{
if
(
$iterateRow
)
{
foreach
(
$row
as
$k
=>
$v
)
{
foreach
(
$row
as
$k
=>
$v
)
{
if
((
$this
->
portability
&
Connection
::
PORTABILITY_EMPTY_TO_NULL
)
&&
$v
===
''
)
{
if
((
$this
->
portability
&
Connection
::
PORTABILITY_EMPTY_TO_NULL
)
!==
0
&&
$v
===
''
)
{
$row
[
$k
]
=
null
;
$row
[
$k
]
=
null
;
}
elseif
((
$this
->
portability
&
Connection
::
PORTABILITY_RTRIM
)
&&
is_string
(
$v
))
{
}
elseif
((
$this
->
portability
&
Connection
::
PORTABILITY_RTRIM
)
!==
0
&&
is_string
(
$v
))
{
$row
[
$k
]
=
rtrim
(
$v
);
$row
[
$k
]
=
rtrim
(
$v
);
}
}
}
}
...
@@ -219,12 +219,10 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -219,12 +219,10 @@ class Statement implements IteratorAggregate, DriverStatement
{
{
$value
=
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
$value
=
$this
->
stmt
->
fetchColumn
(
$columnIndex
);
if
(
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
))
{
if
((
$this
->
portability
&
Connection
::
PORTABILITY_EMPTY_TO_NULL
)
!==
0
&&
$value
===
''
)
{
if
((
$this
->
portability
&
Connection
::
PORTABILITY_EMPTY_TO_NULL
)
&&
$value
===
''
)
{
$value
=
null
;
$value
=
null
;
}
elseif
((
$this
->
portability
&
Connection
::
PORTABILITY_RTRIM
)
!==
0
&&
is_string
(
$value
))
{
}
elseif
((
$this
->
portability
&
Connection
::
PORTABILITY_RTRIM
)
&&
is_string
(
$value
))
{
$value
=
rtrim
(
$value
);
$value
=
rtrim
(
$value
);
}
}
}
return
$value
;
return
$value
;
...
...
src/Query/QueryBuilder.php
View file @
7336ae0a
...
@@ -548,7 +548,7 @@ class QueryBuilder
...
@@ -548,7 +548,7 @@ class QueryBuilder
{
{
$this
->
type
=
self
::
DELETE
;
$this
->
type
=
self
::
DELETE
;
if
(
!
$delete
)
{
if
(
$delete
===
null
)
{
return
$this
;
return
$this
;
}
}
...
@@ -578,7 +578,7 @@ class QueryBuilder
...
@@ -578,7 +578,7 @@ class QueryBuilder
{
{
$this
->
type
=
self
::
UPDATE
;
$this
->
type
=
self
::
UPDATE
;
if
(
!
$update
)
{
if
(
$update
===
null
)
{
return
$this
;
return
$this
;
}
}
...
@@ -611,7 +611,7 @@ class QueryBuilder
...
@@ -611,7 +611,7 @@ class QueryBuilder
{
{
$this
->
type
=
self
::
INSERT
;
$this
->
type
=
self
::
INSERT
;
if
(
!
$insert
)
{
if
(
$insert
===
null
)
{
return
$this
;
return
$this
;
}
}
...
@@ -1053,7 +1053,7 @@ class QueryBuilder
...
@@ -1053,7 +1053,7 @@ class QueryBuilder
*/
*/
public
function
orderBy
(
$sort
,
$order
=
null
)
public
function
orderBy
(
$sort
,
$order
=
null
)
{
{
return
$this
->
add
(
'orderBy'
,
$sort
.
' '
.
(
!
$order
?
'ASC'
:
$order
),
false
);
return
$this
->
add
(
'orderBy'
,
$sort
.
' '
.
(
$order
??
'ASC'
),
false
);
}
}
/**
/**
...
@@ -1066,7 +1066,7 @@ class QueryBuilder
...
@@ -1066,7 +1066,7 @@ class QueryBuilder
*/
*/
public
function
addOrderBy
(
$sort
,
$order
=
null
)
public
function
addOrderBy
(
$sort
,
$order
=
null
)
{
{
return
$this
->
add
(
'orderBy'
,
$sort
.
' '
.
(
!
$order
?
'ASC'
:
$order
),
true
);
return
$this
->
add
(
'orderBy'
,
$sort
.
' '
.
(
$order
??
'ASC'
),
true
);
}
}
/**
/**
...
...
src/SQLParserUtils.php
View file @
7336ae0a
...
@@ -155,7 +155,7 @@ class SQLParserUtils
...
@@ -155,7 +155,7 @@ class SQLParserUtils
$arrayPositions
[
$name
]
=
false
;
$arrayPositions
[
$name
]
=
false
;
}
}
if
(
(
!
$arrayPositions
&&
$isPositional
)
)
{
if
(
$isPositional
&&
count
(
$arrayPositions
)
===
0
)
{
return
[
$query
,
$params
,
$types
];
return
[
$query
,
$params
,
$types
];
}
}
...
@@ -184,7 +184,7 @@ class SQLParserUtils
...
@@ -184,7 +184,7 @@ class SQLParserUtils
$types
=
array_merge
(
$types
=
array_merge
(
array_slice
(
$types
,
0
,
$needle
),
array_slice
(
$types
,
0
,
$needle
),
$count
?
$count
>
0
?
// array needles are at {@link \Doctrine\DBAL\ParameterType} constants
// array needles are at {@link \Doctrine\DBAL\ParameterType} constants
// + {@link Doctrine\DBAL\Connection::ARRAY_PARAM_OFFSET}
// + {@link Doctrine\DBAL\Connection::ARRAY_PARAM_OFFSET}
array_fill
(
0
,
$count
,
$types
[
$needle
]
-
Connection
::
ARRAY_PARAM_OFFSET
)
:
array_fill
(
0
,
$count
,
$types
[
$needle
]
-
Connection
::
ARRAY_PARAM_OFFSET
)
:
...
@@ -192,7 +192,7 @@ class SQLParserUtils
...
@@ -192,7 +192,7 @@ class SQLParserUtils
array_slice
(
$types
,
$needle
+
1
)
array_slice
(
$types
,
$needle
+
1
)
);
);
$expandStr
=
$count
?
implode
(
', '
,
array_fill
(
0
,
$count
,
'?'
))
:
'NULL'
;
$expandStr
=
$count
>
0
?
implode
(
', '
,
array_fill
(
0
,
$count
,
'?'
))
:
'NULL'
;
$query
=
substr
(
$query
,
0
,
$needlePos
)
.
$expandStr
.
substr
(
$query
,
$needlePos
+
1
);
$query
=
substr
(
$query
,
0
,
$needlePos
)
.
$expandStr
.
substr
(
$query
,
$needlePos
+
1
);
$paramOffset
+=
(
$count
-
1
);
// Grows larger by number of parameters minus the replaced needle.
$paramOffset
+=
(
$count
-
1
);
// Grows larger by number of parameters minus the replaced needle.
...
...
src/Schema/AbstractAsset.php
View file @
7336ae0a
...
@@ -114,7 +114,7 @@ abstract class AbstractAsset
...
@@ -114,7 +114,7 @@ abstract class AbstractAsset
public
function
getFullQualifiedName
(
$defaultNamespaceName
)
public
function
getFullQualifiedName
(
$defaultNamespaceName
)
{
{
$name
=
$this
->
getName
();
$name
=
$this
->
getName
();
if
(
!
$this
->
_namespace
)
{
if
(
$this
->
_namespace
===
null
)
{
$name
=
$defaultNamespaceName
.
'.'
.
$name
;
$name
=
$defaultNamespaceName
.
'.'
.
$name
;
}
}
...
@@ -162,7 +162,7 @@ abstract class AbstractAsset
...
@@ -162,7 +162,7 @@ abstract class AbstractAsset
*/
*/
public
function
getName
()
public
function
getName
()
{
{
if
(
$this
->
_namespace
)
{
if
(
$this
->
_namespace
!==
null
)
{
return
$this
->
_namespace
.
'.'
.
$this
->
_name
;
return
$this
->
_namespace
.
'.'
.
$this
->
_name
;
}
}
...
...
src/Schema/AbstractSchemaManager.php
View file @
7336ae0a
...
@@ -155,7 +155,7 @@ abstract class AbstractSchemaManager
...
@@ -155,7 +155,7 @@ abstract class AbstractSchemaManager
*/
*/
public
function
listTableColumns
(
$table
,
$database
=
null
)
public
function
listTableColumns
(
$table
,
$database
=
null
)
{
{
if
(
!
$database
)
{
if
(
$database
===
null
)
{
$database
=
$this
->
_conn
->
getDatabase
();
$database
=
$this
->
_conn
->
getDatabase
();
}
}
...
@@ -226,7 +226,7 @@ abstract class AbstractSchemaManager
...
@@ -226,7 +226,7 @@ abstract class AbstractSchemaManager
protected
function
filterAssetNames
(
$assetNames
)
protected
function
filterAssetNames
(
$assetNames
)
{
{
$filter
=
$this
->
_conn
->
getConfiguration
()
->
getSchemaAssetsFilter
();
$filter
=
$this
->
_conn
->
getConfiguration
()
->
getSchemaAssetsFilter
();
if
(
!
$filter
)
{
if
(
$filter
===
null
)
{
return
$assetNames
;
return
$assetNames
;
}
}
...
@@ -628,13 +628,7 @@ abstract class AbstractSchemaManager
...
@@ -628,13 +628,7 @@ abstract class AbstractSchemaManager
{
{
$list
=
[];
$list
=
[];
foreach
(
$databases
as
$value
)
{
foreach
(
$databases
as
$value
)
{
$value
=
$this
->
_getPortableDatabaseDefinition
(
$value
);
$list
[]
=
$this
->
_getPortableDatabaseDefinition
(
$value
);
if
(
!
$value
)
{
continue
;
}
$list
[]
=
$value
;
}
}
return
$list
;
return
$list
;
...
@@ -806,7 +800,7 @@ abstract class AbstractSchemaManager
...
@@ -806,7 +800,7 @@ abstract class AbstractSchemaManager
$column
=
$this
->
_getPortableTableColumnDefinition
(
$tableColumn
);
$column
=
$this
->
_getPortableTableColumnDefinition
(
$tableColumn
);
}
}
if
(
!
$column
)
{
if
(
$column
===
null
)
{
continue
;
continue
;
}
}
...
@@ -886,7 +880,7 @@ abstract class AbstractSchemaManager
...
@@ -886,7 +880,7 @@ abstract class AbstractSchemaManager
$index
=
new
Index
(
$data
[
'name'
],
$data
[
'columns'
],
$data
[
'unique'
],
$data
[
'primary'
],
$data
[
'flags'
],
$data
[
'options'
]);
$index
=
new
Index
(
$data
[
'name'
],
$data
[
'columns'
],
$data
[
'unique'
],
$data
[
'primary'
],
$data
[
'flags'
],
$data
[
'options'
]);
}
}
if
(
!
$index
)
{
if
(
$index
===
null
)
{
continue
;
continue
;
}
}
...
@@ -905,13 +899,7 @@ abstract class AbstractSchemaManager
...
@@ -905,13 +899,7 @@ abstract class AbstractSchemaManager
{
{
$list
=
[];
$list
=
[];
foreach
(
$tables
as
$value
)
{
foreach
(
$tables
as
$value
)
{
$value
=
$this
->
_getPortableTableDefinition
(
$value
);
$list
[]
=
$this
->
_getPortableTableDefinition
(
$value
);
if
(
!
$value
)
{
continue
;
}
$list
[]
=
$value
;
}
}
return
$list
;
return
$list
;
...
@@ -936,13 +924,7 @@ abstract class AbstractSchemaManager
...
@@ -936,13 +924,7 @@ abstract class AbstractSchemaManager
{
{
$list
=
[];
$list
=
[];
foreach
(
$users
as
$value
)
{
foreach
(
$users
as
$value
)
{
$value
=
$this
->
_getPortableUserDefinition
(
$value
);
$list
[]
=
$this
->
_getPortableUserDefinition
(
$value
);
if
(
!
$value
)
{
continue
;
}
$list
[]
=
$value
;
}
}
return
$list
;
return
$list
;
...
@@ -969,7 +951,7 @@ abstract class AbstractSchemaManager
...
@@ -969,7 +951,7 @@ abstract class AbstractSchemaManager
foreach
(
$views
as
$value
)
{
foreach
(
$views
as
$value
)
{
$view
=
$this
->
_getPortableViewDefinition
(
$value
);
$view
=
$this
->
_getPortableViewDefinition
(
$value
);
if
(
!
$view
)
{
if
(
$view
===
false
)
{
continue
;
continue
;
}
}
...
@@ -1107,7 +1089,7 @@ abstract class AbstractSchemaManager
...
@@ -1107,7 +1089,7 @@ abstract class AbstractSchemaManager
*/
*/
public
function
extractDoctrineTypeFromComment
(
$comment
,
$currentType
)
public
function
extractDoctrineTypeFromComment
(
$comment
,
$currentType
)
{
{
if
(
$comment
!==
null
&&
preg_match
(
'(\(DC2Type:(((?!\)).)+)\))'
,
$comment
,
$match
))
{
if
(
$comment
!==
null
&&
preg_match
(
'(\(DC2Type:(((?!\)).)+)\))'
,
$comment
,
$match
)
===
1
)
{
return
$match
[
1
];
return
$match
[
1
];
}
}
...
...
src/Schema/ColumnDiff.php
View file @
7336ae0a
...
@@ -48,7 +48,7 @@ class ColumnDiff
...
@@ -48,7 +48,7 @@ class ColumnDiff
*/
*/
public
function
getOldColumnName
()
public
function
getOldColumnName
()
{
{
$quote
=
$this
->
fromColumn
&&
$this
->
fromColumn
->
isQuoted
();
$quote
=
$this
->
fromColumn
!==
null
&&
$this
->
fromColumn
->
isQuoted
();
return
new
Identifier
(
$this
->
oldColumnName
,
$quote
);
return
new
Identifier
(
$this
->
oldColumnName
,
$quote
);
}
}
...
...
src/Schema/Comparator.php
View file @
7336ae0a
...
@@ -293,7 +293,7 @@ class Comparator
...
@@ -293,7 +293,7 @@ class Comparator
$changes
++
;
$changes
++
;
}
}
return
$changes
?
$tableDifferences
:
false
;
return
$changes
>
0
?
$tableDifferences
:
false
;
}
}
/**
/**
...
...
src/Schema/DB2SchemaManager.php
View file @
7336ae0a
...
@@ -51,7 +51,7 @@ class DB2SchemaManager extends AbstractSchemaManager
...
@@ -51,7 +51,7 @@ class DB2SchemaManager extends AbstractSchemaManager
if
(
$tableColumn
[
'default'
]
!==
null
&&
$tableColumn
[
'default'
]
!==
'NULL'
)
{
if
(
$tableColumn
[
'default'
]
!==
null
&&
$tableColumn
[
'default'
]
!==
'NULL'
)
{
$default
=
$tableColumn
[
'default'
];
$default
=
$tableColumn
[
'default'
];
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$default
,
$matches
))
{
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$default
,
$matches
)
===
1
)
{
$default
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
$default
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
}
}
}
}
...
...
src/Schema/MySqlSchemaManager.php
View file @
7336ae0a
...
@@ -143,7 +143,11 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -143,7 +143,11 @@ class MySqlSchemaManager extends AbstractSchemaManager
case
'real'
:
case
'real'
:
case
'numeric'
:
case
'numeric'
:
case
'decimal'
:
case
'decimal'
:
if
(
preg_match
(
'([A-Za-z]+\(([0-9]+)\,([0-9]+)\))'
,
$tableColumn
[
'type'
],
$match
))
{
if
(
preg_match
(
'([A-Za-z]+\(([0-9]+),([0-9]+)\))'
,
$tableColumn
[
'type'
],
$match
)
===
1
)
{
$precision
=
$match
[
1
];
$precision
=
$match
[
1
];
$scale
=
$match
[
2
];
$scale
=
$match
[
2
];
$length
=
null
;
$length
=
null
;
...
@@ -237,7 +241,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -237,7 +241,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
return
null
;
return
null
;
}
}
if
(
preg_match
(
'/^\'(.*)\'$/'
,
$columnDefault
,
$matches
))
{
if
(
preg_match
(
'/^\'(.*)\'$/'
,
$columnDefault
,
$matches
)
===
1
)
{
return
strtr
(
$matches
[
1
],
self
::
MARIADB_ESCAPE_SEQUENCES
);
return
strtr
(
$matches
[
1
],
self
::
MARIADB_ESCAPE_SEQUENCES
);
}
}
...
...
src/Schema/OracleSchemaManager.php
View file @
7336ae0a
...
@@ -124,7 +124,7 @@ class OracleSchemaManager extends AbstractSchemaManager
...
@@ -124,7 +124,7 @@ class OracleSchemaManager extends AbstractSchemaManager
$dbType
=
strtolower
(
$tableColumn
[
'data_type'
]);
$dbType
=
strtolower
(
$tableColumn
[
'data_type'
]);
if
(
strpos
(
$dbType
,
'timestamp('
)
===
0
)
{
if
(
strpos
(
$dbType
,
'timestamp('
)
===
0
)
{
if
(
strpos
(
$dbType
,
'with time zone'
))
{
if
(
strpos
(
$dbType
,
'with time zone'
)
!==
false
)
{
$dbType
=
'timestamptz'
;
$dbType
=
'timestamptz'
;
}
else
{
}
else
{
$dbType
=
'timestamp'
;
$dbType
=
'timestamp'
;
...
@@ -146,7 +146,7 @@ class OracleSchemaManager extends AbstractSchemaManager
...
@@ -146,7 +146,7 @@ class OracleSchemaManager extends AbstractSchemaManager
if
(
$tableColumn
[
'data_default'
]
!==
null
)
{
if
(
$tableColumn
[
'data_default'
]
!==
null
)
{
// Default values returned from database are represented as literal expressions
// Default values returned from database are represented as literal expressions
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$tableColumn
[
'data_default'
],
$matches
))
{
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$tableColumn
[
'data_default'
],
$matches
)
===
1
)
{
$tableColumn
[
'data_default'
]
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
$tableColumn
[
'data_default'
]
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
}
}
}
}
...
@@ -345,7 +345,7 @@ class OracleSchemaManager extends AbstractSchemaManager
...
@@ -345,7 +345,7 @@ class OracleSchemaManager extends AbstractSchemaManager
*/
*/
private
function
getQuotedIdentifierName
(
$identifier
)
private
function
getQuotedIdentifierName
(
$identifier
)
{
{
if
(
preg_match
(
'/[a-z]/'
,
$identifier
))
{
if
(
preg_match
(
'/[a-z]/'
,
$identifier
)
===
1
)
{
return
$this
->
_platform
->
quoteIdentifier
(
$identifier
);
return
$this
->
_platform
->
quoteIdentifier
(
$identifier
);
}
}
...
...
src/Schema/PostgreSqlSchemaManager.php
View file @
7336ae0a
...
@@ -138,14 +138,26 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -138,14 +138,26 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$foreignColumns
=
[];
$foreignColumns
=
[];
$foreignTable
=
null
;
$foreignTable
=
null
;
if
(
preg_match
(
'(ON UPDATE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))'
,
$tableForeignKey
[
'condef'
],
$match
))
{
if
(
preg_match
(
'(ON UPDATE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))'
,
$tableForeignKey
[
'condef'
],
$match
)
===
1
)
{
$onUpdate
=
$match
[
1
];
$onUpdate
=
$match
[
1
];
}
}
if
(
preg_match
(
'(ON DELETE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))'
,
$tableForeignKey
[
'condef'
],
$match
))
{
if
(
preg_match
(
'(ON DELETE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))'
,
$tableForeignKey
[
'condef'
],
$match
)
===
1
)
{
$onDelete
=
$match
[
1
];
$onDelete
=
$match
[
1
];
}
}
if
(
preg_match
(
'/FOREIGN KEY \((.+)\) REFERENCES (.+)\((.+)\)/'
,
$tableForeignKey
[
'condef'
],
$values
))
{
if
(
preg_match
(
'/FOREIGN KEY \((.+)\) REFERENCES (.+)\((.+)\)/'
,
$tableForeignKey
[
'condef'
],
$values
)
===
1
)
{
// PostgreSQL returns identifiers that are keywords with quotes, we need them later, don't get
// PostgreSQL returns identifiers that are keywords with quotes, we need them later, don't get
// the idea to trim them here.
// the idea to trim them here.
$localColumns
=
array_map
(
'trim'
,
explode
(
','
,
$values
[
1
]));
$localColumns
=
array_map
(
'trim'
,
explode
(
','
,
$values
[
1
]));
...
@@ -323,15 +335,15 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -323,15 +335,15 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$matches
=
[];
$matches
=
[];
$autoincrement
=
false
;
$autoincrement
=
false
;
if
(
preg_match
(
"/^nextval\('(.*)'(::.*)?\)$/"
,
$tableColumn
[
'default'
],
$matches
))
{
if
(
preg_match
(
"/^nextval\('(.*)'(::.*)?\)$/"
,
$tableColumn
[
'default'
],
$matches
)
===
1
)
{
$tableColumn
[
'sequence'
]
=
$matches
[
1
];
$tableColumn
[
'sequence'
]
=
$matches
[
1
];
$tableColumn
[
'default'
]
=
null
;
$tableColumn
[
'default'
]
=
null
;
$autoincrement
=
true
;
$autoincrement
=
true
;
}
}
if
(
preg_match
(
"/^['(](.*)[')]::/"
,
$tableColumn
[
'default'
],
$matches
))
{
if
(
preg_match
(
"/^['(](.*)[')]::/"
,
$tableColumn
[
'default'
],
$matches
)
===
1
)
{
$tableColumn
[
'default'
]
=
$matches
[
1
];
$tableColumn
[
'default'
]
=
$matches
[
1
];
}
elseif
(
preg_match
(
'/^NULL::/'
,
$tableColumn
[
'default'
]))
{
}
elseif
(
preg_match
(
'/^NULL::/'
,
$tableColumn
[
'default'
])
===
1
)
{
$tableColumn
[
'default'
]
=
null
;
$tableColumn
[
'default'
]
=
null
;
}
}
...
@@ -353,7 +365,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -353,7 +365,8 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$jsonb
=
null
;
$jsonb
=
null
;
$dbType
=
strtolower
(
$tableColumn
[
'type'
]);
$dbType
=
strtolower
(
$tableColumn
[
'type'
]);
if
(
strlen
(
$tableColumn
[
'domain_type'
])
&&
!
$this
->
_platform
->
hasDoctrineTypeMappingFor
(
$tableColumn
[
'type'
]))
{
if
(
strlen
(
$tableColumn
[
'domain_type'
])
>
0
&&
!
$this
->
_platform
->
hasDoctrineTypeMappingFor
(
$tableColumn
[
'type'
]))
{
$dbType
=
strtolower
(
$tableColumn
[
'domain_type'
]);
$dbType
=
strtolower
(
$tableColumn
[
'domain_type'
]);
$tableColumn
[
'complete_type'
]
=
$tableColumn
[
'domain_complete_type'
];
$tableColumn
[
'complete_type'
]
=
$tableColumn
[
'domain_complete_type'
];
}
}
...
@@ -415,7 +428,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -415,7 +428,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
case
'numeric'
:
case
'numeric'
:
$tableColumn
[
'default'
]
=
$this
->
fixVersion94NegativeNumericDefaultValue
(
$tableColumn
[
'default'
]);
$tableColumn
[
'default'
]
=
$this
->
fixVersion94NegativeNumericDefaultValue
(
$tableColumn
[
'default'
]);
if
(
preg_match
(
'([A-Za-z]+\(([0-9]+)\,([0-9]+)\))'
,
$tableColumn
[
'complete_type'
],
$match
))
{
if
(
preg_match
(
'([A-Za-z]+\(([0-9]+)\,([0-9]+)\))'
,
$tableColumn
[
'complete_type'
],
$match
)
===
1
)
{
$precision
=
$match
[
1
];
$precision
=
$match
[
1
];
$scale
=
$match
[
2
];
$scale
=
$match
[
2
];
$length
=
null
;
$length
=
null
;
...
@@ -431,7 +448,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -431,7 +448,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
break
;
break
;
}
}
if
(
$tableColumn
[
'default'
]
&&
preg_match
(
"('([^']+)'::)"
,
$tableColumn
[
'default'
],
$match
))
{
if
(
$tableColumn
[
'default'
]
!==
null
&&
preg_match
(
"('([^']+)'::)"
,
$tableColumn
[
'default'
],
$match
)
===
1
)
{
$tableColumn
[
'default'
]
=
$match
[
1
];
$tableColumn
[
'default'
]
=
$match
[
1
];
}
}
...
...
src/Schema/SQLServerSchemaManager.php
View file @
7336ae0a
...
@@ -134,7 +134,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
...
@@ -134,7 +134,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
return
null
;
return
null
;
}
}
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$value
,
$matches
))
{
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$value
,
$matches
)
===
1
)
{
$value
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
$value
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
}
}
...
...
src/Schema/SqliteSchemaManager.php
View file @
7336ae0a
...
@@ -131,7 +131,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
...
@@ -131,7 +131,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
)?#isx'
,
)?#isx'
,
$createSql
,
$createSql
,
$match
$match
))
{
)
>
0
)
{
$names
=
array_reverse
(
$match
[
1
]);
$names
=
array_reverse
(
$match
[
1
]);
$deferrable
=
array_reverse
(
$match
[
2
]);
$deferrable
=
array_reverse
(
$match
[
2
]);
$deferred
=
array_reverse
(
$match
[
3
]);
$deferred
=
array_reverse
(
$match
[
3
]);
...
@@ -334,7 +334,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
...
@@ -334,7 +334,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
if
(
$default
!==
null
)
{
if
(
$default
!==
null
)
{
// SQLite returns the default value as a literal expression, so we need to parse it
// SQLite returns the default value as a literal expression, so we need to parse it
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$default
,
$matches
))
{
if
(
preg_match
(
'/^\'(.*)\'$/s'
,
$default
,
$matches
)
===
1
)
{
$default
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
$default
=
str_replace
(
"''"
,
"'"
,
$matches
[
1
]);
}
}
}
}
...
...
src/Schema/Table.php
View file @
7336ae0a
...
@@ -271,7 +271,7 @@ class Table extends AbstractAsset
...
@@ -271,7 +271,7 @@ class Table extends AbstractAsset
*/
*/
private
function
_createIndex
(
array
$columnNames
,
$indexName
,
$isUnique
,
$isPrimary
,
array
$flags
=
[],
array
$options
=
[])
private
function
_createIndex
(
array
$columnNames
,
$indexName
,
$isUnique
,
$isPrimary
,
array
$flags
=
[],
array
$options
=
[])
{
{
if
(
preg_match
(
'(([^a-zA-Z0-9_]+))'
,
$this
->
normalizeIdentifier
(
$indexName
)))
{
if
(
preg_match
(
'(([^a-zA-Z0-9_]+))'
,
$this
->
normalizeIdentifier
(
$indexName
))
===
1
)
{
throw
SchemaException
::
indexNameInvalid
(
$indexName
);
throw
SchemaException
::
indexNameInvalid
(
$indexName
);
}
}
...
@@ -511,7 +511,7 @@ class Table extends AbstractAsset
...
@@ -511,7 +511,7 @@ class Table extends AbstractAsset
{
{
$constraint
->
setLocalTable
(
$this
);
$constraint
->
setLocalTable
(
$this
);
if
(
strlen
(
$constraint
->
getName
()))
{
if
(
strlen
(
$constraint
->
getName
())
>
0
)
{
$name
=
$constraint
->
getName
();
$name
=
$constraint
->
getName
();
}
else
{
}
else
{
$name
=
$this
->
_generateIdentifierName
(
$name
=
$this
->
_generateIdentifierName
(
...
@@ -714,7 +714,7 @@ class Table extends AbstractAsset
...
@@ -714,7 +714,7 @@ class Table extends AbstractAsset
*/
*/
public
function
hasPrimaryKey
()
public
function
hasPrimaryKey
()
{
{
return
$this
->
_primaryKeyName
&&
$this
->
hasIndex
(
$this
->
_primaryKeyName
);
return
$this
->
_primaryKeyName
!==
false
&&
$this
->
hasIndex
(
$this
->
_primaryKeyName
);
}
}
/**
/**
...
...
src/Statement.php
View file @
7336ae0a
...
@@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
...
@@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\Type
;
use
IteratorAggregate
;
use
IteratorAggregate
;
use
Throwable
;
use
Throwable
;
use
function
is_array
;
use
function
is_string
;
use
function
is_string
;
/**
/**
...
@@ -139,19 +138,19 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -139,19 +138,19 @@ class Statement implements IteratorAggregate, DriverStatement
*/
*/
public
function
execute
(
$params
=
null
)
public
function
execute
(
$params
=
null
)
{
{
if
(
is_array
(
$params
)
)
{
if
(
$params
!==
null
)
{
$this
->
params
=
$params
;
$this
->
params
=
$params
;
}
}
$logger
=
$this
->
conn
->
getConfiguration
()
->
getSQLLogger
();
$logger
=
$this
->
conn
->
getConfiguration
()
->
getSQLLogger
();
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
startQuery
(
$this
->
sql
,
$this
->
params
,
$this
->
types
);
$logger
->
startQuery
(
$this
->
sql
,
$this
->
params
,
$this
->
types
);
}
}
try
{
try
{
$stmt
=
$this
->
stmt
->
execute
(
$params
);
$stmt
=
$this
->
stmt
->
execute
(
$params
);
}
catch
(
Throwable
$ex
)
{
}
catch
(
Throwable
$ex
)
{
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
throw
DBALException
::
driverExceptionDuringQuery
(
throw
DBALException
::
driverExceptionDuringQuery
(
...
@@ -162,7 +161,7 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -162,7 +161,7 @@ class Statement implements IteratorAggregate, DriverStatement
);
);
}
}
if
(
$logger
)
{
if
(
$logger
!==
null
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
}
}
$this
->
params
=
[];
$this
->
params
=
[];
...
...
src/Tools/Console/Command/ReservedWordsCommand.php
View file @
7336ae0a
...
@@ -108,7 +108,7 @@ EOT
...
@@ -108,7 +108,7 @@ EOT
$conn
=
$this
->
getHelper
(
'db'
)
->
getConnection
();
$conn
=
$this
->
getHelper
(
'db'
)
->
getConnection
();
$keywordLists
=
(
array
)
$input
->
getOption
(
'list'
);
$keywordLists
=
(
array
)
$input
->
getOption
(
'list'
);
if
(
!
$keywordLists
)
{
if
(
count
(
$keywordLists
)
===
0
)
{
$keywordLists
=
array_keys
(
$this
->
keywordListClasses
);
$keywordLists
=
array_keys
(
$this
->
keywordListClasses
);
}
}
...
...
src/Tools/Console/Command/RunSqlCommand.php
View file @
7336ae0a
...
@@ -11,6 +11,7 @@ use Symfony\Component\Console\Input\InputInterface;
...
@@ -11,6 +11,7 @@ use Symfony\Component\Console\Input\InputInterface;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
function
assert
;
use
function
assert
;
use
function
is_bool
;
use
function
is_numeric
;
use
function
is_numeric
;
use
function
is_string
;
use
function
is_string
;
use
function
stripos
;
use
function
stripos
;
...
@@ -59,7 +60,10 @@ EOT
...
@@ -59,7 +60,10 @@ EOT
throw
new
LogicException
(
"Option 'depth' must contains an integer value"
);
throw
new
LogicException
(
"Option 'depth' must contains an integer value"
);
}
}
if
(
stripos
(
$sql
,
'select'
)
===
0
||
$input
->
getOption
(
'force-fetch'
))
{
$forceFetch
=
$input
->
getOption
(
'force-fetch'
);
assert
(
is_bool
(
$forceFetch
));
if
(
stripos
(
$sql
,
'select'
)
===
0
||
$forceFetch
)
{
$resultSet
=
$conn
->
fetchAll
(
$sql
);
$resultSet
=
$conn
->
fetchAll
(
$sql
);
}
else
{
}
else
{
$resultSet
=
$conn
->
executeUpdate
(
$sql
);
$resultSet
=
$conn
->
executeUpdate
(
$sql
);
...
...
src/Types/DateImmutableType.php
View file @
7336ae0a
...
@@ -49,7 +49,7 @@ class DateImmutableType extends DateType
...
@@ -49,7 +49,7 @@ class DateImmutableType extends DateType
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
'!'
.
$platform
->
getDateFormatString
(),
$value
);
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
'!'
.
$platform
->
getDateFormatString
(),
$value
);
if
(
!
$dateTim
e
)
{
if
(
$dateTime
===
fals
e
)
{
throw
ConversionException
::
conversionFailedFormat
(
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$value
,
$this
->
getName
(),
$this
->
getName
(),
...
...
src/Types/DateTimeImmutableType.php
View file @
7336ae0a
...
@@ -50,11 +50,11 @@ class DateTimeImmutableType extends DateTimeType
...
@@ -50,11 +50,11 @@ class DateTimeImmutableType extends DateTimeType
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
$platform
->
getDateTimeFormatString
(),
$value
);
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
$platform
->
getDateTimeFormatString
(),
$value
);
if
(
!
$dateTim
e
)
{
if
(
$dateTime
===
fals
e
)
{
$dateTime
=
date_create_immutable
(
$value
);
$dateTime
=
date_create_immutable
(
$value
);
}
}
if
(
!
$dateTim
e
)
{
if
(
$dateTime
===
fals
e
)
{
throw
ConversionException
::
conversionFailedFormat
(
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$value
,
$this
->
getName
(),
$this
->
getName
(),
...
...
src/Types/DateTimeType.php
View file @
7336ae0a
...
@@ -55,11 +55,11 @@ class DateTimeType extends Type implements PhpDateTimeMappingType
...
@@ -55,11 +55,11 @@ class DateTimeType extends Type implements PhpDateTimeMappingType
$val
=
DateTime
::
createFromFormat
(
$platform
->
getDateTimeFormatString
(),
$value
);
$val
=
DateTime
::
createFromFormat
(
$platform
->
getDateTimeFormatString
(),
$value
);
if
(
!
$val
)
{
if
(
$val
===
false
)
{
$val
=
date_create
(
$value
);
$val
=
date_create
(
$value
);
}
}
if
(
!
$val
)
{
if
(
$val
===
false
)
{
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getDateTimeFormatString
());
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getDateTimeFormatString
());
}
}
...
...
src/Types/DateTimeTzImmutableType.php
View file @
7336ae0a
...
@@ -49,7 +49,7 @@ class DateTimeTzImmutableType extends DateTimeTzType
...
@@ -49,7 +49,7 @@ class DateTimeTzImmutableType extends DateTimeTzType
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
$platform
->
getDateTimeTzFormatString
(),
$value
);
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
$platform
->
getDateTimeTzFormatString
(),
$value
);
if
(
!
$dateTim
e
)
{
if
(
$dateTime
===
fals
e
)
{
throw
ConversionException
::
conversionFailedFormat
(
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$value
,
$this
->
getName
(),
$this
->
getName
(),
...
...
src/Types/DateTimeTzType.php
View file @
7336ae0a
...
@@ -66,7 +66,7 @@ class DateTimeTzType extends Type implements PhpDateTimeMappingType
...
@@ -66,7 +66,7 @@ class DateTimeTzType extends Type implements PhpDateTimeMappingType
}
}
$val
=
DateTime
::
createFromFormat
(
$platform
->
getDateTimeTzFormatString
(),
$value
);
$val
=
DateTime
::
createFromFormat
(
$platform
->
getDateTimeTzFormatString
(),
$value
);
if
(
!
$val
)
{
if
(
$val
===
false
)
{
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getDateTimeTzFormatString
());
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getDateTimeTzFormatString
());
}
}
...
...
src/Types/DateType.php
View file @
7336ae0a
...
@@ -53,7 +53,7 @@ class DateType extends Type
...
@@ -53,7 +53,7 @@ class DateType extends Type
}
}
$val
=
DateTime
::
createFromFormat
(
'!'
.
$platform
->
getDateFormatString
(),
$value
);
$val
=
DateTime
::
createFromFormat
(
'!'
.
$platform
->
getDateFormatString
(),
$value
);
if
(
!
$val
)
{
if
(
$val
===
false
)
{
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getDateFormatString
());
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getDateFormatString
());
}
}
...
...
src/Types/SimpleArrayType.php
View file @
7336ae0a
...
@@ -3,8 +3,10 @@
...
@@ -3,8 +3,10 @@
namespace
Doctrine\DBAL\Types
;
namespace
Doctrine\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
function
count
;
use
function
explode
;
use
function
explode
;
use
function
implode
;
use
function
implode
;
use
function
is_array
;
use
function
is_resource
;
use
function
is_resource
;
use
function
stream_get_contents
;
use
function
stream_get_contents
;
...
@@ -28,7 +30,7 @@ class SimpleArrayType extends Type
...
@@ -28,7 +30,7 @@ class SimpleArrayType extends Type
*/
*/
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
!
$value
)
{
if
(
!
is_array
(
$value
)
||
count
(
$value
)
===
0
)
{
return
null
;
return
null
;
}
}
...
...
src/Types/TimeImmutableType.php
View file @
7336ae0a
...
@@ -49,7 +49,7 @@ class TimeImmutableType extends TimeType
...
@@ -49,7 +49,7 @@ class TimeImmutableType extends TimeType
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
'!'
.
$platform
->
getTimeFormatString
(),
$value
);
$dateTime
=
DateTimeImmutable
::
createFromFormat
(
'!'
.
$platform
->
getTimeFormatString
(),
$value
);
if
(
!
$dateTim
e
)
{
if
(
$dateTime
===
fals
e
)
{
throw
ConversionException
::
conversionFailedFormat
(
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$value
,
$this
->
getName
(),
$this
->
getName
(),
...
...
src/Types/TimeType.php
View file @
7336ae0a
...
@@ -53,7 +53,7 @@ class TimeType extends Type
...
@@ -53,7 +53,7 @@ class TimeType extends Type
}
}
$val
=
DateTime
::
createFromFormat
(
'!'
.
$platform
->
getTimeFormatString
(),
$value
);
$val
=
DateTime
::
createFromFormat
(
'!'
.
$platform
->
getTimeFormatString
(),
$value
);
if
(
!
$val
)
{
if
(
$val
===
false
)
{
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getTimeFormatString
());
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getTimeFormatString
());
}
}
...
...
src/Types/VarDateTimeImmutableType.php
View file @
7336ae0a
...
@@ -50,7 +50,7 @@ class VarDateTimeImmutableType extends VarDateTimeType
...
@@ -50,7 +50,7 @@ class VarDateTimeImmutableType extends VarDateTimeType
$dateTime
=
date_create_immutable
(
$value
);
$dateTime
=
date_create_immutable
(
$value
);
if
(
!
$dateTim
e
)
{
if
(
$dateTime
===
fals
e
)
{
throw
ConversionException
::
conversionFailed
(
$value
,
$this
->
getName
());
throw
ConversionException
::
conversionFailed
(
$value
,
$this
->
getName
());
}
}
...
...
src/Types/VarDateTimeType.php
View file @
7336ae0a
...
@@ -25,7 +25,7 @@ class VarDateTimeType extends DateTimeType
...
@@ -25,7 +25,7 @@ class VarDateTimeType extends DateTimeType
}
}
$val
=
date_create
(
$value
);
$val
=
date_create
(
$value
);
if
(
!
$val
)
{
if
(
$val
===
false
)
{
throw
ConversionException
::
conversionFailed
(
$value
,
$this
->
getName
());
throw
ConversionException
::
conversionFailed
(
$value
,
$this
->
getName
());
}
}
...
...
tests/FunctionalTestCase.php
View file @
7336ae0a
...
@@ -68,7 +68,7 @@ abstract class FunctionalTestCase extends TestCase
...
@@ -68,7 +68,7 @@ abstract class FunctionalTestCase extends TestCase
throw
$t
;
throw
$t
;
}
}
if
(
isset
(
$this
->
sqlLoggerStack
->
queries
)
&&
count
(
$this
->
sqlLoggerStack
->
queries
)
)
{
if
(
count
(
$this
->
sqlLoggerStack
->
queries
)
>
0
)
{
$queries
=
''
;
$queries
=
''
;
$i
=
count
(
$this
->
sqlLoggerStack
->
queries
);
$i
=
count
(
$this
->
sqlLoggerStack
->
queries
);
foreach
(
array_reverse
(
$this
->
sqlLoggerStack
->
queries
)
as
$query
)
{
foreach
(
array_reverse
(
$this
->
sqlLoggerStack
->
queries
)
as
$query
)
{
...
...
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