Laravel version update
Laravel version update
This commit is contained in:
94
vendor/symfony/dom-crawler/Crawler.php
vendored
94
vendor/symfony/dom-crawler/Crawler.php
vendored
@@ -192,7 +192,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
$dom = new \DOMDocument('1.0', $charset);
|
||||
$dom->validateOnParse = true;
|
||||
|
||||
set_error_handler(function () {throw new \Exception();});
|
||||
set_error_handler(function () { throw new \Exception(); });
|
||||
|
||||
try {
|
||||
// Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML()
|
||||
@@ -337,7 +337,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
@@ -380,7 +380,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
* @param int $offset
|
||||
* @param int $length
|
||||
*
|
||||
* @return Crawler A Crawler instance with the sliced nodes
|
||||
* @return self
|
||||
*/
|
||||
public function slice($offset = 0, $length = null)
|
||||
{
|
||||
@@ -394,7 +394,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @param \Closure $closure An anonymous function
|
||||
*
|
||||
* @return Crawler A Crawler instance with the selected nodes
|
||||
* @return self
|
||||
*/
|
||||
public function reduce(\Closure $closure)
|
||||
{
|
||||
@@ -411,7 +411,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* Returns the first node of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the first selected node
|
||||
* @return self
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
@@ -421,7 +421,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* Returns the last node of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the last selected node
|
||||
* @return self
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
@@ -431,7 +431,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -447,7 +447,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -463,7 +463,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* Returns the previous sibling nodes of the current selection.
|
||||
*
|
||||
* @return Crawler A Crawler instance with the previous sibling nodes
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -479,7 +479,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -504,7 +504,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -637,7 +637,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
@@ -658,7 +658,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@@ -679,7 +679,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
@@ -694,7 +694,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @param string $value The image alt
|
||||
*
|
||||
* @return Crawler A new instance of Crawler with the filtered list of nodes
|
||||
* @return self A new instance of Crawler with the filtered list of nodes
|
||||
*/
|
||||
public function selectImage($value)
|
||||
{
|
||||
@@ -708,7 +708,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
@@ -900,7 +900,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf('concat(%s)', implode($parts, ', '));
|
||||
return sprintf('concat(%s)', implode(', ', $parts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -910,7 +910,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* @param string $xpath
|
||||
*
|
||||
* @return Crawler
|
||||
* @return self
|
||||
*/
|
||||
private function filterRelativeXPath($xpath)
|
||||
{
|
||||
@@ -940,29 +940,54 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
{
|
||||
$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));
|
||||
|
||||
if (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);
|
||||
@@ -975,7 +1000,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
} elseif ('/' === $expression[0] || '.' === $expression[0] || 0 === strpos($expression, 'self::')) {
|
||||
$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;
|
||||
@@ -983,9 +1008,16 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
$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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -155,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)
|
||||
{
|
||||
|
4
vendor/symfony/dom-crawler/Form.php
vendored
4
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)
|
||||
{
|
||||
@@ -279,7 +279,7 @@ class Form extends Link implements \ArrayAccess
|
||||
/**
|
||||
* Gets all fields.
|
||||
*
|
||||
* @return FormField[] An array of fields
|
||||
* @return FormField[]
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
|
@@ -15,6 +15,8 @@ use Symfony\Component\DomCrawler\Field\FormField;
|
||||
|
||||
/**
|
||||
* This is an internal class that must not be used directly.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class FormFieldRegistry
|
||||
{
|
||||
@@ -149,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)
|
||||
{
|
||||
|
2
vendor/symfony/dom-crawler/LICENSE
vendored
2
vendor/symfony/dom-crawler/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2016 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
|
||||
|
15
vendor/symfony/dom-crawler/Tests/CrawlerTest.php
vendored
15
vendor/symfony/dom-crawler/Tests/CrawlerTest.php
vendored
@@ -30,14 +30,14 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetUri()
|
||||
{
|
||||
$uri = 'http://symfony.com';
|
||||
$crawler = new Crawler(null, $uri);
|
||||
$crawler = new Crawler(null, $uri);
|
||||
$this->assertEquals($uri, $crawler->getUri());
|
||||
}
|
||||
|
||||
public function testGetBaseHref()
|
||||
{
|
||||
$baseHref = 'http://symfony.com';
|
||||
$crawler = new Crawler(null, null, $baseHref);
|
||||
$crawler = new Crawler(null, null, $baseHref);
|
||||
$this->assertEquals($baseHref, $crawler->getBaseHref());
|
||||
}
|
||||
|
||||
@@ -238,7 +238,13 @@ EOF
|
||||
$crawler = new Crawler();
|
||||
$crawler->addContent('<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><span>中文</span></html>');
|
||||
$this->assertEquals('中文', $crawler->filterXPath('//span')->text(), '->addContent() guess wrong charset');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension iconv
|
||||
*/
|
||||
public function testAddContentNonUtf8()
|
||||
{
|
||||
$crawler = new Crawler();
|
||||
$crawler->addContent(iconv('UTF-8', 'SJIS', '<html><head><meta charset="Shift_JIS"></head><body>日本語</body></html>'));
|
||||
$this->assertEquals('日本語', $crawler->filterXPath('//body')->text(), '->addContent() can recognize "Shift_JIS" in html5 meta charset tag');
|
||||
@@ -430,6 +436,7 @@ EOF
|
||||
$this->assertCount(5, $crawler->filterXPath('(//a | //div)//img'));
|
||||
$this->assertCount(7, $crawler->filterXPath('((//a | //div)//img | //ul)'));
|
||||
$this->assertCount(7, $crawler->filterXPath('( ( //a | //div )//img | //ul )'));
|
||||
$this->assertCount(1, $crawler->filterXPath("//a[./@href][((./@id = 'Klausi|Claudiu' or normalize-space(string(.)) = 'Klausi|Claudiu' or ./@title = 'Klausi|Claudiu' or ./@rel = 'Klausi|Claudiu') or .//img[./@alt = 'Klausi|Claudiu'])]"));
|
||||
}
|
||||
|
||||
public function testFilterXPath()
|
||||
@@ -596,7 +603,7 @@ EOF
|
||||
|
||||
$this->assertCount(0, $crawler->filterXPath('self::a'), 'The fake root node has no "real" element name');
|
||||
$this->assertCount(0, $crawler->filterXPath('self::a/img'), 'The fake root node has no "real" element name');
|
||||
$this->assertCount(9, $crawler->filterXPath('self::*/a'));
|
||||
$this->assertCount(10, $crawler->filterXPath('self::*/a'));
|
||||
}
|
||||
|
||||
public function testFilter()
|
||||
@@ -1079,6 +1086,8 @@ HTML;
|
||||
|
||||
<a href="?get=param">GetLink</a>
|
||||
|
||||
<a href="/example">Klausi|Claudiu</a>
|
||||
|
||||
<form action="foo" id="FooFormId">
|
||||
<input type="text" value="TextValue" name="TextName" />
|
||||
<input type="submit" value="FooValue" name="FooName" id="FooId" />
|
||||
|
@@ -188,7 +188,8 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
$form = $this->createForm('<form>'.$form.'</form>');
|
||||
$this->assertEquals(
|
||||
$values,
|
||||
array_map(function ($field) {
|
||||
array_map(
|
||||
function ($field) {
|
||||
$class = get_class($field);
|
||||
|
||||
return array(substr($class, strrpos($class, '\\') + 1), $field->getValue());
|
||||
|
Reference in New Issue
Block a user