Skip to content

Commit f5066a5

Browse files
authored
Merge pull request #124 from andrewnicols/php54fix
Remove php8 nullsafe operator
2 parents 31cc1af + 406933c commit f5066a5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Html2Text.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ protected function doConvert()
352352
{
353353
$this->linkList = array();
354354

355-
$text = trim($this->html ?? '');
355+
if ($this->html === null) {
356+
$text = '';
357+
} else {
358+
$text = trim($this->html);
359+
}
356360

357361
$this->converter($text);
358362

@@ -390,7 +394,10 @@ protected function converter(&$text)
390394
$text = preg_replace("/[\n]{3,}/", "\n\n", $text);
391395

392396
// remove leading empty lines (can be produced by eg. P tag on the beginning)
393-
$text = ltrim($text ?? '', "\n");
397+
if ($text === null) {
398+
$text = '';
399+
}
400+
$text = ltrim($text, "\n");
394401

395402
if ($this->options['width'] > 0) {
396403
$text = wordwrap($text, $this->options['width']);

0 commit comments

Comments
 (0)