Skip to content

Commit f295e1c

Browse files
author
Christoph Singer
committed
get rid of deprecated getFirstNode calls
1 parent 6142fa6 commit f295e1c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/HtmlPage.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function removeMeta($name)
153153
*/
154154
public function getMeta($name)
155155
{
156-
$node = $this->filterXPath('descendant-or-self::meta[@name = \'' . $name . '\']')->getFirstNode();
156+
$node = $this->filterXPath('descendant-or-self::meta[@name = \'' . $name . '\']')->getNode(0);
157157
if ($node instanceof \DOMElement) {
158158
return $node->getAttribute('content');
159159
} else {
@@ -168,7 +168,7 @@ public function getMeta($name)
168168
*/
169169
public function setBaseHref($url)
170170
{
171-
$node = $this->filterXPath('descendant-or-self::base')->getFirstNode();
171+
$node = $this->filterXPath('descendant-or-self::base')->getNode(0);
172172
if ($node == null) {
173173
$node = $this->dom->createElement('base');
174174
$this->getHeadNode()->appendChild($node);
@@ -183,7 +183,7 @@ public function setBaseHref($url)
183183
*/
184184
public function getBaseHref()
185185
{
186-
$node = $this->filterXPath('descendant-or-self::base')->getFirstNode();
186+
$node = $this->filterXPath('descendant-or-self::base')->getNode(0);
187187
if ($node instanceof \DOMElement) {
188188
return $node->getAttribute('href');
189189
} else {

src/HtmlPageCrawler.php

+16
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ public function replaceWith($content)
590590
*
591591
* @param null|string $text
592592
* @return string|HtmlPageCrawler
593+
* @api
593594
*/
594595
public function text($text = null)
595596
{
@@ -897,13 +898,28 @@ public function getFirstNode()
897898
return $this->getNode(0);
898899
}
899900

901+
/**
902+
* @param int $position
903+
*
904+
* overridden from Crawler because it is not public in Symfony 2.3
905+
* TODO: throw away as soon as we don't need to support SF 2.3 any more
906+
*
907+
* @return \DOMElement|null
908+
*/
909+
public function getNode($position)
910+
{
911+
return parent::getNode($position);
912+
}
913+
900914
/**
901915
* Returns the node name of the first node of the list.
902916
*
903917
* in Crawler (parent), this function will be available starting with 2.6.0,
904918
* therefore this method be removed from here as soon as we don't need to keep compatibility
905919
* with Symfony < 2.6
906920
*
921+
* TODO: throw away as soon as we don't need to support SF 2.3 any more
922+
*
907923
* @return string The node name
908924
*
909925
* @throws \InvalidArgumentException When current node is empty

0 commit comments

Comments
 (0)