Completed
Push — master ( 65f66e...428edc )
by Michal
04:14
created

SetStatement   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 5 1
1
<?php
2
3
/**
4
 * `SET` statement.
5
 */
6
7
namespace PhpMyAdmin\SqlParser\Statements;
8
9
use PhpMyAdmin\SqlParser\Statement;
10
use PhpMyAdmin\SqlParser\Components\SetOperation;
11
use PhpMyAdmin\SqlParser\Components\OptionsArray;
12
13
/**
14
 * `SET` statement.
15
 *
16
 * @category   Statements
17
 *
18
 * @license    https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
19
 */
20
class SetStatement extends Statement
21
{
22
    /**
23
     * The clauses of this statement, in order.
24
     *
25
     * @see Statement::$CLAUSES
26
     *
27
     * @var array
28
     */
29
    public static $CLAUSES = array(
30
        'SET' => array('SET',         3),
31
    );
32
33
    /**
34
     * Possible exceptions in SET statment.
35
     *
36
     * @var array
37
     */
38
    public static $OPTIONS = array(
39
        'CHARSET' => array(3, 'var'),
40
        'CHARACTER SET' => array(3, 'var'),
41
        'NAMES' => array(3, 'var'),
42
        'PASSWORD' => array(3, 'expr'),
43
    );
44
45
    /**
46
     * Options used in current statement.
47
     *
48
     * @var OptionsArray[]
49
     */
50
    public $options;
51
52
    /**
53
     * The updated values.
54
     *
55
     * @var SetOperation[]
56
     */
57
    public $set;
58
59
    /**
60
     * @return string
61
     */
62 1
    public function build()
63
    {
64 1
        return 'SET ' . OptionsArray::build($this->options)
0 ignored issues
show
Documentation introduced by
$this->options is of type array<integer,object<Php...mponents\OptionsArray>>, but the function expects a object<PhpMyAdmin\SqlPar...omponents\OptionsArray>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
65 1
            . ' ' . SetOperation::build($this->set);
66
    }
67
}
68