06.08.2022 07:08:59 am
Перешел на PHP 8.1.6 и вот ошибка, после перехода: ord(): Passing null to parameter #1 ($character) of type string is deprecated. Понят, что передавать null первым параметром - это устаревший подход, но как его решить?
Ошибка указывает на строку:
В методе:
На всякий случай, метод
Решение подсказали на Хабре: заменить строчку:
На:
После замены строки, ошибка больше не появлялась.
Ошибка указывает на строку:
if (ord($get) <= self::ORD_LF) { // EOL reached
В методе:
protected function singleLineComment()
{
$comment = '';
while (true) {
$get = $this->get();
$comment .= $get;
if (ord($get) <= self::ORD_LF) { // EOL reached
// if IE conditional comment
if (preg_match('/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
return "/{$comment}";
}
return $get;
}
}
}
На всякий случай, метод
get
:
protected function get()
{
$c = $this->lookAhead;
$this->lookAhead = null;
if ($c === null) {
if ($this->inputIndex < $this->inputLength) {
$c = $this->input[$this->inputIndex];
$this->inputIndex += 1;
} else {
return null;
}
}
if ($c === "\r" | $c === "\n") {
return "\n";
}
if (ord($c) < self::ORD_SPACE) { // control char
return ' ';
}
return $c;
}
$get = $this->get();
На:
$get = $this->get() ?? "\x00";
После замены строки, ошибка больше не появлялась.
- Жалоба