From d6ee59d811f1623018f09e50869f7a31b7a62c5e Mon Sep 17 00:00:00 2001 From: Dylan Ferris Date: Mon, 4 Dec 2017 23:25:13 -0500 Subject: [PATCH] Fix warning in PHP 7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a warning in PHP 7.2 from doing `count(null)`: > PHP Warning – yii\base\ErrorException > > count(): Parameter must be an array or an object that implements Countable > 1. in /vendor/yiidoc/yii2-selectize/Selectize.php at line 84 --- Selectize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Selectize.php b/Selectize.php index 2d20065..842423e 100644 --- a/Selectize.php +++ b/Selectize.php @@ -81,7 +81,7 @@ public function registerJs() if (!isset($this->clientOptions['create']) && empty($this->items)) { $this->clientOptions['create'] = "function(input) { return { value: input, text: input };}"; } - $clientOptions = (count($this->clientOptions)) ? Json::encode($this->clientOptions) : ''; + $clientOptions = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); $this->getView()->registerJs("jQuery('#{$this->options['id']}').selectize({$clientOptions});"); }