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
3e83d36e
Unverified
Commit
3e83d36e
authored
Jan 21, 2019
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPStan Level 4
parent
b90d6324
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
47 additions
and
91 deletions
+47
-91
Connection.php
lib/Doctrine/DBAL/Connection.php
+2
-2
MasterSlaveConnection.php
lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
+2
-2
DB2Statement.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+1
-13
MysqliStatement.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+9
-17
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+8
-9
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+2
-1
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+1
-1
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+4
-14
ColumnDiff.php
lib/Doctrine/DBAL/Schema/ColumnDiff.php
+1
-1
Sequence.php
lib/Doctrine/DBAL/Schema/Sequence.php
+2
-3
SqliteSchemaManager.php
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
+6
-5
TableDiff.php
lib/Doctrine/DBAL/Schema/TableDiff.php
+8
-4
SQLAzureShardManager.php
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
+0
-6
phpstan.neon.dist
phpstan.neon.dist
+1
-1
SQLAzureShardManagerTest.php
...Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php
+0
-12
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
3e83d36e
...
...
@@ -149,7 +149,7 @@ class Connection implements DriverConnection
/**
* The schema manager.
*
* @var AbstractSchemaManager
* @var AbstractSchemaManager
|null
*/
protected
$_schemaManager
;
...
...
@@ -1446,7 +1446,7 @@ class Connection implements DriverConnection
*/
public
function
getSchemaManager
()
{
if
(
!
$this
->
_schemaManager
)
{
if
(
$this
->
_schemaManager
===
null
)
{
$this
->
_schemaManager
=
$this
->
_driver
->
getSchemaManager
(
$this
);
}
...
...
lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
View file @
3e83d36e
...
...
@@ -133,7 +133,7 @@ class MasterSlaveConnection extends Connection
// If we have a connection open, and this is not an explicit connection
// change request, then abort right here, because we are already done.
// This prevents writes to the slave in case of "keepSlave" option enabled.
if
(
isset
(
$this
->
_conn
)
&&
$this
->
_conn
&&
!
$requestedConnectionChange
)
{
if
(
$this
->
_conn
!==
null
&&
!
$requestedConnectionChange
)
{
return
false
;
}
...
...
@@ -144,7 +144,7 @@ class MasterSlaveConnection extends Connection
$forceMasterAsSlave
=
true
;
}
if
(
isset
(
$this
->
connections
[
$connectionName
])
&&
$this
->
connections
[
$connectionName
]
)
{
if
(
isset
(
$this
->
connections
[
$connectionName
]))
{
$this
->
_conn
=
$this
->
connections
[
$connectionName
];
if
(
$forceMasterAsSlave
&&
!
$this
->
keepSlave
)
{
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
View file @
3e83d36e
...
...
@@ -146,10 +146,6 @@ class DB2Statement implements IteratorAggregate, Statement
*/
public
function
closeCursor
()
{
if
(
!
$this
->
stmt
)
{
return
false
;
}
$this
->
bindParam
=
[];
if
(
!
db2_free_result
(
$this
->
stmt
))
{
...
...
@@ -166,11 +162,7 @@ class DB2Statement implements IteratorAggregate, Statement
*/
public
function
columnCount
()
{
if
(
!
$this
->
stmt
)
{
return
0
;
}
return
db2_num_fields
(
$this
->
stmt
);
return
db2_num_fields
(
$this
->
stmt
)
?:
0
;
}
/**
...
...
@@ -197,10 +189,6 @@ class DB2Statement implements IteratorAggregate, Statement
*/
public
function
execute
(
$params
=
null
)
{
if
(
!
$this
->
stmt
)
{
return
false
;
}
if
(
$params
===
null
)
{
ksort
(
$this
->
bindParam
);
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
3e83d36e
...
...
@@ -97,16 +97,12 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
public
function
bindParam
(
$column
,
&
$variable
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
{
if
(
$type
===
null
)
{
$type
=
's'
;
}
else
{
if
(
!
isset
(
self
::
$_paramTypeMap
[
$type
]))
{
throw
new
MysqliException
(
sprintf
(
"Unknown type: '%s'"
,
$type
));
}
$type
=
self
::
$_paramTypeMap
[
$type
];
if
(
!
isset
(
self
::
$_paramTypeMap
[
$type
]))
{
throw
new
MysqliException
(
sprintf
(
"Unknown type: '%s'"
,
$type
));
}
$type
=
self
::
$_paramTypeMap
[
$type
];
$this
->
_bindedValues
[
$column
]
=&
$variable
;
$this
->
types
[
$column
-
1
]
=
$type
;
...
...
@@ -118,16 +114,12 @@ class MysqliStatement implements IteratorAggregate, Statement
*/
public
function
bindValue
(
$param
,
$value
,
$type
=
ParameterType
::
STRING
)
{
if
(
$type
===
null
)
{
$type
=
's'
;
}
else
{
if
(
!
isset
(
self
::
$_paramTypeMap
[
$type
]))
{
throw
new
MysqliException
(
sprintf
(
"Unknown type: '%s'"
,
$type
));
}
$type
=
self
::
$_paramTypeMap
[
$type
];
if
(
!
isset
(
self
::
$_paramTypeMap
[
$type
]))
{
throw
new
MysqliException
(
sprintf
(
"Unknown type: '%s'"
,
$type
));
}
$type
=
self
::
$_paramTypeMap
[
$type
];
$this
->
_values
[
$param
]
=
$value
;
$this
->
_bindedValues
[
$param
]
=&
$this
->
_values
[
$param
];
$this
->
types
[
$param
-
1
]
=
$type
;
...
...
@@ -284,7 +276,7 @@ class MysqliStatement implements IteratorAggregate, Statement
}
/**
* @return mixed[]|false
* @return mixed[]|false
|null
*/
private
function
_fetch
()
{
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
3e83d36e
...
...
@@ -144,7 +144,7 @@ abstract class AbstractPlatform
/**
* Holds the KeywordList instance for the current platform.
*
* @var KeywordList
* @var KeywordList
|null
*/
protected
$_keywords
;
...
...
@@ -518,7 +518,7 @@ abstract class AbstractPlatform
/**
* Gets the comment of a passed column modified by potential doctrine type comment hints.
*
* @return string
* @return string
|null
*/
protected
function
getColumnComment
(
Column
$column
)
{
...
...
@@ -1610,9 +1610,9 @@ abstract class AbstractPlatform
}
/**
* @param string $tableName
* @param string $columnName
* @param string $comment
* @param string
$tableName
* @param string
$columnName
* @param string
|null
$comment
*
* @return string
*/
...
...
@@ -1620,13 +1620,12 @@ abstract class AbstractPlatform
{
$tableName
=
new
Identifier
(
$tableName
);
$columnName
=
new
Identifier
(
$columnName
);
$comment
=
$this
->
quoteStringLiteral
(
$comment
);
return
sprintf
(
'COMMENT ON COLUMN %s.%s IS %s'
,
$tableName
->
getQuotedName
(
$this
),
$columnName
->
getQuotedName
(
$this
),
$
comment
$
this
->
quoteStringLiteral
((
string
)
$comment
)
);
}
...
...
@@ -2300,7 +2299,7 @@ abstract class AbstractPlatform
* Obtains DBMS specific SQL code portion needed to set a CHECK constraint
* declaration to be used in statements like CREATE TABLE.
*
* @param mixed[][] $definition The check definition.
* @param
string[]|
mixed[][] $definition The check definition.
*
* @return string DBMS specific SQL code portion needed to set a CHECK constraint.
*/
...
...
@@ -3154,7 +3153,7 @@ abstract class AbstractPlatform
*/
public
function
supportsForeignKeyOnUpdate
()
{
return
$this
->
supportsForeignKeyConstraints
()
&&
true
;
return
$this
->
supportsForeignKeyConstraints
();
}
/**
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
3e83d36e
...
...
@@ -1215,7 +1215,8 @@ SQL
*/
private
function
isSerialField
(
array
$field
)
:
bool
{
return
$field
[
'autoincrement'
]
??
false
===
true
&&
isset
(
$field
[
'type'
])
return
isset
(
$field
[
'type'
],
$field
[
'autoincrement'
])
&&
$field
[
'autoincrement'
]
===
true
&&
$this
->
isNumericType
(
$field
[
'type'
]);
}
...
...
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
3e83d36e
...
...
@@ -403,7 +403,7 @@ class QueryBuilder
* 'groupBy', 'having' and 'orderBy'.
*
* @param string $sqlPartName
* @param
string
$sqlPart
* @param
mixed
$sqlPart
* @param bool $append
*
* @return $this This QueryBuilder instance.
...
...
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
3e83d36e
...
...
@@ -747,14 +747,9 @@ abstract class AbstractSchemaManager
protected
function
_getPortableSequencesList
(
$sequences
)
{
$list
=
[];
foreach
(
$sequences
as
$value
)
{
$value
=
$this
->
_getPortableSequenceDefinition
(
$value
);
if
(
!
$value
)
{
continue
;
}
$list
[]
=
$value
;
foreach
(
$sequences
as
$value
)
{
$list
[]
=
$this
->
_getPortableSequenceDefinition
(
$value
);
}
return
$list
;
...
...
@@ -996,14 +991,9 @@ abstract class AbstractSchemaManager
protected
function
_getPortableTableForeignKeysList
(
$tableForeignKeys
)
{
$list
=
[];
foreach
(
$tableForeignKeys
as
$value
)
{
$value
=
$this
->
_getPortableTableForeignKeyDefinition
(
$value
);
if
(
!
$value
)
{
continue
;
}
$list
[]
=
$value
;
foreach
(
$tableForeignKeys
as
$value
)
{
$list
[]
=
$this
->
_getPortableTableForeignKeyDefinition
(
$value
);
}
return
$list
;
...
...
lib/Doctrine/DBAL/Schema/ColumnDiff.php
View file @
3e83d36e
...
...
@@ -18,7 +18,7 @@ class ColumnDiff
/** @var string[] */
public
$changedProperties
=
[];
/** @var Column */
/** @var Column
|null
*/
public
$fromColumn
;
/**
...
...
lib/Doctrine/DBAL/Schema/Sequence.php
View file @
3e83d36e
...
...
@@ -4,7 +4,6 @@ namespace Doctrine\DBAL\Schema;
use
Doctrine\DBAL\Schema\Visitor\Visitor
;
use
function
count
;
use
function
is_numeric
;
use
function
sprintf
;
/**
...
...
@@ -66,7 +65,7 @@ class Sequence extends AbstractAsset
*/
public
function
setAllocationSize
(
$allocationSize
)
{
$this
->
allocationSize
=
is_numeric
(
$allocationSize
)
?
(
int
)
$allocationSize
:
1
;
$this
->
allocationSize
=
(
int
)
$allocationSize
?
:
1
;
return
$this
;
}
...
...
@@ -78,7 +77,7 @@ class Sequence extends AbstractAsset
*/
public
function
setInitialValue
(
$initialValue
)
{
$this
->
initialValue
=
is_numeric
(
$initialValue
)
?
(
int
)
$initialValue
:
1
;
$this
->
initialValue
=
(
int
)
$initialValue
?
:
1
;
return
$this
;
}
...
...
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
View file @
3e83d36e
...
...
@@ -77,7 +77,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
*/
public
function
createForeignKey
(
ForeignKeyConstraint
$foreignKey
,
$table
)
{
$tableDiff
=
$this
->
getTableDiffForAlterForeignKey
(
$
foreignKey
,
$
table
);
$tableDiff
=
$this
->
getTableDiffForAlterForeignKey
(
$table
);
$tableDiff
->
addedForeignKeys
[]
=
$foreignKey
;
$this
->
alterTable
(
$tableDiff
);
...
...
@@ -88,7 +88,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
*/
public
function
dropAndCreateForeignKey
(
ForeignKeyConstraint
$foreignKey
,
$table
)
{
$tableDiff
=
$this
->
getTableDiffForAlterForeignKey
(
$
foreignKey
,
$
table
);
$tableDiff
=
$this
->
getTableDiffForAlterForeignKey
(
$table
);
$tableDiff
->
changedForeignKeys
[]
=
$foreignKey
;
$this
->
alterTable
(
$tableDiff
);
...
...
@@ -99,7 +99,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
*/
public
function
dropForeignKey
(
$foreignKey
,
$table
)
{
$tableDiff
=
$this
->
getTableDiffForAlterForeignKey
(
$
foreignKey
,
$
table
);
$tableDiff
=
$this
->
getTableDiffForAlterForeignKey
(
$table
);
$tableDiff
->
removedForeignKeys
[]
=
$foreignKey
;
$this
->
alterTable
(
$tableDiff
);
...
...
@@ -436,11 +436,12 @@ class SqliteSchemaManager extends AbstractSchemaManager
*
* @throws DBALException
*/
private
function
getTableDiffForAlterForeignKey
(
ForeignKeyConstraint
$foreignKey
,
$table
)
private
function
getTableDiffForAlterForeignKey
(
$table
)
{
if
(
!
$table
instanceof
Table
)
{
$tableDetails
=
$this
->
tryMethod
(
'listTableDetails'
,
$table
);
if
(
$table
===
false
)
{
if
(
$tableDetails
===
false
)
{
throw
new
DBALException
(
sprintf
(
'Sqlite schema manager requires to modify foreign keys table definition "%s".'
,
$table
));
}
...
...
lib/Doctrine/DBAL/Schema/TableDiff.php
View file @
3e83d36e
...
...
@@ -12,7 +12,7 @@ class TableDiff
/** @var string */
public
$name
=
null
;
/** @var string|
bool
*/
/** @var string|
false
*/
public
$newName
=
false
;
/**
...
...
@@ -92,7 +92,7 @@ class TableDiff
*/
public
$removedForeignKeys
=
[];
/** @var Table */
/** @var Table
|null
*/
public
$fromTable
;
/**
...
...
@@ -139,10 +139,14 @@ class TableDiff
}
/**
* @return Identifier|
string|bool
* @return Identifier|
false
*/
public
function
getNewName
()
{
return
$this
->
newName
?
new
Identifier
(
$this
->
newName
)
:
$this
->
newName
;
if
(
$this
->
newName
===
false
)
{
return
false
;
}
return
new
Identifier
(
$this
->
newName
);
}
}
lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php
View file @
3e83d36e
...
...
@@ -7,8 +7,6 @@ use Doctrine\DBAL\Sharding\ShardingException;
use
Doctrine\DBAL\Sharding\ShardManager
;
use
Doctrine\DBAL\Types\Type
;
use
RuntimeException
;
use
function
is_bool
;
use
function
is_scalar
;
use
function
sprintf
;
/**
...
...
@@ -125,10 +123,6 @@ class SQLAzureShardManager implements ShardManager
throw
ShardingException
::
activeTransaction
();
}
if
(
$distributionValue
===
null
||
is_bool
(
$distributionValue
)
||
!
is_scalar
(
$distributionValue
))
{
throw
ShardingException
::
noShardDistributionValue
();
}
$platform
=
$this
->
conn
->
getDatabasePlatform
();
$sql
=
sprintf
(
'USE FEDERATION %s (%s = %s) WITH RESET, FILTERING = %s;'
,
...
...
phpstan.neon.dist
View file @
3e83d36e
parameters:
level:
3
level:
4
paths:
- %currentWorkingDirectory%/lib
autoload_files:
...
...
tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php
View file @
3e83d36e
...
...
@@ -79,18 +79,6 @@ class SQLAzureShardManagerTest extends TestCase
self
::
assertEquals
(
1234
,
$sm
->
getCurrentDistributionValue
());
}
public
function
testSelectShardNoDistributionValue
()
{
$conn
=
$this
->
createConnection
([
'sharding'
=>
[
'federationName'
=>
'abc'
,
'distributionKey'
=>
'foo'
,
'distributionType'
=>
'integer'
]]);
$conn
->
expects
(
$this
->
at
(
1
))
->
method
(
'isTransactionActive'
)
->
will
(
$this
->
returnValue
(
false
));
$this
->
expectException
(
ShardingException
::
class
);
$this
->
expectExceptionMessage
(
'You have to specify a string or integer as shard distribution value.'
);
$sm
=
new
SQLAzureShardManager
(
$conn
);
$sm
->
selectShard
(
null
);
}
/**
* @param mixed[] $params
*/
...
...
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