i have string of html which i want to explode by <br>
, but sometimes it can be inside of other tags.
if (in_array($param, $customOrdering, true) && $value) {
$ordering = array_search($param, $customOrdering, true);
$segments[$ordering] = [];
if (in_array($param, $explodeParams, true)) {
$values = explode('<br>', $value);
foreach ($values as $v) {
$testing_value = $v;
if (!empty(trim(strip_tags($testing_value)))) {
array_push($segments[$ordering], $this->createSegmentFromParam($param, $v));
138 } elseif (!empty(trim($v)) && $segments[$ordering]) {
139 end($segments[$ordering])->value_raw .= strip_tags($v, $this->allowedTags);
}
}
} else {
array_push($segments[$ordering], $this->createSegmentFromParam($param, $value));
}
}
declaration of createSegmentFormParam
@return ArrayHash
private function createSegmentFromParam($param, $value)
and i have this output from phpStan
138 Right side of && is always false.
139 Cannot access property $value_raw on false.
any ideas how to pass on ? code working well
There is still an open issue for similar behaviour or PHP Stan - False negative with array_push on property
Try not using array_push
and replace it on line 138
with the following:
$segments[$ordering][] = $this->createSegmentFromParam($param, $v);
Apart from this in the beginning of your code array_search
may return FALSE
you do want to check this before going further down the code...