Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/dom-crawler/Crawler.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 5fb285c0d0e3 |
line wrap: on
line diff
--- a/vendor/symfony/dom-crawler/Crawler.php Fri Feb 23 15:51:18 2018 +0000 +++ b/vendor/symfony/dom-crawler/Crawler.php Fri Feb 23 15:52:07 2018 +0000 @@ -20,9 +20,6 @@ */ class Crawler implements \Countable, \IteratorAggregate { - /** - * @var string The current URI - */ protected $uri; /** @@ -58,14 +55,14 @@ private $isHtml = true; /** - * @param mixed $node A Node to use as the base for the crawling - * @param string $currentUri The current URI - * @param string $baseHref The base href value + * @param mixed $node A Node to use as the base for the crawling + * @param string $uri The current URI + * @param string $baseHref The base href value */ - public function __construct($node = null, $currentUri = null, $baseHref = null) + public function __construct($node = null, $uri = null, $baseHref = null) { - $this->uri = $currentUri; - $this->baseHref = $baseHref ?: $currentUri; + $this->uri = $uri; + $this->baseHref = $baseHref ?: $uri; $this->add($node); } @@ -107,7 +104,7 @@ * * @param \DOMNodeList|\DOMNode|array|string|null $node A node * - * @throws \InvalidArgumentException When node is not the expected type. + * @throws \InvalidArgumentException when node is not the expected type */ public function add($node) { @@ -127,8 +124,8 @@ /** * Adds HTML/XML content. * - * If the charset is not set via the content type, it is assumed - * to be ISO-8859-1, which is the default charset defined by the + * If the charset is not set via the content type, it is assumed to be UTF-8, + * or ISO-8859-1 as a fallback, which is the default charset defined by the * HTTP 1.1 specification. * * @param string $content A string to parse as HTML/XML @@ -161,7 +158,7 @@ } if (null === $charset) { - $charset = 'ISO-8859-1'; + $charset = preg_match('//u', $content) ? 'UTF-8' : 'ISO-8859-1'; } if ('x' === $xmlMatches[1]) { @@ -694,8 +691,8 @@ */ public function filter($selector) { - if (!class_exists('Symfony\\Component\\CssSelector\\CssSelectorConverter')) { - throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector 2.8+ is not installed (you can use filterXPath instead).'); + if (!class_exists(CssSelectorConverter::class)) { + throw new \RuntimeException('To filter with a CSS selector, install the CssSelector component ("composer require symfony/css-selector"). Or use filterXpath instead.'); } $converter = new CssSelectorConverter($this->isHtml); @@ -743,7 +740,7 @@ public function selectButton($value) { $translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")'; - $xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, $translate, static::xpathLiteral(' '.$value.' ')). + $xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, static::xpathLiteral(' '.$value.' ')). sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)). sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)); @@ -1071,7 +1068,7 @@ } /** - * @return \ArrayIterator + * @return \ArrayIterator|\DOMElement[] */ public function getIterator() { @@ -1089,7 +1086,7 @@ $nodes = array(); do { - if ($node !== $this->getNode(0) && $node->nodeType === 1) { + if ($node !== $this->getNode(0) && 1 === $node->nodeType) { $nodes[] = $node; } } while ($node = $node->$siblingDir);