diff --git a/phpstan.neon b/phpstan.neon index dcfd312..2c1409d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ includes: - phpstan-baseline.neon parameters: - level: 6 + level: 8 paths: - src bootstrapFiles: diff --git a/src/QueryBuilderForm.php b/src/QueryBuilderForm.php index 4713201..c26fd73 100644 --- a/src/QueryBuilderForm.php +++ b/src/QueryBuilderForm.php @@ -99,10 +99,11 @@ class QueryBuilderForm extends Widget public function init() : void { if (is_array($this->builder)) { - $this->builder = Yii::createObject(array_merge([ - 'class' => QueryBuilder::className() - ], $this->builder) - ); + /** @var QueryBuilder $builder */ + $builder = Yii::createObject(array_merge([ + 'class' => QueryBuilder::class + ], $this->builder)); + $this->builder = $builder; } if (!$this->builder instanceof QueryBuilder) { @@ -125,7 +126,11 @@ public function run() { echo Html::endForm(); + /** @var string $id */ $id = $this->options['id']; + if(!$this->builder instanceof QueryBuilder) { + throw new InvalidConfigException("Builder needs to be builder object"); + } $builderId = $this->builder->getId(); $view = $this->getView(); diff --git a/src/Translator.php b/src/Translator.php index d665af5..59c12c9 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -99,11 +99,11 @@ public function init() : void /** * Encodes filter rule into SQL condition * @param string $field field name - * @param string|array $type operator type - * @param string|array $params query parameters + * @param string $type operator type + * @param array $params query parameters * @return string encoded rule */ - protected function encodeRule($field, $type, $params) + protected function encodeRule(string $field, string $type, array $params) { $pattern = $this->_operators[$type]; $keys = array_keys($params);