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
8b373f4a
Commit
8b373f4a
authored
Dec 30, 2019
by
Benjamin Morel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix phpstan errors
parent
489cb9eb
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
46 additions
and
41 deletions
+46
-41
ArrayStatement.php
lib/Doctrine/DBAL/Cache/ArrayStatement.php
+1
-5
Connection.php
lib/Doctrine/DBAL/Connection.php
+2
-0
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+14
-14
Connection.php
lib/Doctrine/DBAL/Portability/Connection.php
+1
-1
Statement.php
lib/Doctrine/DBAL/Portability/Statement.php
+2
-1
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+2
-2
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+4
-0
MySqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+0
-9
phpstan.neon.dist
phpstan.neon.dist
+1
-1
DefaultValueTest.php
...octrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php
+0
-4
OracleSchemaManagerTest.php
.../Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
+8
-2
PostgreSqlSchemaManagerTest.php
...ts/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
+5
-1
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+1
-1
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+5
-0
No files found.
lib/Doctrine/DBAL/Cache/ArrayStatement.php
View file @
8b373f4a
...
...
@@ -49,7 +49,7 @@ final class ArrayStatement implements IteratorAggregate, ResultStatement
*/
public
function
closeCursor
()
:
void
{
$this
->
data
=
null
;
$this
->
data
=
[]
;
}
/**
...
...
@@ -65,10 +65,6 @@ final class ArrayStatement implements IteratorAggregate, ResultStatement
*/
public
function
rowCount
()
:
int
{
if
(
$this
->
data
===
null
)
{
return
0
;
}
return
count
(
$this
->
data
);
}
...
...
lib/Doctrine/DBAL/Connection.php
View file @
8b373f4a
...
...
@@ -1264,6 +1264,8 @@ class Connection implements DriverConnection
{
$this
->
connect
();
assert
(
$this
->
_conn
!==
null
);
return
$this
->
_conn
;
}
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
8b373f4a
...
...
@@ -688,7 +688,7 @@ class SqlitePlatform extends AbstractPlatform
*/
protected
function
getPostAlterTableIndexForeignKeySQL
(
TableDiff
$diff
)
:
array
{
if
(
!
$diff
->
fromTable
instanceof
Table
)
{
if
(
$diff
->
fromTable
===
null
)
{
throw
new
DBALException
(
'Sqlite platform requires for alter table the table diff with reference to original table schema.'
);
}
...
...
@@ -699,7 +699,7 @@ class SqlitePlatform extends AbstractPlatform
$tableName
=
$diff
->
getName
(
$this
);
}
foreach
(
$this
->
getIndexesInAlteredTable
(
$diff
)
as
$index
)
{
foreach
(
$this
->
getIndexesInAlteredTable
(
$diff
,
$diff
->
fromTable
)
as
$index
)
{
if
(
$index
->
isPrimary
())
{
continue
;
}
...
...
@@ -823,7 +823,7 @@ class SqlitePlatform extends AbstractPlatform
}
$fromTable
=
$diff
->
fromTable
;
if
(
!
$fromTable
instanceof
Table
)
{
if
(
$fromTable
===
null
)
{
throw
new
DBALException
(
'Sqlite platform requires for alter table the table diff with reference to original table schema.'
);
}
...
...
@@ -908,7 +908,7 @@ class SqlitePlatform extends AbstractPlatform
if
(
!
$this
->
onSchemaAlterTable
(
$diff
,
$tableSql
))
{
$dataTable
=
new
Table
(
'__temp__'
.
$table
->
getName
());
$newTable
=
new
Table
(
$table
->
getQuotedName
(
$this
),
$columns
,
$this
->
getPrimaryIndexInAlteredTable
(
$diff
),
[],
$this
->
getForeignKeysInAlteredTable
(
$diff
),
$table
->
getOptions
());
$newTable
=
new
Table
(
$table
->
getQuotedName
(
$this
),
$columns
,
$this
->
getPrimaryIndexInAlteredTable
(
$diff
,
$fromTable
),
[],
$this
->
getForeignKeysInAlteredTable
(
$diff
,
$fromTable
),
$table
->
getOptions
());
$newTable
->
addOption
(
'alter'
,
true
);
$sql
=
$this
->
getPreAlterTableIndexForeignKeySQL
(
$diff
);
...
...
@@ -1016,11 +1016,11 @@ class SqlitePlatform extends AbstractPlatform
/**
* @return string[]
*/
private
function
getColumnNamesInAlteredTable
(
TableDiff
$diff
)
:
array
private
function
getColumnNamesInAlteredTable
(
TableDiff
$diff
,
Table
$fromTable
)
:
array
{
$columns
=
[];
foreach
(
$
diff
->
fromTable
->
getColumns
()
as
$columnName
=>
$column
)
{
foreach
(
$fromTable
->
getColumns
()
as
$columnName
=>
$column
)
{
$columns
[
strtolower
(
$columnName
)]
=
$column
->
getName
();
}
...
...
@@ -1056,10 +1056,10 @@ class SqlitePlatform extends AbstractPlatform
/**
* @return Index[]
*/
private
function
getIndexesInAlteredTable
(
TableDiff
$diff
)
:
array
private
function
getIndexesInAlteredTable
(
TableDiff
$diff
,
Table
$fromTable
)
:
array
{
$indexes
=
$
diff
->
fromTable
->
getIndexes
();
$columnNames
=
$this
->
getColumnNamesInAlteredTable
(
$diff
);
$indexes
=
$fromTable
->
getIndexes
();
$columnNames
=
$this
->
getColumnNamesInAlteredTable
(
$diff
,
$fromTable
);
foreach
(
$indexes
as
$key
=>
$index
)
{
foreach
(
$diff
->
renamedIndexes
as
$oldIndexName
=>
$renamedIndex
)
{
...
...
@@ -1120,10 +1120,10 @@ class SqlitePlatform extends AbstractPlatform
/**
* @return ForeignKeyConstraint[]
*/
private
function
getForeignKeysInAlteredTable
(
TableDiff
$diff
)
:
array
private
function
getForeignKeysInAlteredTable
(
TableDiff
$diff
,
Table
$fromTable
)
:
array
{
$foreignKeys
=
$
diff
->
fromTable
->
getForeignKeys
();
$columnNames
=
$this
->
getColumnNamesInAlteredTable
(
$diff
);
$foreignKeys
=
$fromTable
->
getForeignKeys
();
$columnNames
=
$this
->
getColumnNamesInAlteredTable
(
$diff
,
$fromTable
);
foreach
(
$foreignKeys
as
$key
=>
$constraint
)
{
$changed
=
false
;
...
...
@@ -1180,11 +1180,11 @@ class SqlitePlatform extends AbstractPlatform
/**
* @return Index[]
*/
private
function
getPrimaryIndexInAlteredTable
(
TableDiff
$diff
)
:
array
private
function
getPrimaryIndexInAlteredTable
(
TableDiff
$diff
,
Table
$fromTable
)
:
array
{
$primaryIndex
=
[];
foreach
(
$this
->
getIndexesInAlteredTable
(
$diff
)
as
$index
)
{
foreach
(
$this
->
getIndexesInAlteredTable
(
$diff
,
$fromTable
)
as
$index
)
{
if
(
!
$index
->
isPrimary
())
{
continue
;
}
...
...
lib/Doctrine/DBAL/Portability/Connection.php
View file @
8b373f4a
...
...
@@ -35,7 +35,7 @@ class Connection extends \Doctrine\DBAL\Connection
/** @var int */
private
$portability
=
self
::
PORTABILITY_NONE
;
/** @var int */
/** @var int
|null
*/
private
$case
;
/**
...
...
lib/Doctrine/DBAL/Portability/Statement.php
View file @
8b373f4a
...
...
@@ -26,7 +26,7 @@ final class Statement implements IteratorAggregate, DriverStatement
/** @var DriverStatement|ResultStatement */
private
$stmt
;
/** @var int */
/** @var int
|null
*/
private
$case
;
/** @var int */
...
...
@@ -204,6 +204,7 @@ final class Statement implements IteratorAggregate, DriverStatement
}
if
(
$fixCase
)
{
assert
(
$this
->
case
!==
null
);
$row
=
array_change_key_case
(
$row
,
$this
->
case
);
}
...
...
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
8b373f4a
...
...
@@ -393,9 +393,9 @@ class QueryBuilder
* Gets the maximum number of results the query object was set to retrieve (the "limit").
* Returns NULL if {@link setMaxResults} was not applied to this query builder.
*
* @return int The maximum number of results.
* @return int
|null
The maximum number of results.
*/
public
function
getMaxResults
()
:
int
public
function
getMaxResults
()
:
?
int
{
return
$this
->
maxResults
;
}
...
...
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
8b373f4a
...
...
@@ -592,6 +592,8 @@ abstract class AbstractSchemaManager
*/
protected
function
_getPortableDatabaseDefinition
(
array
$database
)
:
string
{
assert
(
!
empty
(
$database
));
return
array_shift
(
$database
);
}
...
...
@@ -774,6 +776,8 @@ abstract class AbstractSchemaManager
*/
protected
function
_getPortableTableDefinition
(
array
$table
)
:
string
{
assert
(
!
empty
(
$table
));
return
array_shift
(
$table
);
}
...
...
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
8b373f4a
...
...
@@ -9,7 +9,6 @@ use Doctrine\DBAL\Platforms\MySqlPlatform;
use
Doctrine\DBAL\Types\Type
;
use
const
CASE_LOWER
;
use
function
array_change_key_case
;
use
function
array_shift
;
use
function
array_values
;
use
function
assert
;
use
function
explode
;
...
...
@@ -53,14 +52,6 @@ class MySqlSchemaManager extends AbstractSchemaManager
return
new
View
(
$view
[
'TABLE_NAME'
],
$view
[
'VIEW_DEFINITION'
]);
}
/**
* {@inheritdoc}
*/
protected
function
_getPortableTableDefinition
(
array
$table
)
:
string
{
return
array_shift
(
$table
);
}
/**
* {@inheritdoc}
*/
...
...
phpstan.neon.dist
View file @
8b373f4a
...
...
@@ -36,7 +36,7 @@ parameters:
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int|string> given\.\z~'
# PHPStan is too strict about preg_replace(): https://phpstan.org/r/993dc99f-0d43-4b51-868b-d01f982c1463
- '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string|null\.\z~'
- '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string
\
|null\.\z~'
# legacy variadic-like signature
- '~^Method Doctrine\\DBAL(\\.*)?Connection::query\(\) invoked with \d+ parameters?, 0 required\.\z~'
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php
View file @
8b373f4a
...
...
@@ -41,8 +41,6 @@ class DefaultValueTest extends DbalFunctionalTestCase
}
/**
* @param mixed $expectedDefault
*
* @dataProvider columnProvider
*/
public
function
testEscapedDefaultValueCanBeIntrospected
(
string
$name
,
?
string
$expectedDefault
)
:
void
...
...
@@ -58,8 +56,6 @@ class DefaultValueTest extends DbalFunctionalTestCase
}
/**
* @param mixed $expectedDefault
*
* @dataProvider columnProvider
*/
public
function
testEscapedDefaultValueCanBeInserted
(
string
$name
,
?
string
$expectedDefault
)
:
void
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
View file @
8b373f4a
...
...
@@ -177,7 +177,10 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
self
::
assertTrue
(
$onlinePrimaryTable
->
hasColumn
(
'"Id"'
));
self
::
assertSame
(
'"Id"'
,
$onlinePrimaryTable
->
getColumn
(
'"Id"'
)
->
getQuotedName
(
$platform
));
self
::
assertTrue
(
$onlinePrimaryTable
->
hasPrimaryKey
());
self
::
assertSame
([
'"Id"'
],
$onlinePrimaryTable
->
getPrimaryKey
()
->
getQuotedColumns
(
$platform
));
$onlinePrimaryTablePrimaryKey
=
$onlinePrimaryTable
->
getPrimaryKey
();
self
::
assertNotNull
(
$onlinePrimaryTablePrimaryKey
);
self
::
assertSame
([
'"Id"'
],
$onlinePrimaryTablePrimaryKey
->
getQuotedColumns
(
$platform
));
self
::
assertTrue
(
$onlinePrimaryTable
->
hasColumn
(
'select'
));
self
::
assertSame
(
'"select"'
,
$onlinePrimaryTable
->
getColumn
(
'select'
)
->
getQuotedName
(
$platform
));
...
...
@@ -211,7 +214,10 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
self
::
assertTrue
(
$onlineForeignTable
->
hasColumn
(
'id'
));
self
::
assertSame
(
'ID'
,
$onlineForeignTable
->
getColumn
(
'id'
)
->
getQuotedName
(
$platform
));
self
::
assertTrue
(
$onlineForeignTable
->
hasPrimaryKey
());
self
::
assertSame
([
'ID'
],
$onlineForeignTable
->
getPrimaryKey
()
->
getQuotedColumns
(
$platform
));
$onlineForeignTablePrimaryKey
=
$onlineForeignTable
->
getPrimaryKey
();
self
::
assertNotNull
(
$onlineForeignTablePrimaryKey
);
self
::
assertSame
([
'ID'
],
$onlineForeignTablePrimaryKey
->
getQuotedColumns
(
$platform
));
self
::
assertTrue
(
$onlineForeignTable
->
hasColumn
(
'"Fk"'
));
self
::
assertSame
(
'"Fk"'
,
$onlineForeignTable
->
getColumn
(
'"Fk"'
)
->
getQuotedName
(
$platform
));
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
View file @
8b373f4a
...
...
@@ -178,11 +178,15 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$nestedSchemaTable
=
$this
->
schemaManager
->
listTableDetails
(
'nested.schematable'
);
self
::
assertTrue
(
$nestedSchemaTable
->
hasColumn
(
'id'
));
self
::
assertEquals
([
'id'
],
$nestedSchemaTable
->
getPrimaryKey
()
->
getColumns
());
$primaryKey
=
$nestedSchemaTable
->
getPrimaryKey
();
self
::
assertNotNull
(
$primaryKey
);
self
::
assertEquals
([
'id'
],
$primaryKey
->
getColumns
());
$relatedFks
=
$nestedSchemaTable
->
getForeignKeys
();
self
::
assertCount
(
1
,
$relatedFks
);
$relatedFk
=
array_pop
(
$relatedFks
);
self
::
assertNotNull
(
$relatedFk
);
self
::
assertEquals
(
'nested.schemarelated'
,
$relatedFk
->
getForeignTableName
());
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
8b373f4a
...
...
@@ -271,7 +271,7 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
public
function
getGenerateForeignKeySql
()
:
string
{
return
null
;
$this
->
fail
(
'Foreign key constraints are not yet supported for SQLite.'
)
;
}
public
function
testModifyLimitQuery
()
:
void
...
...
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
8b373f4a
...
...
@@ -254,6 +254,7 @@ class ComparatorTest extends TestCase
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
self
::
assertNotNull
(
$tableDiff
);
self
::
assertCount
(
1
,
$tableDiff
->
renamedColumns
,
'we should have one rename datefield1 => new_datefield1.'
);
self
::
assertArrayHasKey
(
'datefield1'
,
$tableDiff
->
renamedColumns
,
"'datefield1' should be set to be renamed to new_datefield1"
);
self
::
assertCount
(
1
,
$tableDiff
->
addedColumns
,
"'new_datefield2' should be added"
);
...
...
@@ -723,6 +724,7 @@ class ComparatorTest extends TestCase
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
self
::
assertNotNull
(
$tableDiff
);
self
::
assertCount
(
0
,
$tableDiff
->
addedColumns
);
self
::
assertCount
(
0
,
$tableDiff
->
removedColumns
);
self
::
assertArrayHasKey
(
'foo'
,
$tableDiff
->
renamedColumns
);
...
...
@@ -748,6 +750,7 @@ class ComparatorTest extends TestCase
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
self
::
assertNotNull
(
$tableDiff
);
self
::
assertCount
(
1
,
$tableDiff
->
addedColumns
,
"'baz' should be added, not created through renaming!"
);
self
::
assertArrayHasKey
(
'baz'
,
$tableDiff
->
addedColumns
,
"'baz' should be added, not created through renaming!"
);
self
::
assertCount
(
2
,
$tableDiff
->
removedColumns
,
"'foo' and 'bar' should both be dropped, an ambiguity exists which one could be renamed to 'baz'."
);
...
...
@@ -773,6 +776,7 @@ class ComparatorTest extends TestCase
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$table1
,
$table2
);
self
::
assertNotNull
(
$tableDiff
);
self
::
assertCount
(
0
,
$tableDiff
->
addedIndexes
);
self
::
assertCount
(
0
,
$tableDiff
->
removedIndexes
);
self
::
assertArrayHasKey
(
'idx_foo'
,
$tableDiff
->
renamedIndexes
);
...
...
@@ -801,6 +805,7 @@ class ComparatorTest extends TestCase
$comparator
=
new
Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$table1
,
$table2
);
self
::
assertNotNull
(
$tableDiff
);
self
::
assertCount
(
1
,
$tableDiff
->
addedIndexes
);
self
::
assertArrayHasKey
(
'idx_baz'
,
$tableDiff
->
addedIndexes
);
self
::
assertCount
(
2
,
$tableDiff
->
removedIndexes
);
...
...
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