Fix deprecation warnings coming from pQuery library
[MAILPOET-3980]
This commit is contained in:
committed by
Veljko V
parent
539f518f64
commit
df6a955f0c
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace MailPoet\Util\pQuery;
|
||||
|
||||
class DomNode extends \pQuery\DomNode {
|
||||
public $childClass = 'MailPoet\Util\pQuery\DomNode';
|
||||
use MailPoetVendor\pQuery\DomNode as pQueryDomNode;
|
||||
|
||||
class DomNode extends pQueryDomNode {
|
||||
public $childClass = DomNode::class;
|
||||
public $parserClass = Html5Parser::class;
|
||||
|
||||
public function getInnerText() {
|
||||
return html_entity_decode($this->toString(true, true, 1), ENT_NOQUOTES, 'UTF-8');
|
||||
@@ -12,4 +15,10 @@ class DomNode extends \pQuery\DomNode {
|
||||
public function getOuterText() {
|
||||
return html_entity_decode($this->toString(), ENT_NOQUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
public function query($query = '*') {
|
||||
$select = $this->select($query);
|
||||
$result = new pQuery((array)$select);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace MailPoet\Util\pQuery;
|
||||
|
||||
class Html5Parser extends \pQuery\HtmlParser {
|
||||
/** @var string|\pQuery\DomNode */
|
||||
public $root = 'MailPoet\Util\pQuery\DomNode';
|
||||
use MailPoetVendor\pQuery\HtmlParser;
|
||||
|
||||
class Html5Parser extends HtmlParser {
|
||||
/** @var string|DomNode */
|
||||
public $root = DomNode::class;
|
||||
}
|
||||
|
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace MailPoet\Util\pQuery;
|
||||
|
||||
use MailPoetVendor\pQuery\pQuery as pQuerypQuery;
|
||||
|
||||
// extend pQuery class to use UTF-8 encoding when getting elements' inner/outer text
|
||||
// phpcs:ignore Squiz.Classes.ValidClassName
|
||||
class pQuery extends \pQuery {
|
||||
public static function parseStr($html) {
|
||||
class pQuery extends pQuerypQuery {
|
||||
public static function parseStr($html): DomNode {
|
||||
$parser = new Html5Parser($html);
|
||||
|
||||
if (!$parser->root instanceof \pQuery\DomNode) {
|
||||
if (!$parser->root instanceof DomNode) {
|
||||
// this condition shouldn't happen it is here only for PHPStan
|
||||
throw new \Exception('Renderer is not configured correctly');
|
||||
}
|
||||
|
Reference in New Issue
Block a user