Avoid PhpStorm inspection for $value{0} on empty string (prevent E_NOTICE)

Here, $value is not empty, but the PhpStorm inspection doesn't get that.
I want to have zero warnings for this library.
This commit is contained in:
Fonata
2019-09-14 01:18:29 +02:00
parent f89ed5978d
commit 5ca540daa7

View File

@@ -1103,7 +1103,7 @@ class Csv {
: '';
$enclosure_quoted = preg_quote($this->enclosure, '/');
$pattern = "/" . $delimiter_quoted . $enclosure_quoted . "|\n|\r/i";
if ($this->enclose_all || preg_match($pattern, $value) || ($value{0} == ' ' || substr($value, -1) == ' ')) {
if ($this->enclose_all || preg_match($pattern, $value) || (strpos($value, ' ') === 0 || substr($value, -1) == ' ')) {
$value = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $value);
$value = $this->enclosure . $value . $this->enclosure;
}