Fix PHPStan parameter type error introduced after update to version 0.12.83
This commit fixes the following PHPStan errors introduced after the update to version 0.12.83: ``` ------ ---------------------------------------------------------------------- Line lib/Newsletter/Renderer/Blocks/Footer.php ------ ---------------------------------------------------------------------- 18 Parameter #1 $html of method MailPoet\Util\pQuery\pQuery::parseStr() expects string, array|string|null given. ------ ---------------------------------------------------------------------- ------ ---------------------------------------------------------------------- Line lib/Newsletter/Renderer/Blocks/Header.php ------ ---------------------------------------------------------------------- 18 Parameter #1 $html of method MailPoet\Util\pQuery\pQuery::parseStr() expects string, array|string|null given. ------ ---------------------------------------------------------------------- ``` [MAILPOET-3491]
This commit is contained in:
@ -14,6 +14,9 @@ class Footer {
|
|||||||
$lineHeight = sprintf(
|
$lineHeight = sprintf(
|
||||||
'%spx', StylesHelper::$defaultLineHeight * (int)$element['styles']['text']['fontSize']
|
'%spx', StylesHelper::$defaultLineHeight * (int)$element['styles']['text']['fontSize']
|
||||||
);
|
);
|
||||||
|
if (!is_string($element['text'])) {
|
||||||
|
throw new \RuntimeException('$element[\'text\'] should be a string.');
|
||||||
|
}
|
||||||
$dOMParser = new pQuery();
|
$dOMParser = new pQuery();
|
||||||
$DOM = $dOMParser->parseStr($element['text']);
|
$DOM = $dOMParser->parseStr($element['text']);
|
||||||
if (isset($element['styles']['link'])) {
|
if (isset($element['styles']['link'])) {
|
||||||
|
@ -14,6 +14,9 @@ class Header {
|
|||||||
$lineHeight = sprintf(
|
$lineHeight = sprintf(
|
||||||
'%spx', StylesHelper::$defaultLineHeight * (int)$element['styles']['text']['fontSize']
|
'%spx', StylesHelper::$defaultLineHeight * (int)$element['styles']['text']['fontSize']
|
||||||
);
|
);
|
||||||
|
if (!is_string($element['text'])) {
|
||||||
|
throw new \RuntimeException('$element[\'text\'] should be a string.');
|
||||||
|
}
|
||||||
$dOMParser = new pQuery();
|
$dOMParser = new pQuery();
|
||||||
$DOM = $dOMParser->parseStr($element['text']);
|
$DOM = $dOMParser->parseStr($element['text']);
|
||||||
if (isset($element['styles']['link'])) {
|
if (isset($element['styles']['link'])) {
|
||||||
|
@ -52,4 +52,10 @@ class FooterTest extends \MailPoetUnitTest {
|
|||||||
$output = (new Footer)->render($this->block);
|
$output = (new Footer)->render($this->block);
|
||||||
expect($output)->stringContainsString('<a href="http://example.com" style="color:#aaaaaa;text-decoration:none">link</a>');
|
expect($output)->stringContainsString('<a href="http://example.com" style="color:#aaaaaa;text-decoration:none">link</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItRaisesExceptionIfTextIsNotString() {
|
||||||
|
$this->block['text'] = ['some', 'array'];
|
||||||
|
$this->expectException('RuntimeException');
|
||||||
|
(new Footer)->render($this->block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,10 @@ class HeaderTest extends \MailPoetUnitTest {
|
|||||||
$output = (new Footer)->render($this->block);
|
$output = (new Footer)->render($this->block);
|
||||||
expect($output)->stringContainsString('<a href="http://example.com" style="color:#aaaaaa;text-decoration:underline">link</a>');
|
expect($output)->stringContainsString('<a href="http://example.com" style="color:#aaaaaa;text-decoration:underline">link</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItRaisesExceptionIfTextIsNotString() {
|
||||||
|
$this->block['text'] = ['some', 'array'];
|
||||||
|
$this->expectException('RuntimeException');
|
||||||
|
(new Header)->render($this->block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user