Skip to content

Commit 31cc1af

Browse files
authored
Merge pull request #119 from iansltx/php82
Clean up PHP 8.2 compatibility, duplicated test run
2 parents 15bd0a1 + 030d1c6 commit 31cc1af

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Html2Text.php

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

355-
$text = trim($this->html);
355+
$text = trim($this->html ?? '');
356356

357357
$this->converter($text);
358358

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

392392
// remove leading empty lines (can be produced by eg. P tag on the beginning)
393-
$text = ltrim($text, "\n");
393+
$text = ltrim($text ?? '', "\n");
394394

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

test/ImageTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class ImageTest extends TestCase
88
{
9-
public function testImageDataProvider() {
9+
public function imageDataProvider() {
1010
return array(
1111
'Without alt tag' => array(
1212
'html' => '<img src="http://example.com/example.jpg">',
@@ -36,7 +36,7 @@ public function testImageDataProvider() {
3636
}
3737

3838
/**
39-
* @dataProvider testImageDataProvider
39+
* @dataProvider imageDataProvider
4040
*/
4141
public function testImages($html, $expected)
4242
{

test/PrintTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class PrintTest extends TestCase
1111

1212
public function testP()
1313
{
14-
$this->html = new Html2Text(self::TEST_HTML);
15-
$this->html->p();
14+
$html = new Html2Text(self::TEST_HTML);
15+
$html->p();
1616
$this->expectOutputString(self::EXPECTED);
1717
}
1818

1919
public function testPrint_text()
2020
{
21-
$this->html = new Html2Text(self::TEST_HTML);
22-
$this->html->print_text();
21+
$html = new Html2Text(self::TEST_HTML);
22+
$html->print_text();
2323
$this->expectOutputString(self::EXPECTED);
2424
}
2525
}

0 commit comments

Comments
 (0)