Skip to content

Commit

Permalink
Merge pull request #119 from iansltx/php82
Browse files Browse the repository at this point in the history
Clean up PHP 8.2 compatibility, duplicated test run
  • Loading branch information
andrewnicols committed Aug 20, 2024
2 parents 15bd0a1 + 030d1c6 commit 31cc1af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Html2Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ protected function doConvert()
{
$this->linkList = array();

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

$this->converter($text);

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

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

if ($this->options['width'] > 0) {
$text = wordwrap($text, $this->options['width']);
Expand Down
4 changes: 2 additions & 2 deletions test/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ImageTest extends TestCase
{
public function testImageDataProvider() {
public function imageDataProvider() {
return array(
'Without alt tag' => array(
'html' => '<img src="http://example.com/example.jpg">',
Expand Down Expand Up @@ -36,7 +36,7 @@ public function testImageDataProvider() {
}

/**
* @dataProvider testImageDataProvider
* @dataProvider imageDataProvider
*/
public function testImages($html, $expected)
{
Expand Down
8 changes: 4 additions & 4 deletions test/PrintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class PrintTest extends TestCase

public function testP()
{
$this->html = new Html2Text(self::TEST_HTML);
$this->html->p();
$html = new Html2Text(self::TEST_HTML);
$html->p();
$this->expectOutputString(self::EXPECTED);
}

public function testPrint_text()
{
$this->html = new Html2Text(self::TEST_HTML);
$this->html->print_text();
$html = new Html2Text(self::TEST_HTML);
$html->print_text();
$this->expectOutputString(self::EXPECTED);
}
}

0 comments on commit 31cc1af

Please sign in to comment.