Completed
Pull Request — master (#75)
by Deven
162:47 queued 92:52
created

SetStatement   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 49
rs 10
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
 * @package    SqlParser
7
 * @subpackage Statements
8
 */
9
namespace SqlParser\Statements;
10
11
use SqlParser\Statement;
12
use SqlParser\Components\SetOperation;
13
use SqlParser\Components\OptionsArray;
14
15
/**
16
 * `SET` statement.
17
 *
18
 * @category   Statements
19
 * @package    SqlParser
20
 * @subpackage Statements
21
 * @author     Dan Ungureanu <[email protected]>
22
 * @license    http://opensource.org/licenses/GPL-2.0 GNU Public License
23
 */
24
class SetStatement extends Statement
25
{
26
27
    /**
28
     * The clauses of this statement, in order.
29
     *
30
     * @see Statement::$CLAUSES
31
     *
32
     * @var array
33
     */
34
    public static $CLAUSES = array(
35
        'SET'                           => array('SET',         3),
36
    );
37
38
    /**
39
     * Possible exceptions in SET statment
40
     *
41
     * @var array
42
     */
43
    public static $OPTIONS = array(
44
        'CHARSET'           => array(3, 'var'),
45
        'CHARACTER SET'     => array(3, 'var'),
46
        'NAMES'             => array(3, 'var'),
47
        'PASSWORD'          => array(3, 'expr'),
48
    );
49
50
    /**
51
     * Options used in current statement
52
     *
53
     * @var OptionsArray[]
54
     */
55
    public $options;
56
57
    /**
58
     * The updated values.
59
     *
60
     * @var SetOperation[]
61
     */
62
    public $set;
63
64
    /**
65
     * @return string
66
     */
67
    public function build()
68
    {
69
        return 'SET ' . OptionsArray::build($this->options)
0 ignored issues
show
Documentation introduced by
$this->options is of type array<integer,object<Sql...mponents\OptionsArray>>, but the function expects a object<SqlParser\Components\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...
70
            . ' ' . SetOperation::build($this->set);
71
    }
72
}
73