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
6c4401f4
Unverified
Commit
6c4401f4
authored
Apr 03, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked all possible usages of the empty() construct and whitelisted the rest
parent
f30a9a9a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
14 deletions
+26
-14
phpstan.neon.dist
phpstan.neon.dist
+10
-0
Connection.php
src/Connection.php
+4
-3
EasyConnectString.php
src/Driver/AbstractOracleDriver/EasyConnectString.php
+4
-4
Driver.php
src/Driver/PDOSqlsrv/Driver.php
+1
-1
CompositeExpression.php
src/Query/Expression/CompositeExpression.php
+1
-1
QueryBuilder.php
src/Query/QueryBuilder.php
+5
-4
Comparator.php
src/Schema/Comparator.php
+1
-1
No files found.
phpstan.neon.dist
View file @
6c4401f4
...
...
@@ -78,5 +78,15 @@ parameters:
-
message: '~^Call to static method PHPUnit\\Framework\\Assert::assertSame\(\) with Doctrine\\DBAL\\Types\\Type and Doctrine\\DBAL\\Types\\Type will always evaluate to true\.$~'
path: %currentWorkingDirectory%/tests/Types/TypeRegistryTest.php
# https://github.com/phpstan/phpstan-strict-rules/issues/103
-
message: '~^Construct empty\(\) is not allowed. Use more strict comparison\.~'
paths:
- %currentWorkingDirectory%/src/Driver/*/*Connection.php
- %currentWorkingDirectory%/src/Driver/*/Driver.php
- %currentWorkingDirectory%/src/Driver/AbstractOracleDriver/EasyConnectString.php
- %currentWorkingDirectory%/src/Platforms/*Platform.php
- %currentWorkingDirectory%/src/Schema/*SchemaManager.php
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
src/Connection.php
View file @
6c4401f4
...
...
@@ -23,6 +23,7 @@ use Exception;
use
Throwable
;
use
function
array_key_exists
;
use
function
assert
;
use
function
count
;
use
function
implode
;
use
function
is_int
;
use
function
is_string
;
...
...
@@ -420,7 +421,7 @@ class Connection implements DriverConnection
try
{
$this
->
connect
();
}
catch
(
Throwable
$originalException
)
{
if
(
empty
(
$this
->
params
[
'dbname'
]))
{
if
(
!
isset
(
$this
->
params
[
'dbname'
]))
{
throw
$originalException
;
}
...
...
@@ -647,7 +648,7 @@ class Connection implements DriverConnection
*/
public
function
delete
(
$tableExpression
,
array
$identifier
,
array
$types
=
[])
{
if
(
empty
(
$identifier
)
)
{
if
(
count
(
$identifier
)
===
0
)
{
throw
InvalidArgumentException
::
fromEmptyCriteria
();
}
...
...
@@ -753,7 +754,7 @@ class Connection implements DriverConnection
*/
public
function
insert
(
$tableExpression
,
array
$data
,
array
$types
=
[])
{
if
(
empty
(
$data
)
)
{
if
(
count
(
$data
)
===
0
)
{
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$tableExpression
.
' () VALUES ()'
);
}
...
...
src/Driver/AbstractOracleDriver/EasyConnectString.php
View file @
6c4401f4
...
...
@@ -45,11 +45,11 @@ final class EasyConnectString
*/
public
static
function
fromConnectionParameters
(
array
$params
)
:
self
{
if
(
!
empty
(
$params
[
'connectstring'
]))
{
if
(
isset
(
$params
[
'connectstring'
]))
{
return
new
self
(
$params
[
'connectstring'
]);
}
if
(
empty
(
$params
[
'host'
]))
{
if
(
!
isset
(
$params
[
'host'
]))
{
return
new
self
(
$params
[
'dbname'
]
??
''
);
}
...
...
@@ -58,7 +58,7 @@ final class EasyConnectString
if
(
isset
(
$params
[
'servicename'
])
||
isset
(
$params
[
'dbname'
]))
{
$serviceKey
=
'SID'
;
if
(
!
empty
(
$params
[
'service'
]))
{
if
(
isset
(
$params
[
'service'
]))
{
$serviceKey
=
'SERVICE_NAME'
;
}
...
...
@@ -67,7 +67,7 @@ final class EasyConnectString
$connectData
[
$serviceKey
]
=
$serviceName
;
}
if
(
!
empty
(
$params
[
'instancename'
]))
{
if
(
isset
(
$params
[
'instancename'
]))
{
$connectData
[
'INSTANCE_NAME'
]
=
$params
[
'instancename'
];
}
...
...
src/Driver/PDOSqlsrv/Driver.php
View file @
6c4401f4
...
...
@@ -55,7 +55,7 @@ class Driver extends AbstractSQLServerDriver
$dsn
.=
$params
[
'host'
];
}
if
(
isset
(
$params
[
'port'
])
&&
!
empty
(
$params
[
'port'
])
)
{
if
(
isset
(
$params
[
'port'
]))
{
$dsn
.=
','
.
$params
[
'port'
];
}
...
...
src/Query/Expression/CompositeExpression.php
View file @
6c4401f4
...
...
@@ -96,7 +96,7 @@ class CompositeExpression implements Countable
*/
public
function
add
(
$part
)
{
if
(
empty
(
$part
)
)
{
if
(
$part
===
null
)
{
return
$this
;
}
...
...
src/Query/QueryBuilder.php
View file @
6c4401f4
...
...
@@ -10,6 +10,7 @@ use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
use
function
array_key_exists
;
use
function
array_keys
;
use
function
array_unshift
;
use
function
count
;
use
function
func_get_args
;
use
function
func_num_args
;
use
function
implode
;
...
...
@@ -468,7 +469,7 @@ class QueryBuilder
{
$this
->
type
=
self
::
SELECT
;
if
(
empty
(
$select
)
)
{
if
(
$select
===
null
)
{
return
$this
;
}
...
...
@@ -518,7 +519,7 @@ class QueryBuilder
{
$this
->
type
=
self
::
SELECT
;
if
(
empty
(
$select
)
)
{
if
(
$select
===
null
)
{
return
$this
;
}
...
...
@@ -890,7 +891,7 @@ class QueryBuilder
*/
public
function
groupBy
(
$groupBy
/*, string ...$groupBys*/
)
{
if
(
empty
(
$groupBy
)
)
{
if
(
is_array
(
$groupBy
)
&&
count
(
$groupBy
)
===
0
)
{
return
$this
;
}
...
...
@@ -919,7 +920,7 @@ class QueryBuilder
*/
public
function
addGroupBy
(
$groupBy
/*, string ...$groupBys*/
)
{
if
(
empty
(
$groupBy
)
)
{
if
(
is_array
(
$groupBy
)
&&
count
(
$groupBy
)
===
0
)
{
return
$this
;
}
...
...
src/Schema/Comparator.php
View file @
6c4401f4
...
...
@@ -217,7 +217,7 @@ class Comparator
// See if column has changed properties in table 2.
$changedProperties
=
$this
->
diffColumn
(
$column
,
$table2
->
getColumn
(
$columnName
));
if
(
empty
(
$changedProperties
)
)
{
if
(
count
(
$changedProperties
)
===
0
)
{
continue
;
}
...
...
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