Skip to content

Commit

Permalink
phpstan to level 6
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson committed Feb 21, 2024
1 parent 4ca865e commit 75d462f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 24 deletions.
3 changes: 1 addition & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
includes:
- phpstan-baseline.neon
parameters:
level: 1
level: 6
paths:
- src
- tests
bootstrapFiles:
- stan_autoload.php
5 changes: 3 additions & 2 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class QueryBuilder extends \soluto\plugin\Widget {
public $pluginName = 'queryBuilder';

/**
* @return string[]
* @inheritdoc
*/
protected function assets()
protected function assets() : array
{
return [
QueryBuilderAsset::className()
QueryBuilderAsset::class
];
}

Expand Down
9 changes: 9 additions & 0 deletions src/QueryBuilderAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@ class QueryBuilderAsset extends AssetBundle {

public $sourcePath = '@bower/jquery-querybuilder/dist';

/**
* @var string[]
*/
public $js = [
'js/query-builder.standalone.js',
];

/**
* @var string[]
*/
public $css = [
'css/query-builder.default.css',
];

/**
* @var string[]
*/
public $depends = [
'yii\web\JqueryAsset'
];
Expand Down
10 changes: 5 additions & 5 deletions src/QueryBuilderForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
class QueryBuilderForm extends Widget
{
/**
* @param array|string $action the form action URL. This parameter will be processed by [[\yii\helpers\Url::to()]].
* @var array<mixed>|string $action the form action URL. This parameter will be processed by [[\yii\helpers\Url::to()]].
* @see method for specifying the HTTP method for this form.
*/
public $action = [''];
public array|string $action = [''];

/**
* @var string the form submission method. This should be either 'post' or 'get'. Defaults to 'get'.
Expand All @@ -59,7 +59,7 @@ class QueryBuilderForm extends Widget
public $method = 'get';

/**
* @var array the HTML attributes (name-value pairs) for the form tag.
* @var array<mixed> the HTML attributes (name-value pairs) for the form tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = [];
Expand All @@ -70,7 +70,7 @@ class QueryBuilderForm extends Widget
public $rulesParam = 'rules';

/**
* @var array|QueryBuilder QueryBuilder column configuration.
* @var array<mixed>|QueryBuilder QueryBuilder column configuration.
* For example,
*
* ```php
Expand All @@ -96,7 +96,7 @@ class QueryBuilderForm extends Widget
/**
* @inheritdoc
*/
public function init()
public function init() : void
{
if (is_array($this->builder)) {
$this->builder = Yii::createObject(array_merge([
Expand Down
33 changes: 19 additions & 14 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,24 @@
*/
class Translator extends BaseObject
{
private $_where;
private $_params = [];
private $_operators;
private string $_where;

/** @var array<string, mixed> */
private array $_params = [];

/** @var array<string, mixed> */
private array $_operators;

/**
* @var array The params from yii\db\Query object that are already set so we don't overwrite them
* @var array<string, mixed> The params from yii\db\Query object that are already set so we don't overwrite them
* @deprecated
*/
private $currentParams = [];
private array $currentParams = [];

/**
* Constructors.
* @param array $data Rules configuraion
* @param array $config the configuration array to be applied to this object.
* @param array<mixed> $data Rules configuraion
* @param array<string, mixed> $config the configuration array to be applied to this object.
*/
public function __construct($data, $config = [])
{
Expand All @@ -64,7 +69,7 @@ public function __construct($data, $config = [])
/**
* @inheritdoc
*/
public function init()
public function init() : void
{
$this->_operators = [
'equal' => '= ?',
Expand Down Expand Up @@ -94,8 +99,8 @@ public function init()
/**
* 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|array<mixed> $type operator type
* @param string|array<string, mixed> $params query parameters
* @return string encoded rule
*/
protected function encodeRule($field, $type, $params)
Expand Down Expand Up @@ -124,7 +129,7 @@ protected function encodeRule($field, $type, $params)
}

/**
* @param array $data rules configuration
* @param array<mixed> $data rules configuration
* @return string the WHERE clause
*/
protected function buildWhere($data)
Expand Down Expand Up @@ -172,7 +177,7 @@ public function where()

/**
* Returns the parameters to be bound to the query.
* @return array
* @return array<string,mixed>
*/
public function params()
{
Expand All @@ -190,10 +195,10 @@ private function getNewParamName(){

/**
*
* @param array $currentParams
* @param array<string, mixed> $currentParams
* @deprecated
*/
public function setCurrentParams($currentParams) {
public function setCurrentParams($currentParams) : void {
$this->currentParams = $currentParams;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


use yii\base\BaseObject;
use yii\web\JsExpression;

/**
* The validation object representation
Expand Down Expand Up @@ -43,7 +44,7 @@ class Validation extends BaseObject
public $step;

/**
* @var yii\web\JsExpression A function used to perform the validation.
* @var JsExpression A function used to perform the validation.
* If provided, the default validation will not be performed. It must returns true if the value is valid
* or an error string otherwise. It takes 4 parameters:
* value
Expand Down

0 comments on commit 75d462f

Please sign in to comment.