Miscellaneous fixes, mostly undefined variables (#14432)

* Miscellaneous fixes, mostly undefined variables

* Update phpstan-baseline.neon
This commit is contained in:
Jellyfrog
2022-10-11 11:30:00 +02:00
committed by GitHub
parent 071173ffb9
commit be1a2cec50
23 changed files with 50 additions and 38 deletions

View File

@@ -140,7 +140,7 @@ class QueryBuilderFluentParser extends QueryBuilderParser
$op = $rule['operator'];
$value = $rule['value'];
if (! is_array($value) && Str::startsWith($value, '`') && Str::endsWith($value, '`')) {
if (! is_array($value) && is_string($value) && Str::startsWith($value, '`') && Str::endsWith($value, '`')) {
$value = DB::raw($this->expandMacro(trim($value, '`')));
}

View File

@@ -171,8 +171,12 @@ class QueryBuilderParser implements \JsonSerializable
$split = array_chunk(preg_split('/(&&|\|\|)/', $query, -1, PREG_SPLIT_DELIM_CAPTURE), 2);
foreach ($split as $chunk) {
if (count($chunk) < 2 && empty($chunk[0])) {
continue; // likely the ending && or ||
if (count($chunk) < 2) {
if (empty($chunk[0])) {
continue; // likely the ending && or ||
}
$chunk[1] = '';
}
@[$rule_text, $rule_operator] = $chunk;
@@ -181,8 +185,11 @@ class QueryBuilderParser implements \JsonSerializable
$condition = ($rule_operator == '||' ? 'OR' : 'AND');
}
@[$field, $op, $value] = preg_split('/ *([!=<>~]{1,2}) */', trim($rule_text), 2, PREG_SPLIT_DELIM_CAPTURE);
$field = ltrim($field, '%');
$rule_split = preg_split('/ *([!=<>~]{1,2}) */', trim($rule_text), 2, PREG_SPLIT_DELIM_CAPTURE);
$field = ltrim($rule_split[0], '%');
$op = $rule_split[1] ?? null;
$value = $rule_split[2] ?? null;
// for rules missing values just use '= 1'
$operator = isset(self::$legacy_operators[$op]) ? self::$legacy_operators[$op] : 'equal';