Update to Drupal 8.2.6. For more information, see https://www.drupal.org/project/drupal/releases/8.2.6
This commit is contained in:
parent
db56c09587
commit
f1e72395cb
588 changed files with 26857 additions and 2777 deletions
337
vendor/symfony/dom-crawler/Crawler.php
vendored
337
vendor/symfony/dom-crawler/Crawler.php
vendored
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Symfony\Component\DomCrawler;
|
||||
|
||||
use Symfony\Component\CssSelector\CssSelector;
|
||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||
|
||||
/**
|
||||
* Crawler eases navigation of a list of \DOMElement objects.
|
||||
* Crawler eases navigation of a list of \DOMNode objects.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
|
@ -40,6 +40,18 @@ class Crawler extends \SplObjectStorage
|
|||
*/
|
||||
private $baseHref;
|
||||
|
||||
/**
|
||||
* @var \DOMDocument|null
|
||||
*/
|
||||
private $document;
|
||||
|
||||
/**
|
||||
* Whether the Crawler contains HTML or XML content (used when converting CSS to XPath).
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $isHtml = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -60,7 +72,8 @@ class Crawler extends \SplObjectStorage
|
|||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->removeAll($this);
|
||||
parent::removeAll($this);
|
||||
$this->document = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,34 +173,7 @@ class Crawler extends \SplObjectStorage
|
|||
|
||||
try {
|
||||
// Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML()
|
||||
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
|
||||
} elseif (function_exists('iconv')) {
|
||||
$content = preg_replace_callback(
|
||||
'/[\x80-\xFF]+/',
|
||||
function ($m) {
|
||||
$m = unpack('C*', $m[0]);
|
||||
$i = 1;
|
||||
$entities = '';
|
||||
|
||||
while (isset($m[$i])) {
|
||||
if (0xF0 <= $m[$i]) {
|
||||
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
||||
} elseif (0xE0 <= $m[$i]) {
|
||||
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
||||
} else {
|
||||
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
|
||||
}
|
||||
|
||||
$entities .= '&#'.$c.';';
|
||||
}
|
||||
|
||||
return $entities;
|
||||
},
|
||||
iconv($charset, 'UTF-8', $content)
|
||||
);
|
||||
}
|
||||
$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
|
@ -229,8 +215,11 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param string $content The XML content
|
||||
* @param string $charset The charset
|
||||
* @param int $options Bitwise OR of the libxml option constants
|
||||
* LIBXML_PARSEHUGE is dangerous, see
|
||||
* http://symfony.com/blog/security-release-symfony-2-0-17-released
|
||||
*/
|
||||
public function addXmlContent($content, $charset = 'UTF-8')
|
||||
public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NONET)
|
||||
{
|
||||
// remove the default namespace if it's the only namespace to make XPath expressions simpler
|
||||
if (!preg_match('/xmlns:/', $content)) {
|
||||
|
@ -244,13 +233,15 @@ class Crawler extends \SplObjectStorage
|
|||
$dom->validateOnParse = true;
|
||||
|
||||
if ('' !== trim($content)) {
|
||||
@$dom->loadXML($content, LIBXML_NONET);
|
||||
@$dom->loadXML($content, $options);
|
||||
}
|
||||
|
||||
libxml_use_internal_errors($internalErrors);
|
||||
libxml_disable_entity_loader($disableEntities);
|
||||
|
||||
$this->addDocument($dom);
|
||||
|
||||
$this->isHtml = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,10 +290,18 @@ class Crawler extends \SplObjectStorage
|
|||
public function addNode(\DOMNode $node)
|
||||
{
|
||||
if ($node instanceof \DOMDocument) {
|
||||
$this->attach($node->documentElement);
|
||||
} else {
|
||||
$this->attach($node);
|
||||
$node = $node->documentElement;
|
||||
}
|
||||
|
||||
if (null !== $this->document && $this->document !== $node->ownerDocument) {
|
||||
@trigger_error('Attaching DOM nodes from multiple documents in a Crawler is deprecated as of 2.8 and will be forbidden in 3.0.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (null === $this->document) {
|
||||
$this->document = $node->ownerDocument;
|
||||
}
|
||||
|
||||
parent::attach($node);
|
||||
}
|
||||
|
||||
// Serializing and unserializing a crawler creates DOM objects in a corrupted state. DOM elements are not properly serializable.
|
||||
|
@ -321,7 +320,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param int $position The position
|
||||
*
|
||||
* @return Crawler A new instance of the Crawler with the selected node, or an empty Crawler if it does not exist.
|
||||
* @return self
|
||||
*/
|
||||
public function eq($position)
|
||||
{
|
||||
|
@ -366,7 +365,7 @@ class Crawler extends \SplObjectStorage
|
|||
* @param int $offset
|
||||
* @param int $length
|
||||
*
|
||||
* @return Crawler A Crawler instance with the sliced nodes
|
||||
* @return self
|
||||
*/
|
||||
public function slice($offset = 0, $length = -1)
|
||||
{
|
||||
|
@ -380,7 +379,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param \Closure $closure An anonymous function
|
||||
*
|
||||
* @return Crawler A Crawler instance with the selected nodes.
|
||||
* @return self
|
||||
*/
|
||||
public function reduce(\Closure $closure)
|
||||
{
|
||||
|
@ -397,7 +396,7 @@ class Crawler extends \SplObjectStorage
|
|||
/**
|
||||
* Returns the first node of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the first selected node
|
||||
* @return self
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
|
@ -407,7 +406,7 @@ class Crawler extends \SplObjectStorage
|
|||
/**
|
||||
* Returns the last node of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the last selected node
|
||||
* @return self
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
|
@ -417,7 +416,7 @@ class Crawler extends \SplObjectStorage
|
|||
/**
|
||||
* Returns the siblings nodes of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the sibling nodes
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException When current node is empty
|
||||
*/
|
||||
|
@ -433,7 +432,7 @@ class Crawler extends \SplObjectStorage
|
|||
/**
|
||||
* Returns the next siblings nodes of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the next sibling nodes
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException When current node is empty
|
||||
*/
|
||||
|
@ -449,7 +448,7 @@ class Crawler extends \SplObjectStorage
|
|||
/**
|
||||
* Returns the previous sibling nodes of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the previous sibling nodes
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
|
@ -465,7 +464,7 @@ class Crawler extends \SplObjectStorage
|
|||
/**
|
||||
* Returns the parents nodes of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the parents nodes of the current selection
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException When current node is empty
|
||||
*/
|
||||
|
@ -479,7 +478,7 @@ class Crawler extends \SplObjectStorage
|
|||
$nodes = array();
|
||||
|
||||
while ($node = $node->parentNode) {
|
||||
if (1 === $node->nodeType) {
|
||||
if (XML_ELEMENT_NODE === $node->nodeType) {
|
||||
$nodes[] = $node;
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +489,7 @@ class Crawler extends \SplObjectStorage
|
|||
/**
|
||||
* Returns the children nodes of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the children nodes
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException When current node is empty
|
||||
*/
|
||||
|
@ -623,7 +622,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param string $xpath An XPath expression
|
||||
*
|
||||
* @return Crawler A new instance of Crawler with the filtered list of nodes
|
||||
* @return self
|
||||
*/
|
||||
public function filterXPath($xpath)
|
||||
{
|
||||
|
@ -644,18 +643,20 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param string $selector A CSS selector
|
||||
*
|
||||
* @return Crawler A new instance of Crawler with the filtered list of nodes
|
||||
* @return self
|
||||
*
|
||||
* @throws \RuntimeException if the CssSelector Component is not available
|
||||
*/
|
||||
public function filter($selector)
|
||||
{
|
||||
if (!class_exists('Symfony\\Component\\CssSelector\\CssSelector')) {
|
||||
throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector is not installed (you can use filterXPath instead).');
|
||||
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).');
|
||||
}
|
||||
|
||||
$converter = new CssSelectorConverter($this->isHtml);
|
||||
|
||||
// The CssSelector already prefixes the selector with descendant-or-self::
|
||||
return $this->filterRelativeXPath(CssSelector::toXPath($selector));
|
||||
return $this->filterRelativeXPath($converter->toXPath($selector));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -663,7 +664,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param string $value The link text
|
||||
*
|
||||
* @return Crawler A new instance of Crawler with the filtered list of nodes
|
||||
* @return self
|
||||
*/
|
||||
public function selectLink($value)
|
||||
{
|
||||
|
@ -678,7 +679,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param string $value The button text
|
||||
*
|
||||
* @return Crawler A new instance of Crawler with the filtered list of nodes
|
||||
* @return self
|
||||
*/
|
||||
public function selectButton($value)
|
||||
{
|
||||
|
@ -697,7 +698,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @return Link A Link instance
|
||||
*
|
||||
* @throws \InvalidArgumentException If the current node list is empty
|
||||
* @throws \InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement
|
||||
*/
|
||||
public function link($method = 'get')
|
||||
{
|
||||
|
@ -707,6 +708,10 @@ class Crawler extends \SplObjectStorage
|
|||
|
||||
$node = $this->getNode(0);
|
||||
|
||||
if (!$node instanceof \DOMElement) {
|
||||
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_class($node)));
|
||||
}
|
||||
|
||||
return new Link($node, $this->baseHref, $method);
|
||||
}
|
||||
|
||||
|
@ -714,11 +719,17 @@ class Crawler extends \SplObjectStorage
|
|||
* Returns an array of Link objects for the nodes in the list.
|
||||
*
|
||||
* @return Link[] An array of Link instances
|
||||
*
|
||||
* @throws \InvalidArgumentException If the current node list contains non-DOMElement instances
|
||||
*/
|
||||
public function links()
|
||||
{
|
||||
$links = array();
|
||||
foreach ($this as $node) {
|
||||
if (!$node instanceof \DOMElement) {
|
||||
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_class($node)));
|
||||
}
|
||||
|
||||
$links[] = new Link($node, $this->baseHref, 'get');
|
||||
}
|
||||
|
||||
|
@ -733,7 +744,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @return Form A Form instance
|
||||
*
|
||||
* @throws \InvalidArgumentException If the current node list is empty
|
||||
* @throws \InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement
|
||||
*/
|
||||
public function form(array $values = null, $method = null)
|
||||
{
|
||||
|
@ -741,7 +752,13 @@ class Crawler extends \SplObjectStorage
|
|||
throw new \InvalidArgumentException('The current node list is empty.');
|
||||
}
|
||||
|
||||
$form = new Form($this->getNode(0), $this->uri, $method, $this->baseHref);
|
||||
$node = $this->getNode(0);
|
||||
|
||||
if (!$node instanceof \DOMElement) {
|
||||
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_class($node)));
|
||||
}
|
||||
|
||||
$form = new Form($node, $this->uri, $method, $this->baseHref);
|
||||
|
||||
if (null !== $values) {
|
||||
$form->setValues($values);
|
||||
|
@ -813,7 +830,127 @@ class Crawler extends \SplObjectStorage
|
|||
}
|
||||
}
|
||||
|
||||
return sprintf('concat(%s)', implode($parts, ', '));
|
||||
return sprintf('concat(%s)', implode(', ', $parts));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function attach($object, $data = null)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::attach($object, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function detach($object)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::detach($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function contains($object)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
return parent::contains($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function addAll($storage)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::addAll($storage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function removeAll($storage)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::removeAll($storage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function removeAllExcept($storage)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::removeAllExcept($storage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
return parent::getInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function setInfo($data)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::setInfo($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function offsetExists($object)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
return parent::offsetExists($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function offsetSet($object, $data = null)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::offsetSet($object, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function offsetUnset($object)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
parent::offsetUnset($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
|
||||
*/
|
||||
public function offsetGet($object)
|
||||
{
|
||||
$this->triggerDeprecation(__METHOD__);
|
||||
|
||||
return parent::offsetGet($object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -823,7 +960,7 @@ class Crawler extends \SplObjectStorage
|
|||
*
|
||||
* @param string $xpath
|
||||
*
|
||||
* @return Crawler
|
||||
* @return self
|
||||
*/
|
||||
private function filterRelativeXPath($xpath)
|
||||
{
|
||||
|
@ -853,32 +990,59 @@ class Crawler extends \SplObjectStorage
|
|||
{
|
||||
$expressions = array();
|
||||
|
||||
$unionPattern = '/\|(?![^\[]*\])/';
|
||||
// An expression which will never match to replace expressions which cannot match in the crawler
|
||||
// We cannot simply drop
|
||||
$nonMatchingExpression = 'a[name() = "b"]';
|
||||
|
||||
// Split any unions into individual expressions.
|
||||
foreach (preg_split($unionPattern, $xpath) as $expression) {
|
||||
$expression = trim($expression);
|
||||
$parenthesis = '';
|
||||
$xpathLen = strlen($xpath);
|
||||
$openedBrackets = 0;
|
||||
$startPosition = strspn($xpath, " \t\n\r\0\x0B");
|
||||
|
||||
// If the union is inside some braces, we need to preserve the opening braces and apply
|
||||
// the change only inside it.
|
||||
if (preg_match('/^[\(\s*]+/', $expression, $matches)) {
|
||||
$parenthesis = $matches[0];
|
||||
$expression = substr($expression, strlen($parenthesis));
|
||||
for ($i = $startPosition; $i <= $xpathLen; ++$i) {
|
||||
$i += strcspn($xpath, '"\'[]|', $i);
|
||||
|
||||
if ($i < $xpathLen) {
|
||||
switch ($xpath[$i]) {
|
||||
case '"':
|
||||
case "'":
|
||||
if (false === $i = strpos($xpath, $xpath[$i], $i + 1)) {
|
||||
return $xpath; // The XPath expression is invalid
|
||||
}
|
||||
continue 2;
|
||||
case '[':
|
||||
++$openedBrackets;
|
||||
continue 2;
|
||||
case ']':
|
||||
--$openedBrackets;
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
if ($openedBrackets) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($startPosition < $xpathLen && '(' === $xpath[$startPosition]) {
|
||||
// If the union is inside some braces, we need to preserve the opening braces and apply
|
||||
// the change only inside it.
|
||||
$j = 1 + strspn($xpath, "( \t\n\r\0\x0B", $startPosition + 1);
|
||||
$parenthesis = substr($xpath, $startPosition, $j);
|
||||
$startPosition += $j;
|
||||
} else {
|
||||
$parenthesis = '';
|
||||
}
|
||||
$expression = rtrim(substr($xpath, $startPosition, $i - $startPosition));
|
||||
|
||||
// BC for Symfony 2.4 and lower were elements were adding in a fake _root parent
|
||||
if (0 === strpos($expression, '/_root/')) {
|
||||
@trigger_error('XPath expressions referencing the fake root node are deprecated since version 2.8 and will be unsupported in 3.0. Please use "./" instead of "/_root/".', E_USER_DEPRECATED);
|
||||
|
||||
$expression = './'.substr($expression, 7);
|
||||
} elseif (0 === strpos($expression, 'self::*/')) {
|
||||
$expression = './'.substr($expression, 8);
|
||||
}
|
||||
|
||||
// add prefix before absolute element selector
|
||||
if (empty($expression)) {
|
||||
if ('' === $expression) {
|
||||
$expression = $nonMatchingExpression;
|
||||
} elseif (0 === strpos($expression, '//')) {
|
||||
$expression = 'descendant-or-self::'.substr($expression, 2);
|
||||
|
@ -896,7 +1060,7 @@ class Crawler extends \SplObjectStorage
|
|||
// '.' is the fake root element in Symfony 2.4 and lower, which is excluded from results
|
||||
$expression = $nonMatchingExpression;
|
||||
} elseif (0 === strpos($expression, 'descendant::')) {
|
||||
$expression = 'descendant-or-self::'.substr($expression, strlen('descendant::'));
|
||||
$expression = 'descendant-or-self::'.substr($expression, 12);
|
||||
} elseif (preg_match('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/', $expression)) {
|
||||
// the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes)
|
||||
$expression = $nonMatchingExpression;
|
||||
|
@ -904,9 +1068,16 @@ class Crawler extends \SplObjectStorage
|
|||
$expression = 'self::'.$expression;
|
||||
}
|
||||
$expressions[] = $parenthesis.$expression;
|
||||
|
||||
if ($i === $xpathLen) {
|
||||
return implode(' | ', $expressions);
|
||||
}
|
||||
|
||||
$i += strspn($xpath, " \t\n\r\0\x0B", $i + 1);
|
||||
$startPosition = $i + 1;
|
||||
}
|
||||
|
||||
return implode(' | ', $expressions);
|
||||
return $xpath; // The XPath expression is invalid
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1010,7 +1181,29 @@ class Crawler extends \SplObjectStorage
|
|||
private function createSubCrawler($nodes)
|
||||
{
|
||||
$crawler = new static($nodes, $this->uri, $this->baseHref);
|
||||
$crawler->isHtml = $this->isHtml;
|
||||
$crawler->document = $this->document;
|
||||
$crawler->namespaces = $this->namespaces;
|
||||
|
||||
return $crawler;
|
||||
}
|
||||
|
||||
private function triggerDeprecation($methodName, $useTrace = false)
|
||||
{
|
||||
if ($useTrace || defined('HHVM_VERSION')) {
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
} else {
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
}
|
||||
|
||||
// The SplObjectStorage class performs calls to its own methods. These
|
||||
// method calls must not lead to triggered deprecation notices.
|
||||
if (isset($trace[2]['class']) && 'SplObjectStorage' === $trace[2]['class']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@trigger_error('The '.$methodName.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,10 @@ class ChoiceFormField extends FormField
|
|||
*/
|
||||
public function isDisabled()
|
||||
{
|
||||
if (parent::isDisabled() && 'select' === $this->type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($this->options as $option) {
|
||||
if ($option['value'] == $this->value && $option['disabled']) {
|
||||
return true;
|
||||
|
@ -151,11 +155,11 @@ class ChoiceFormField extends FormField
|
|||
/**
|
||||
* Adds a choice to the current ones.
|
||||
*
|
||||
* This method should only be used internally.
|
||||
*
|
||||
* @param \DOMElement $node
|
||||
*
|
||||
* @throws \LogicException When choice provided is not multiple nor radio
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function addChoice(\DOMElement $node)
|
||||
{
|
||||
|
@ -259,7 +263,8 @@ class ChoiceFormField extends FormField
|
|||
{
|
||||
$option = array();
|
||||
|
||||
$defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : 'on';
|
||||
$defaultDefaultValue = 'select' === $this->node->nodeName ? '' : 'on';
|
||||
$defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : $defaultDefaultValue;
|
||||
$option['value'] = $node->hasAttribute('value') ? $node->getAttribute('value') : $defaultValue;
|
||||
$option['disabled'] = $node->hasAttribute('disabled');
|
||||
|
||||
|
|
18
vendor/symfony/dom-crawler/Form.php
vendored
18
vendor/symfony/dom-crawler/Form.php
vendored
|
@ -69,7 +69,7 @@ class Form extends Link implements \ArrayAccess
|
|||
*
|
||||
* @param array $values An array of field values
|
||||
*
|
||||
* @return Form
|
||||
* @return $this
|
||||
*/
|
||||
public function setValues(array $values)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ class Form extends Link implements \ArrayAccess
|
|||
*
|
||||
* The returned array does not include file fields (@see getFiles).
|
||||
*
|
||||
* @return array An array of field values.
|
||||
* @return array An array of field values
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ class Form extends Link implements \ArrayAccess
|
|||
/**
|
||||
* Gets the file field values.
|
||||
*
|
||||
* @return array An array of file field values.
|
||||
* @return array An array of file field values
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ class Form extends Link implements \ArrayAccess
|
|||
* This method converts fields with the array notation
|
||||
* (like foo[bar] to arrays) like PHP does.
|
||||
*
|
||||
* @return array An array of field values.
|
||||
* @return array An array of field values
|
||||
*/
|
||||
public function getPhpValues()
|
||||
{
|
||||
|
@ -157,8 +157,12 @@ class Form extends Link implements \ArrayAccess
|
|||
*
|
||||
* This method converts fields with the array notation
|
||||
* (like foo[bar] to arrays) like PHP does.
|
||||
* The returned array is consistent with the array for field values
|
||||
* (@see getPhpValues), rather than uploaded files found in $_FILES.
|
||||
* For a compound file field foo[bar] it will create foo[bar][name],
|
||||
* instead of foo[name][bar] which would be found in $_FILES.
|
||||
*
|
||||
* @return array An array of field values.
|
||||
* @return array An array of file field values
|
||||
*/
|
||||
public function getPhpFiles()
|
||||
{
|
||||
|
@ -242,8 +246,6 @@ class Form extends Link implements \ArrayAccess
|
|||
* Removes a field from the form.
|
||||
*
|
||||
* @param string $name The field name
|
||||
*
|
||||
* @throws \InvalidArgumentException when the name is malformed
|
||||
*/
|
||||
public function remove($name)
|
||||
{
|
||||
|
@ -277,7 +279,7 @@ class Form extends Link implements \ArrayAccess
|
|||
/**
|
||||
* Gets all fields.
|
||||
*
|
||||
* @return FormField[] An array of fields
|
||||
* @return FormField[]
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
|
|
19
vendor/symfony/dom-crawler/FormFieldRegistry.php
vendored
19
vendor/symfony/dom-crawler/FormFieldRegistry.php
vendored
|
@ -15,6 +15,8 @@ use Symfony\Component\DomCrawler\Field\FormField;
|
|||
|
||||
/**
|
||||
* This is an internal class that must not be used directly.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class FormFieldRegistry
|
||||
{
|
||||
|
@ -26,8 +28,6 @@ class FormFieldRegistry
|
|||
* Adds a field to the registry.
|
||||
*
|
||||
* @param FormField $field The field
|
||||
*
|
||||
* @throws \InvalidArgumentException when the name is malformed
|
||||
*/
|
||||
public function add(FormField $field)
|
||||
{
|
||||
|
@ -52,8 +52,6 @@ class FormFieldRegistry
|
|||
* Removes a field and its children from the registry.
|
||||
*
|
||||
* @param string $name The fully qualified name of the base field
|
||||
*
|
||||
* @throws \InvalidArgumentException when the name is malformed
|
||||
*/
|
||||
public function remove($name)
|
||||
{
|
||||
|
@ -76,7 +74,6 @@ class FormFieldRegistry
|
|||
*
|
||||
* @return mixed The value of the field
|
||||
*
|
||||
* @throws \InvalidArgumentException when the name is malformed
|
||||
* @throws \InvalidArgumentException if the field does not exist
|
||||
*/
|
||||
public function &get($name)
|
||||
|
@ -118,7 +115,6 @@ class FormFieldRegistry
|
|||
* @param string $name The fully qualified name of the field
|
||||
* @param mixed $value The value
|
||||
*
|
||||
* @throws \InvalidArgumentException when the name is malformed
|
||||
* @throws \InvalidArgumentException if the field does not exist
|
||||
*/
|
||||
public function set($name, $value)
|
||||
|
@ -155,7 +151,7 @@ class FormFieldRegistry
|
|||
* @param string $base The fully qualified name of the base field
|
||||
* @param array $values The values of the fields
|
||||
*
|
||||
* @return FormFieldRegistry
|
||||
* @return static
|
||||
*/
|
||||
private static function create($base, array $values)
|
||||
{
|
||||
|
@ -199,24 +195,23 @@ class FormFieldRegistry
|
|||
* @param string $name The name of the field
|
||||
*
|
||||
* @return string[] The list of segments
|
||||
*
|
||||
* @throws \InvalidArgumentException when the name is malformed
|
||||
*/
|
||||
private function getSegments($name)
|
||||
{
|
||||
if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
|
||||
$segments = array($m['base']);
|
||||
while (!empty($m['extra'])) {
|
||||
if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $m['extra'], $m)) {
|
||||
$extra = $m['extra'];
|
||||
if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
|
||||
$segments[] = $m['segment'];
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('Malformed field path "%s"', $name));
|
||||
$segments[] = $extra;
|
||||
}
|
||||
}
|
||||
|
||||
return $segments;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Malformed field path "%s"', $name));
|
||||
return array($name);
|
||||
}
|
||||
}
|
||||
|
|
2
vendor/symfony/dom-crawler/LICENSE
vendored
2
vendor/symfony/dom-crawler/LICENSE
vendored
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2004-2015 Fabien Potencier
|
||||
Copyright (c) 2004-2017 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
35
vendor/symfony/dom-crawler/README.md
vendored
35
vendor/symfony/dom-crawler/README.md
vendored
|
@ -1,36 +1,13 @@
|
|||
DomCrawler Component
|
||||
====================
|
||||
|
||||
DomCrawler eases DOM navigation for HTML and XML documents.
|
||||
|
||||
If you are familiar with jQuery, DomCrawler is a PHP equivalent:
|
||||
|
||||
```php
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
$crawler = new Crawler();
|
||||
$crawler->addContent('<html><body><p>Hello World!</p></body></html>');
|
||||
|
||||
print $crawler->filterXPath('descendant-or-self::body/p')->text();
|
||||
```
|
||||
|
||||
If you are also using the CssSelector component, you can use CSS Selectors
|
||||
instead of XPath expressions:
|
||||
|
||||
```php
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
$crawler = new Crawler();
|
||||
$crawler->addContent('<html><body><p>Hello World!</p></body></html>');
|
||||
|
||||
print $crawler->filter('body > p')->text();
|
||||
```
|
||||
The DomCrawler component eases DOM navigation for HTML and XML documents.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/DomCrawler/
|
||||
$ composer install
|
||||
$ phpunit
|
||||
* [Documentation](https://symfony.com/doc/current/components/dom_crawler.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
|
|
12
vendor/symfony/dom-crawler/composer.json
vendored
12
vendor/symfony/dom-crawler/composer.json
vendored
|
@ -16,21 +16,25 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
"php": ">=5.3.9",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/css-selector": "~2.3"
|
||||
"symfony/css-selector": "~2.8|~3.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/css-selector": ""
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\DomCrawler\\": "" }
|
||||
"psr-4": { "Symfony\\Component\\DomCrawler\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.7-dev"
|
||||
"dev-master": "2.8-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue