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
8b03048c
Unverified
Commit
8b03048c
authored
May 30, 2019
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3574 from jwage/query-types
Add proper types to Doctrine\DBAL\Query namespace.
parents
8d7874f5
598bcfd7
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
160 deletions
+97
-160
CompositeExpression.php
lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php
+10
-16
ExpressionBuilder.php
lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
+16
-46
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+71
-98
No files found.
lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php
View file @
8b03048c
...
...
@@ -41,7 +41,7 @@ class CompositeExpression implements Countable
* @param string $type Instance type of composite expression.
* @param self[]|string[] $parts Composition of expressions to be joined on composite expression.
*/
public
function
__construct
(
$type
,
array
$parts
=
[])
public
function
__construct
(
string
$type
,
array
$parts
=
[])
{
$this
->
type
=
$type
;
...
...
@@ -51,11 +51,11 @@ class CompositeExpression implements Countable
/**
* Adds multiple parts to composite expression.
*
* @param
self[]|string[]
$parts
* @param
array<int, self|string>
$parts
*
* @return
\Doctrine\DBAL\Query\Expression\CompositeExpression
* @return
$this
*/
public
function
addMultiple
(
array
$parts
=
[])
public
function
addMultiple
(
array
$parts
=
[])
:
self
{
foreach
(
$parts
as
$part
)
{
$this
->
add
(
$part
);
...
...
@@ -67,11 +67,11 @@ class CompositeExpression implements Countable
/**
* Adds an expression to composite expression.
*
* @param
mixed
$part
* @param
self|string
$part
*
* @return
\Doctrine\DBAL\Query\Expression\CompositeExpression
* @return
$this
*/
public
function
add
(
$part
)
public
function
add
(
$part
)
:
self
{
if
(
empty
(
$part
))
{
return
$this
;
...
...
@@ -88,20 +88,16 @@ class CompositeExpression implements Countable
/**
* Retrieves the amount of expressions on composite expression.
*
* @return int
*/
public
function
count
()
public
function
count
()
:
int
{
return
count
(
$this
->
parts
);
}
/**
* Retrieves the string representation of this composite expression.
*
* @return string
*/
public
function
__toString
()
public
function
__toString
()
:
string
{
if
(
$this
->
count
()
===
1
)
{
return
(
string
)
$this
->
parts
[
0
];
...
...
@@ -112,10 +108,8 @@ class CompositeExpression implements Countable
/**
* Returns the type of this composite expression (AND/OR).
*
* @return string
*/
public
function
getType
()
public
function
getType
()
:
string
{
return
$this
->
type
;
}
...
...
lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
View file @
8b03048c
...
...
@@ -51,10 +51,8 @@ class ExpressionBuilder
*
* @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return CompositeExpression
*/
public
function
andX
(
$x
=
null
)
public
function
andX
(
$x
=
null
)
:
CompositeExpression
{
return
new
CompositeExpression
(
CompositeExpression
::
TYPE_AND
,
func_get_args
());
}
...
...
@@ -70,10 +68,8 @@ class ExpressionBuilder
*
* @param mixed $x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return CompositeExpression
*/
public
function
orX
(
$x
=
null
)
public
function
orX
(
$x
=
null
)
:
CompositeExpression
{
return
new
CompositeExpression
(
CompositeExpression
::
TYPE_OR
,
func_get_args
());
}
...
...
@@ -84,10 +80,8 @@ class ExpressionBuilder
* @param mixed $x The left expression.
* @param string $operator One of the ExpressionBuilder::* constants.
* @param mixed $y The right expression.
*
* @return string
*/
public
function
comparison
(
$x
,
$operator
,
$y
)
public
function
comparison
(
$x
,
string
$operator
,
$y
)
:
string
{
return
$x
.
' '
.
$operator
.
' '
.
$y
;
}
...
...
@@ -104,10 +98,8 @@ class ExpressionBuilder
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public
function
eq
(
$x
,
$y
)
public
function
eq
(
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
self
::
EQ
,
$y
);
}
...
...
@@ -123,10 +115,8 @@ class ExpressionBuilder
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public
function
neq
(
$x
,
$y
)
public
function
neq
(
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
self
::
NEQ
,
$y
);
}
...
...
@@ -142,10 +132,8 @@ class ExpressionBuilder
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public
function
lt
(
$x
,
$y
)
public
function
lt
(
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
self
::
LT
,
$y
);
}
...
...
@@ -161,10 +149,8 @@ class ExpressionBuilder
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public
function
lte
(
$x
,
$y
)
public
function
lte
(
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
self
::
LTE
,
$y
);
}
...
...
@@ -180,10 +166,8 @@ class ExpressionBuilder
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public
function
gt
(
$x
,
$y
)
public
function
gt
(
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
self
::
GT
,
$y
);
}
...
...
@@ -199,10 +183,8 @@ class ExpressionBuilder
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
*
* @return string
*/
public
function
gte
(
$x
,
$y
)
public
function
gte
(
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
self
::
GTE
,
$y
);
}
...
...
@@ -211,10 +193,8 @@ class ExpressionBuilder
* Creates an IS NULL expression with the given arguments.
*
* @param string $x The field in string format to be restricted by IS NULL.
*
* @return string
*/
public
function
isNull
(
$x
)
public
function
isNull
(
string
$x
)
:
string
{
return
$x
.
' IS NULL'
;
}
...
...
@@ -223,10 +203,8 @@ class ExpressionBuilder
* Creates an IS NOT NULL expression with the given arguments.
*
* @param string $x The field in string format to be restricted by IS NOT NULL.
*
* @return string
*/
public
function
isNotNull
(
$x
)
public
function
isNotNull
(
string
$x
)
:
string
{
return
$x
.
' IS NOT NULL'
;
}
...
...
@@ -236,10 +214,8 @@ class ExpressionBuilder
*
* @param string $x Field in string format to be inspected by LIKE() comparison.
* @param mixed $y Argument to be used in LIKE() comparison.
*
* @return string
*/
public
function
like
(
$x
,
$y
/*, ?string $escapeChar = null */
)
public
function
like
(
string
$x
,
$y
/*, ?string $escapeChar = null */
)
:
string
{
return
$this
->
comparison
(
$x
,
'LIKE'
,
$y
)
.
(
func_num_args
()
>=
3
?
sprintf
(
' ESCAPE %s'
,
func_get_arg
(
2
))
:
''
);
...
...
@@ -250,10 +226,8 @@ class ExpressionBuilder
*
* @param string $x Field in string format to be inspected by NOT LIKE() comparison.
* @param mixed $y Argument to be used in NOT LIKE() comparison.
*
* @return string
*/
public
function
notLike
(
$x
,
$y
/*, ?string $escapeChar = null */
)
public
function
notLike
(
string
$x
,
$y
/*, ?string $escapeChar = null */
)
:
string
{
return
$this
->
comparison
(
$x
,
'NOT LIKE'
,
$y
)
.
(
func_num_args
()
>=
3
?
sprintf
(
' ESCAPE %s'
,
func_get_arg
(
2
))
:
''
);
...
...
@@ -264,10 +238,8 @@ class ExpressionBuilder
*
* @param string $x The field in string format to be inspected by IN() comparison.
* @param string|string[] $y The placeholder or the array of values to be used by IN() comparison.
*
* @return string
*/
public
function
in
(
$x
,
$y
)
public
function
in
(
string
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
'IN'
,
'('
.
implode
(
', '
,
(
array
)
$y
)
.
')'
);
}
...
...
@@ -277,10 +249,8 @@ class ExpressionBuilder
*
* @param string $x The field in string format to be inspected by NOT IN() comparison.
* @param string|string[] $y The placeholder or the array of values to be used by NOT IN() comparison.
*
* @return string
*/
public
function
notIn
(
$x
,
$y
)
public
function
notIn
(
string
$x
,
$y
)
:
string
{
return
$this
->
comparison
(
$x
,
'NOT IN'
,
'('
.
implode
(
', '
,
(
array
)
$y
)
.
')'
);
}
...
...
@@ -288,7 +258,7 @@ class ExpressionBuilder
/**
* Creates an SQL literal expression from the string.
*/
public
function
literal
(
string
$input
)
public
function
literal
(
string
$input
)
:
string
{
return
$this
->
connection
->
quote
(
$input
);
}
...
...
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
8b03048c
This diff is collapsed.
Click to expand it.
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