Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/5408' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
8 changes: 2 additions & 6 deletions src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
namespace Zend\Dom;

use DOMDocument;
use DOMXPath;
use Zend\Dom\Document;
use Zend\Dom\Exception;
use Zend\Stdlib\ErrorHandler;

/**
* Class used to initialize DomDocument from string, with proper verifications
Expand Down Expand Up @@ -147,8 +143,8 @@ protected function setType($type)
/**
* Get DOMDocument generated from set raw document
*
* @return string|null
* @throws Exception\RuntimeException
* @return DOMDocument
* @throws Exception\RuntimeException If cannot get DOMDocument; no document registered
*/
public function getDomDocument()
{
Expand Down
4 changes: 3 additions & 1 deletion src/Document/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class Query
/**
* Perform the query on Document
*
* @param Document $document
* @param string $expression CSS selector or XPath query
* @param Document $document Document to query
* @param string $type The type of $expression
* @return NodeList
*/
public static function execute($expression, Document $document, $type = self::TYPE_XPATH)
Expand Down
10 changes: 5 additions & 5 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use DOMDocument;
use DOMXPath;
use ErrorException;
use Zend\Stdlib\ErrorHandler;

/**
Expand Down Expand Up @@ -212,7 +213,7 @@ public function getDocumentErrors()
*/
public function execute($query)
{
$xpathQuery = Css2Xpath::transform($query);
$xpathQuery = Document\Query::cssToXpath($query);
return $this->queryXpath($xpathQuery, $query);
}

Expand Down Expand Up @@ -300,6 +301,7 @@ public function registerXpathPhpFunctions($xpathPhpFunctions = true)
* @param DOMDocument $document
* @param string|array $xpathQuery
* @return array
* @throws ErrorException If query cannot be executed
*/
protected function getNodeList($document, $xpathQuery)
{
Expand All @@ -317,10 +319,8 @@ protected function getNodeList($document, $xpathQuery)

ErrorHandler::start();
$nodeList = $xpath->query($xpathQuery);
$error = ErrorHandler::stop();
if ($error) {
throw $error;
}
ErrorHandler::stop(true);

return $nodeList;
}
}
6 changes: 3 additions & 3 deletions test/Css2XpathTest.php → test/Document/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Dom;
namespace ZendTest\Dom\Document;

use Zend\Dom\Document\Query;

/**
* Test class for Css2Xpath.
* Test class for Zend\Dom\Document\Query.
*
* @group Zend_Dom
*/
class Css2XpathTest extends \PHPUnit_Framework_TestCase
class QueryTest extends \PHPUnit_Framework_TestCase
{
public function testTransformShouldBeCalledStatically()
{
Expand Down

0 comments on commit 05f12a3

Please sign in to comment.