Issues (377)

controls/php/class-kirki-control-select.php (1 issue)

1
<?php
2
/**
3
 * Customizer Control: kirki-select.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license    https://opensource.org/licenses/MIT
9
 * @since       1.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Select control.
19
 */
20
class Kirki_Control_Select extends Kirki_Control_Base {
21
22
	/**
23
	 * The control type.
24
	 *
25
	 * @access public
26
	 * @var string
27
	 */
28
	public $type = 'kirki-select';
29
30
	/**
31
	 * Placeholder text.
32
	 *
33
	 * @access public
34
	 * @since 3.0.21
35
	 * @var string|false
36
	 */
37
	public $placeholder = false;
38
39
	/**
40
	 * Maximum number of options the user will be able to select.
41
	 * Set to 1 for single-select.
42
	 *
43
	 * @access public
44
	 * @var int
45
	 */
46
	public $multiple = 1;
47
48
	/**
49
	 * Refresh the parameters passed to the JavaScript via JSON.
50
	 *
51
	 * @see WP_Customize_Control::to_json()
52
	 */
53
	public function to_json() {
54
		parent::to_json();
55
		$this->json['multiple']    = $this->multiple;
56
		$this->json['placeholder'] = $this->placeholder;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->placeholder can also be of type boolean. However, the property $placeholder is declared as type false|string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
57
	}
58
}
59