Completed
Pull Request — master (#15643)
by Dmitry
10:34
created

QueryExpressionBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 19
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 6 1
1
<?php
2
3
namespace yii\db;
4
5
/**
6
 * Class QueryExpressionBuilder is used internally to build [[Query]] object
7
 * using unified [[QueryBuilder]] expression building interface.
8
 *
9
 * @author Dmytro Naumenko <[email protected]>
10
 * @since 2.0.14
11
 */
12
class QueryExpressionBuilder implements ExpressionBuilderInterface
13
{
14
    use ExpressionBuilderTrait;
15
16
    /**
17
     * Method builds the raw SQL from the $expression that will not be additionally
18
     * escaped or quoted.
19
     *
20
     * @param ExpressionInterface|Query $expression the expression to be built.
21
     * @param array $params the binding parameters.
22
     * @return string the raw SQL that will not be additionally escaped or quoted.
23
     */
24 50
    public function build(ExpressionInterface $expression, array &$params = [])
25
    {
26 50
        list($sql, $params) = $this->queryBuilder->build($expression, $params);
0 ignored issues
show
Compatibility introduced by
$expression of type object<yii\db\ExpressionInterface> is not a sub-type of object<yii\db\Query>. It seems like you assume a concrete implementation of the interface yii\db\ExpressionInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
27
28 50
        return "($sql)";
29
    }
30
}
31