Class[Element[*].aclass]]"]],
+ ['label:only', ['Pseudo[Element[label]:only]']],
+ ['a:lang(fr)', ["Function[Element[a]:lang(['fr'])]"]],
+ ['div:contains("foo")', ["Function[Element[div]:contains(['foo'])]"]],
+ ['div#foobar', ['Hash[Element[div]#foobar]']],
+ ['div:not(div.foo)', ['Negation[Element[div]:not(Class[Element[div].foo])]']],
+ ['td ~ th', ['CombinedSelector[Element[td] ~ Element[th]]']],
+ ['.foo[data-bar][data-baz=0]', ["Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]"]],
+ ];
}
public function getParserExceptionTestData()
{
- return array(
- array('attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()),
- array('attributes(href)', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()),
- array('html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '/', 4))->getMessage()),
- array(' ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 1))->getMessage()),
- array('div, ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 5))->getMessage()),
- array(' , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 1))->getMessage()),
- array('p, , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 3))->getMessage()),
- array('div > ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 6))->getMessage()),
- array(' > div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '>', 2))->getMessage()),
- array('foo|#bar', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_HASH, 'bar', 4))->getMessage()),
- array('#.foo', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '#', 0))->getMessage()),
- array('.#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()),
- array(':#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()),
- array('[*]', SyntaxErrorException::unexpectedToken('"|"', new Token(Token::TYPE_DELIMITER, ']', 2))->getMessage()),
- array('[foo|]', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_DELIMITER, ']', 5))->getMessage()),
- array('[#]', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_DELIMITER, '#', 1))->getMessage()),
- array('[foo=#]', SyntaxErrorException::unexpectedToken('string or identifier', new Token(Token::TYPE_DELIMITER, '#', 5))->getMessage()),
- array(':nth-child()', SyntaxErrorException::unexpectedToken('at least one argument', new Token(Token::TYPE_DELIMITER, ')', 11))->getMessage()),
- array('[href]a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_IDENTIFIER, 'a', 6))->getMessage()),
- array('[rel:stylesheet]', SyntaxErrorException::unexpectedToken('operator', new Token(Token::TYPE_DELIMITER, ':', 4))->getMessage()),
- array('[rel=stylesheet', SyntaxErrorException::unexpectedToken('"]"', new Token(Token::TYPE_FILE_END, '', 15))->getMessage()),
- array(':lang(fr', SyntaxErrorException::unexpectedToken('an argument', new Token(Token::TYPE_FILE_END, '', 8))->getMessage()),
- array(':contains("foo', SyntaxErrorException::unclosedString(10)->getMessage()),
- array('foo!', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '!', 3))->getMessage()),
- );
+ return [
+ ['attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()],
+ ['attributes(href)', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()],
+ ['html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '/', 4))->getMessage()],
+ [' ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 1))->getMessage()],
+ ['div, ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 5))->getMessage()],
+ [' , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 1))->getMessage()],
+ ['p, , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 3))->getMessage()],
+ ['div > ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 6))->getMessage()],
+ [' > div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '>', 2))->getMessage()],
+ ['foo|#bar', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_HASH, 'bar', 4))->getMessage()],
+ ['#.foo', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '#', 0))->getMessage()],
+ ['.#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()],
+ [':#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()],
+ ['[*]', SyntaxErrorException::unexpectedToken('"|"', new Token(Token::TYPE_DELIMITER, ']', 2))->getMessage()],
+ ['[foo|]', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_DELIMITER, ']', 5))->getMessage()],
+ ['[#]', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_DELIMITER, '#', 1))->getMessage()],
+ ['[foo=#]', SyntaxErrorException::unexpectedToken('string or identifier', new Token(Token::TYPE_DELIMITER, '#', 5))->getMessage()],
+ [':nth-child()', SyntaxErrorException::unexpectedToken('at least one argument', new Token(Token::TYPE_DELIMITER, ')', 11))->getMessage()],
+ ['[href]a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_IDENTIFIER, 'a', 6))->getMessage()],
+ ['[rel:stylesheet]', SyntaxErrorException::unexpectedToken('operator', new Token(Token::TYPE_DELIMITER, ':', 4))->getMessage()],
+ ['[rel=stylesheet', SyntaxErrorException::unexpectedToken('"]"', new Token(Token::TYPE_FILE_END, '', 15))->getMessage()],
+ [':lang(fr', SyntaxErrorException::unexpectedToken('an argument', new Token(Token::TYPE_FILE_END, '', 8))->getMessage()],
+ [':contains("foo', SyntaxErrorException::unclosedString(10)->getMessage()],
+ ['foo!', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '!', 3))->getMessage()],
+ ];
}
public function getPseudoElementsTestData()
{
- return array(
- array('foo', 'Element[foo]', ''),
- array('*', 'Element[*]', ''),
- array(':empty', 'Pseudo[Element[*]:empty]', ''),
- array(':BEfore', 'Element[*]', 'before'),
- array(':aftER', 'Element[*]', 'after'),
- array(':First-Line', 'Element[*]', 'first-line'),
- array(':First-Letter', 'Element[*]', 'first-letter'),
- array('::befoRE', 'Element[*]', 'before'),
- array('::AFter', 'Element[*]', 'after'),
- array('::firsT-linE', 'Element[*]', 'first-line'),
- array('::firsT-letteR', 'Element[*]', 'first-letter'),
- array('::Selection', 'Element[*]', 'selection'),
- array('foo:after', 'Element[foo]', 'after'),
- array('foo::selection', 'Element[foo]', 'selection'),
- array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'),
- array('video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'),
- );
+ return [
+ ['foo', 'Element[foo]', ''],
+ ['*', 'Element[*]', ''],
+ [':empty', 'Pseudo[Element[*]:empty]', ''],
+ [':BEfore', 'Element[*]', 'before'],
+ [':aftER', 'Element[*]', 'after'],
+ [':First-Line', 'Element[*]', 'first-line'],
+ [':First-Letter', 'Element[*]', 'first-letter'],
+ ['::befoRE', 'Element[*]', 'before'],
+ ['::AFter', 'Element[*]', 'after'],
+ ['::firsT-linE', 'Element[*]', 'first-line'],
+ ['::firsT-letteR', 'Element[*]', 'first-letter'],
+ ['::Selection', 'Element[*]', 'selection'],
+ ['foo:after', 'Element[foo]', 'after'],
+ ['foo::selection', 'Element[foo]', 'selection'],
+ ['lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'],
+ ['video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'],
+ ];
}
public function getSpecificityTestData()
{
- return array(
- array('*', 0),
- array(' foo', 1),
- array(':empty ', 10),
- array(':before', 1),
- array('*:before', 1),
- array(':nth-child(2)', 10),
- array('.bar', 10),
- array('[baz]', 10),
- array('[baz="4"]', 10),
- array('[baz^="4"]', 10),
- array('#lipsum', 100),
- array(':not(*)', 0),
- array(':not(foo)', 1),
- array(':not(.foo)', 10),
- array(':not([foo])', 10),
- array(':not(:empty)', 10),
- array(':not(#foo)', 100),
- array('foo:empty', 11),
- array('foo:before', 2),
- array('foo::before', 2),
- array('foo:empty::before', 12),
- array('#lorem + foo#ipsum:first-child > bar:first-line', 213),
- );
+ return [
+ ['*', 0],
+ [' foo', 1],
+ [':empty ', 10],
+ [':before', 1],
+ ['*:before', 1],
+ [':nth-child(2)', 10],
+ ['.bar', 10],
+ ['[baz]', 10],
+ ['[baz="4"]', 10],
+ ['[baz^="4"]', 10],
+ ['#lipsum', 100],
+ [':not(*)', 0],
+ [':not(foo)', 1],
+ [':not(.foo)', 10],
+ [':not([foo])', 10],
+ [':not(:empty)', 10],
+ [':not(#foo)', 100],
+ ['foo:empty', 11],
+ ['foo:before', 2],
+ ['foo::before', 2],
+ ['foo:empty::before', 12],
+ ['#lorem + foo#ipsum:first-child > bar:first-line', 213],
+ ];
}
public function getParseSeriesTestData()
{
- return array(
- array('1n+3', 1, 3),
- array('1n +3', 1, 3),
- array('1n + 3', 1, 3),
- array('1n+ 3', 1, 3),
- array('1n-3', 1, -3),
- array('1n -3', 1, -3),
- array('1n - 3', 1, -3),
- array('1n- 3', 1, -3),
- array('n-5', 1, -5),
- array('odd', 2, 1),
- array('even', 2, 0),
- array('3n', 3, 0),
- array('n', 1, 0),
- array('+n', 1, 0),
- array('-n', -1, 0),
- array('5', 0, 5),
- );
+ return [
+ ['1n+3', 1, 3],
+ ['1n +3', 1, 3],
+ ['1n + 3', 1, 3],
+ ['1n+ 3', 1, 3],
+ ['1n-3', 1, -3],
+ ['1n -3', 1, -3],
+ ['1n - 3', 1, -3],
+ ['1n- 3', 1, -3],
+ ['n-5', 1, -5],
+ ['odd', 2, 1],
+ ['even', 2, 0],
+ ['3n', 3, 0],
+ ['n', 1, 0],
+ ['+n', 1, 0],
+ ['-n', -1, 0],
+ ['5', 0, 5],
+ ];
}
public function getParseSeriesExceptionTestData()
{
- return array(
- array('foo'),
- array('n+'),
- );
+ return [
+ ['foo'],
+ ['n+'],
+ ];
}
}
diff --git a/application/vendor/symfony/css-selector/Tests/Parser/ReaderTest.php b/application/vendor/symfony/css-selector/Tests/Parser/ReaderTest.php
index 21eb608..ff9ea90 100644
--- a/application/vendor/symfony/css-selector/Tests/Parser/ReaderTest.php
+++ b/application/vendor/symfony/css-selector/Tests/Parser/ReaderTest.php
@@ -70,11 +70,11 @@ public function testFindPattern()
$reader = new Reader('hello');
$this->assertFalse($reader->findPattern('/world/'));
- $this->assertEquals(array('hello', 'h'), $reader->findPattern('/^([a-z]).*/'));
+ $this->assertEquals(['hello', 'h'], $reader->findPattern('/^([a-z]).*/'));
$this->assignPosition($reader, 2);
$this->assertFalse($reader->findPattern('/^h.*/'));
- $this->assertEquals(array('llo'), $reader->findPattern('/^llo$/'));
+ $this->assertEquals(['llo'], $reader->findPattern('/^llo$/'));
}
public function testMoveForward()
diff --git a/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ClassParserTest.php b/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ClassParserTest.php
index 7e92f5b..29d9d5f 100644
--- a/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ClassParserTest.php
+++ b/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ClassParserTest.php
@@ -34,12 +34,12 @@ public function testParse($source, $representation)
public function getParseTestData()
{
- return array(
- array('.testclass', 'Class[Element[*].testclass]'),
- array('testel.testclass', 'Class[Element[testel].testclass]'),
- array('testns|.testclass', 'Class[Element[testns|*].testclass]'),
- array('testns|*.testclass', 'Class[Element[testns|*].testclass]'),
- array('testns|testel.testclass', 'Class[Element[testns|testel].testclass]'),
- );
+ return [
+ ['.testclass', 'Class[Element[*].testclass]'],
+ ['testel.testclass', 'Class[Element[testel].testclass]'],
+ ['testns|.testclass', 'Class[Element[testns|*].testclass]'],
+ ['testns|*.testclass', 'Class[Element[testns|*].testclass]'],
+ ['testns|testel.testclass', 'Class[Element[testns|testel].testclass]'],
+ ];
}
}
diff --git a/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ElementParserTest.php b/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ElementParserTest.php
index 05a730f..79cc227 100644
--- a/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ElementParserTest.php
+++ b/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/ElementParserTest.php
@@ -34,11 +34,11 @@ public function testParse($source, $representation)
public function getParseTestData()
{
- return array(
- array('*', 'Element[*]'),
- array('testel', 'Element[testel]'),
- array('testns|*', 'Element[testns|*]'),
- array('testns|testel', 'Element[testns|testel]'),
- );
+ return [
+ ['*', 'Element[*]'],
+ ['testel', 'Element[testel]'],
+ ['testns|*', 'Element[testns|*]'],
+ ['testns|testel', 'Element[testns|testel]'],
+ ];
}
}
diff --git a/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/HashParserTest.php b/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/HashParserTest.php
index 82f555d..a7c79d6 100644
--- a/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/HashParserTest.php
+++ b/application/vendor/symfony/css-selector/Tests/Parser/Shortcut/HashParserTest.php
@@ -34,12 +34,12 @@ public function testParse($source, $representation)
public function getParseTestData()
{
- return array(
- array('#testid', 'Hash[Element[*]#testid]'),
- array('testel#testid', 'Hash[Element[testel]#testid]'),
- array('testns|#testid', 'Hash[Element[testns|*]#testid]'),
- array('testns|*#testid', 'Hash[Element[testns|*]#testid]'),
- array('testns|testel#testid', 'Hash[Element[testns|testel]#testid]'),
- );
+ return [
+ ['#testid', 'Hash[Element[*]#testid]'],
+ ['testel#testid', 'Hash[Element[testel]#testid]'],
+ ['testns|#testid', 'Hash[Element[testns|*]#testid]'],
+ ['testns|*#testid', 'Hash[Element[testns|*]#testid]'],
+ ['testns|testel#testid', 'Hash[Element[testns|testel]#testid]'],
+ ];
}
}
diff --git a/application/vendor/symfony/css-selector/Tests/Parser/TokenStreamTest.php b/application/vendor/symfony/css-selector/Tests/Parser/TokenStreamTest.php
index 44c751a..fb47625 100644
--- a/application/vendor/symfony/css-selector/Tests/Parser/TokenStreamTest.php
+++ b/application/vendor/symfony/css-selector/Tests/Parser/TokenStreamTest.php
@@ -53,7 +53,7 @@ public function testGetNextIdentifier()
public function testFailToGetNextIdentifier()
{
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
+ $this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
$stream = new TokenStream();
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
@@ -73,7 +73,7 @@ public function testGetNextIdentifierOrStar()
public function testFailToGetNextIdentifierOrStar()
{
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
+ $this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
$stream = new TokenStream();
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
diff --git a/application/vendor/symfony/css-selector/Tests/XPath/TranslatorTest.php b/application/vendor/symfony/css-selector/Tests/XPath/TranslatorTest.php
index 6104582..a718fbd 100644
--- a/application/vendor/symfony/css-selector/Tests/XPath/TranslatorTest.php
+++ b/application/vendor/symfony/css-selector/Tests/XPath/TranslatorTest.php
@@ -12,8 +12,12 @@
namespace Symfony\Component\CssSelector\Tests\XPath;
use PHPUnit\Framework\TestCase;
+use Symfony\Component\CssSelector\Node\ElementNode;
+use Symfony\Component\CssSelector\Node\FunctionNode;
+use Symfony\Component\CssSelector\Parser\Parser;
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
use Symfony\Component\CssSelector\XPath\Translator;
+use Symfony\Component\CssSelector\XPath\XPathExpr;
class TranslatorTest extends TestCase
{
@@ -31,6 +35,61 @@ public function testCssToXPath($css, $xpath)
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
}
+ public function testCssToXPathPseudoElement()
+ {
+ $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException');
+ $translator = new Translator();
+ $translator->registerExtension(new HtmlExtension($translator));
+ $translator->cssToXPath('e::first-line');
+ }
+
+ public function testGetExtensionNotExistsExtension()
+ {
+ $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException');
+ $translator = new Translator();
+ $translator->registerExtension(new HtmlExtension($translator));
+ $translator->getExtension('fake');
+ }
+
+ public function testAddCombinationNotExistsExtension()
+ {
+ $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException');
+ $translator = new Translator();
+ $translator->registerExtension(new HtmlExtension($translator));
+ $parser = new Parser();
+ $xpath = $parser->parse('*')[0];
+ $combinedXpath = $parser->parse('*')[0];
+ $translator->addCombination('fake', $xpath, $combinedXpath);
+ }
+
+ public function testAddFunctionNotExistsFunction()
+ {
+ $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException');
+ $translator = new Translator();
+ $translator->registerExtension(new HtmlExtension($translator));
+ $xpath = new XPathExpr();
+ $function = new FunctionNode(new ElementNode(), 'fake');
+ $translator->addFunction($xpath, $function);
+ }
+
+ public function testAddPseudoClassNotExistsClass()
+ {
+ $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException');
+ $translator = new Translator();
+ $translator->registerExtension(new HtmlExtension($translator));
+ $xpath = new XPathExpr();
+ $translator->addPseudoClass($xpath, 'fake');
+ }
+
+ public function testAddAttributeMatchingClassNotExistsClass()
+ {
+ $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException');
+ $translator = new Translator();
+ $translator->registerExtension(new HtmlExtension($translator));
+ $xpath = new XPathExpr();
+ $translator->addAttributeMatching($xpath, '', '', '');
+ }
+
/** @dataProvider getXmlLangTestData */
public function testXmlLang($css, array $elementsId)
{
@@ -39,7 +98,7 @@ public function testXmlLang($css, array $elementsId)
$elements = $document->xpath($translator->cssToXPath($css));
$this->assertCount(\count($elementsId), $elements);
foreach ($elements as $element) {
- $this->assertTrue(\in_array($element->attributes()->id, $elementsId));
+ $this->assertContains((string) $element->attributes()->id, $elementsId);
}
}
@@ -57,7 +116,7 @@ public function testHtmlIds($css, array $elementsId)
$this->assertCount(\count($elementsId), $elementsId);
foreach ($elements as $element) {
if (null !== $element->attributes()->id) {
- $this->assertTrue(\in_array($element->attributes()->id, $elementsId));
+ $this->assertContains((string) $element->attributes()->id, $elementsId);
}
}
libxml_clear_errors();
@@ -78,250 +137,277 @@ public function testHtmlShakespear($css, $count)
$this->assertCount($count, $elements);
}
+ public function testOnlyOfTypeFindsSingleChildrenOfGivenType()
+ {
+ $translator = new Translator();
+ $translator->registerExtension(new HtmlExtension($translator));
+ $document = new \DOMDocument();
+ $document->loadHTML(<<<'HTML'
+
+
+
+ A
+
+
+ B
+ C
+
+
+
+HTML
+);
+
+ $xpath = new \DOMXPath($document);
+ $nodeList = $xpath->query($translator->cssToXPath('span:only-of-type'));
+
+ $this->assertSame(1, $nodeList->length);
+ $this->assertSame('A', $nodeList->item(0)->textContent);
+ }
+
public function getXpathLiteralTestData()
{
- return array(
- array('foo', "'foo'"),
- array("foo's bar", '"foo\'s bar"'),
- array("foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'),
- array("foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'),
- );
+ return [
+ ['foo', "'foo'"],
+ ["foo's bar", '"foo\'s bar"'],
+ ["foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'],
+ ["foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'],
+ ];
}
public function getCssToXPathTestData()
{
- return array(
- array('*', '*'),
- array('e', 'e'),
- array('*|e', 'e'),
- array('e|f', 'e:f'),
- array('e[foo]', 'e[@foo]'),
- array('e[foo|bar]', 'e[@foo:bar]'),
- array('e[foo="bar"]', "e[@foo = 'bar']"),
- array('e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"),
- array('e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"),
- array('e[foo$="bar"]', "e[@foo and substring(@foo, string-length(@foo)-2) = 'bar']"),
- array('e[foo*="bar"]', "e[@foo and contains(@foo, 'bar')]"),
- array('e[foo!="bar"]', "e[not(@foo) or @foo != 'bar']"),
- array('e[foo!="bar"][foo!="baz"]', "e[(not(@foo) or @foo != 'bar') and (not(@foo) or @foo != 'baz')]"),
- array('e[hreflang|="en"]', "e[@hreflang and (@hreflang = 'en' or starts-with(@hreflang, 'en-'))]"),
- array('e:nth-child(1)', "*/*[(name() = 'e') and (position() = 1)]"),
- array('e:nth-last-child(1)', "*/*[(name() = 'e') and (position() = last() - 0)]"),
- array('e:nth-last-child(2n+2)', "*/*[(name() = 'e') and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"),
- array('e:nth-of-type(1)', '*/e[position() = 1]'),
- array('e:nth-last-of-type(1)', '*/e[position() = last() - 0]'),
- array('div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"),
- array('e:first-child', "*/*[(name() = 'e') and (position() = 1)]"),
- array('e:last-child', "*/*[(name() = 'e') and (position() = last())]"),
- array('e:first-of-type', '*/e[position() = 1]'),
- array('e:last-of-type', '*/e[position() = last()]'),
- array('e:only-child', "*/*[(name() = 'e') and (last() = 1)]"),
- array('e:only-of-type', 'e[last() = 1]'),
- array('e:empty', 'e[not(*) and not(string-length())]'),
- array('e:EmPTY', 'e[not(*) and not(string-length())]'),
- array('e:root', 'e[not(parent::*)]'),
- array('e:hover', 'e[0]'),
- array('e:contains("foo")', "e[contains(string(.), 'foo')]"),
- array('e:ConTains(foo)', "e[contains(string(.), 'foo')]"),
- array('e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"),
- array('e#myid', "e[@id = 'myid']"),
- array('e:not(:nth-child(odd))', 'e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]'),
- array('e:nOT(*)', 'e[0]'),
- array('e f', 'e/descendant-or-self::*/f'),
- array('e > f', 'e/f'),
- array('e + f', "e/following-sibling::*[(name() = 'f') and (position() = 1)]"),
- array('e ~ f', 'e/following-sibling::f'),
- array('div#container p', "div[@id = 'container']/descendant-or-self::*/p"),
- );
+ return [
+ ['*', '*'],
+ ['e', 'e'],
+ ['*|e', 'e'],
+ ['e|f', 'e:f'],
+ ['e[foo]', 'e[@foo]'],
+ ['e[foo|bar]', 'e[@foo:bar]'],
+ ['e[foo="bar"]', "e[@foo = 'bar']"],
+ ['e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"],
+ ['e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"],
+ ['e[foo$="bar"]', "e[@foo and substring(@foo, string-length(@foo)-2) = 'bar']"],
+ ['e[foo*="bar"]', "e[@foo and contains(@foo, 'bar')]"],
+ ['e[foo!="bar"]', "e[not(@foo) or @foo != 'bar']"],
+ ['e[foo!="bar"][foo!="baz"]', "e[(not(@foo) or @foo != 'bar') and (not(@foo) or @foo != 'baz')]"],
+ ['e[hreflang|="en"]', "e[@hreflang and (@hreflang = 'en' or starts-with(@hreflang, 'en-'))]"],
+ ['e:nth-child(1)', "*/*[(name() = 'e') and (position() = 1)]"],
+ ['e:nth-last-child(1)', "*/*[(name() = 'e') and (position() = last() - 0)]"],
+ ['e:nth-last-child(2n+2)', "*/*[(name() = 'e') and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"],
+ ['e:nth-of-type(1)', '*/e[position() = 1]'],
+ ['e:nth-last-of-type(1)', '*/e[position() = last() - 0]'],
+ ['div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"],
+ ['e:first-child', "*/*[(name() = 'e') and (position() = 1)]"],
+ ['e:last-child', "*/*[(name() = 'e') and (position() = last())]"],
+ ['e:first-of-type', '*/e[position() = 1]'],
+ ['e:last-of-type', '*/e[position() = last()]'],
+ ['e:only-child', "*/*[(name() = 'e') and (last() = 1)]"],
+ ['e:only-of-type', 'e[count(preceding-sibling::e)=0 and count(following-sibling::e)=0]'],
+ ['e:empty', 'e[not(*) and not(string-length())]'],
+ ['e:EmPTY', 'e[not(*) and not(string-length())]'],
+ ['e:root', 'e[not(parent::*)]'],
+ ['e:hover', 'e[0]'],
+ ['e:contains("foo")', "e[contains(string(.), 'foo')]"],
+ ['e:ConTains(foo)', "e[contains(string(.), 'foo')]"],
+ ['e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"],
+ ['e#myid', "e[@id = 'myid']"],
+ ['e:not(:nth-child(odd))', 'e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]'],
+ ['e:nOT(*)', 'e[0]'],
+ ['e f', 'e/descendant-or-self::*/f'],
+ ['e > f', 'e/f'],
+ ['e + f', "e/following-sibling::*[(name() = 'f') and (position() = 1)]"],
+ ['e ~ f', 'e/following-sibling::f'],
+ ['div#container p', "div[@id = 'container']/descendant-or-self::*/p"],
+ ];
}
public function getXmlLangTestData()
{
- return array(
- array(':lang("EN")', array('first', 'second', 'third', 'fourth')),
- array(':lang("en-us")', array('second', 'fourth')),
- array(':lang(en-nz)', array('third')),
- array(':lang(fr)', array('fifth')),
- array(':lang(ru)', array('sixth')),
- array(":lang('ZH')", array('eighth')),
- array(':lang(de) :lang(zh)', array('eighth')),
- array(':lang(en), :lang(zh)', array('first', 'second', 'third', 'fourth', 'eighth')),
- array(':lang(es)', array()),
- );
+ return [
+ [':lang("EN")', ['first', 'second', 'third', 'fourth']],
+ [':lang("en-us")', ['second', 'fourth']],
+ [':lang(en-nz)', ['third']],
+ [':lang(fr)', ['fifth']],
+ [':lang(ru)', ['sixth']],
+ [":lang('ZH')", ['eighth']],
+ [':lang(de) :lang(zh)', ['eighth']],
+ [':lang(en), :lang(zh)', ['first', 'second', 'third', 'fourth', 'eighth']],
+ [':lang(es)', []],
+ ];
}
public function getHtmlIdsTestData()
{
- return array(
- array('div', array('outer-div', 'li-div', 'foobar-div')),
- array('DIV', array('outer-div', 'li-div', 'foobar-div')), // case-insensitive in HTML
- array('div div', array('li-div')),
- array('div, div div', array('outer-div', 'li-div', 'foobar-div')),
- array('a[name]', array('name-anchor')),
- array('a[NAme]', array('name-anchor')), // case-insensitive in HTML:
- array('a[rel]', array('tag-anchor', 'nofollow-anchor')),
- array('a[rel="tag"]', array('tag-anchor')),
- array('a[href*="localhost"]', array('tag-anchor')),
- array('a[href*=""]', array()),
- array('a[href^="http"]', array('tag-anchor', 'nofollow-anchor')),
- array('a[href^="http:"]', array('tag-anchor')),
- array('a[href^=""]', array()),
- array('a[href$="org"]', array('nofollow-anchor')),
- array('a[href$=""]', array()),
- array('div[foobar~="bc"]', array('foobar-div')),
- array('div[foobar~="cde"]', array('foobar-div')),
- array('[foobar~="ab bc"]', array('foobar-div')),
- array('[foobar~=""]', array()),
- array('[foobar~=" \t"]', array()),
- array('div[foobar~="cd"]', array()),
- array('*[lang|="En"]', array('second-li')),
- array('[lang|="En-us"]', array('second-li')),
+ return [
+ ['div', ['outer-div', 'li-div', 'foobar-div']],
+ ['DIV', ['outer-div', 'li-div', 'foobar-div']], // case-insensitive in HTML
+ ['div div', ['li-div']],
+ ['div, div div', ['outer-div', 'li-div', 'foobar-div']],
+ ['a[name]', ['name-anchor']],
+ ['a[NAme]', ['name-anchor']], // case-insensitive in HTML:
+ ['a[rel]', ['tag-anchor', 'nofollow-anchor']],
+ ['a[rel="tag"]', ['tag-anchor']],
+ ['a[href*="localhost"]', ['tag-anchor']],
+ ['a[href*=""]', []],
+ ['a[href^="http"]', ['tag-anchor', 'nofollow-anchor']],
+ ['a[href^="http:"]', ['tag-anchor']],
+ ['a[href^=""]', []],
+ ['a[href$="org"]', ['nofollow-anchor']],
+ ['a[href$=""]', []],
+ ['div[foobar~="bc"]', ['foobar-div']],
+ ['div[foobar~="cde"]', ['foobar-div']],
+ ['[foobar~="ab bc"]', ['foobar-div']],
+ ['[foobar~=""]', []],
+ ['[foobar~=" \t"]', []],
+ ['div[foobar~="cd"]', []],
+ ['*[lang|="En"]', ['second-li']],
+ ['[lang|="En-us"]', ['second-li']],
// Attribute values are case sensitive
- array('*[lang|="en"]', array()),
- array('[lang|="en-US"]', array()),
- array('*[lang|="e"]', array()),
+ ['*[lang|="en"]', []],
+ ['[lang|="en-US"]', []],
+ ['*[lang|="e"]', []],
// ... :lang() is not.
- array(':lang("EN")', array('second-li', 'li-div')),
- array('*:lang(en-US)', array('second-li', 'li-div')),
- array(':lang("e")', array()),
- array('li:nth-child(3)', array('third-li')),
- array('li:nth-child(10)', array()),
- array('li:nth-child(2n)', array('second-li', 'fourth-li', 'sixth-li')),
- array('li:nth-child(even)', array('second-li', 'fourth-li', 'sixth-li')),
- array('li:nth-child(2n+0)', array('second-li', 'fourth-li', 'sixth-li')),
- array('li:nth-child(+2n+1)', array('first-li', 'third-li', 'fifth-li', 'seventh-li')),
- array('li:nth-child(odd)', array('first-li', 'third-li', 'fifth-li', 'seventh-li')),
- array('li:nth-child(2n+4)', array('fourth-li', 'sixth-li')),
- array('li:nth-child(3n+1)', array('first-li', 'fourth-li', 'seventh-li')),
- array('li:nth-child(n)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-child(n-1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-child(n+1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-child(n+3)', array('third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-child(-n)', array()),
- array('li:nth-child(-n-1)', array()),
- array('li:nth-child(-n+1)', array('first-li')),
- array('li:nth-child(-n+3)', array('first-li', 'second-li', 'third-li')),
- array('li:nth-last-child(0)', array()),
- array('li:nth-last-child(2n)', array('second-li', 'fourth-li', 'sixth-li')),
- array('li:nth-last-child(even)', array('second-li', 'fourth-li', 'sixth-li')),
- array('li:nth-last-child(2n+2)', array('second-li', 'fourth-li', 'sixth-li')),
- array('li:nth-last-child(n)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-last-child(n-1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-last-child(n-3)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-last-child(n+1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')),
- array('li:nth-last-child(n+3)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li')),
- array('li:nth-last-child(-n)', array()),
- array('li:nth-last-child(-n-1)', array()),
- array('li:nth-last-child(-n+1)', array('seventh-li')),
- array('li:nth-last-child(-n+3)', array('fifth-li', 'sixth-li', 'seventh-li')),
- array('ol:first-of-type', array('first-ol')),
- array('ol:nth-child(1)', array('first-ol')),
- array('ol:nth-of-type(2)', array('second-ol')),
- array('ol:nth-last-of-type(1)', array('second-ol')),
- array('span:only-child', array('foobar-span')),
- array('li div:only-child', array('li-div')),
- array('div *:only-child', array('li-div', 'foobar-span')),
- array('p:only-of-type', array('paragraph')),
- array('a:empty', array('name-anchor')),
- array('a:EMpty', array('name-anchor')),
- array('li:empty', array('third-li', 'fourth-li', 'fifth-li', 'sixth-li')),
- array(':root', array('html')),
- array('html:root', array('html')),
- array('li:root', array()),
- array('* :root', array()),
- array('*:contains("link")', array('html', 'outer-div', 'tag-anchor', 'nofollow-anchor')),
- array(':CONtains("link")', array('html', 'outer-div', 'tag-anchor', 'nofollow-anchor')),
- array('*:contains("LInk")', array()), // case sensitive
- array('*:contains("e")', array('html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em')),
- array('*:contains("E")', array()), // case-sensitive
- array('.a', array('first-ol')),
- array('.b', array('first-ol')),
- array('*.a', array('first-ol')),
- array('ol.a', array('first-ol')),
- array('.c', array('first-ol', 'third-li', 'fourth-li')),
- array('*.c', array('first-ol', 'third-li', 'fourth-li')),
- array('ol *.c', array('third-li', 'fourth-li')),
- array('ol li.c', array('third-li', 'fourth-li')),
- array('li ~ li.c', array('third-li', 'fourth-li')),
- array('ol > li.c', array('third-li', 'fourth-li')),
- array('#first-li', array('first-li')),
- array('li#first-li', array('first-li')),
- array('*#first-li', array('first-li')),
- array('li div', array('li-div')),
- array('li > div', array('li-div')),
- array('div div', array('li-div')),
- array('div > div', array()),
- array('div>.c', array('first-ol')),
- array('div > .c', array('first-ol')),
- array('div + div', array('foobar-div')),
- array('a ~ a', array('tag-anchor', 'nofollow-anchor')),
- array('a[rel="tag"] ~ a', array('nofollow-anchor')),
- array('ol#first-ol li:last-child', array('seventh-li')),
- array('ol#first-ol *:last-child', array('li-div', 'seventh-li')),
- array('#outer-div:first-child', array('outer-div')),
- array('#outer-div :first-child', array('name-anchor', 'first-li', 'li-div', 'p-b', 'checkbox-fieldset-disabled', 'area-href')),
- array('a[href]', array('tag-anchor', 'nofollow-anchor')),
- array(':not(*)', array()),
- array('a:not([href])', array('name-anchor')),
- array('ol :Not(li[class])', array('first-li', 'second-li', 'li-div', 'fifth-li', 'sixth-li', 'seventh-li')),
+ [':lang("EN")', ['second-li', 'li-div']],
+ ['*:lang(en-US)', ['second-li', 'li-div']],
+ [':lang("e")', []],
+ ['li:nth-child(3)', ['third-li']],
+ ['li:nth-child(10)', []],
+ ['li:nth-child(2n)', ['second-li', 'fourth-li', 'sixth-li']],
+ ['li:nth-child(even)', ['second-li', 'fourth-li', 'sixth-li']],
+ ['li:nth-child(2n+0)', ['second-li', 'fourth-li', 'sixth-li']],
+ ['li:nth-child(+2n+1)', ['first-li', 'third-li', 'fifth-li', 'seventh-li']],
+ ['li:nth-child(odd)', ['first-li', 'third-li', 'fifth-li', 'seventh-li']],
+ ['li:nth-child(2n+4)', ['fourth-li', 'sixth-li']],
+ ['li:nth-child(3n+1)', ['first-li', 'fourth-li', 'seventh-li']],
+ ['li:nth-child(n)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-child(n-1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-child(n+1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-child(n+3)', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-child(-n)', []],
+ ['li:nth-child(-n-1)', []],
+ ['li:nth-child(-n+1)', ['first-li']],
+ ['li:nth-child(-n+3)', ['first-li', 'second-li', 'third-li']],
+ ['li:nth-last-child(0)', []],
+ ['li:nth-last-child(2n)', ['second-li', 'fourth-li', 'sixth-li']],
+ ['li:nth-last-child(even)', ['second-li', 'fourth-li', 'sixth-li']],
+ ['li:nth-last-child(2n+2)', ['second-li', 'fourth-li', 'sixth-li']],
+ ['li:nth-last-child(n)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-last-child(n-1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-last-child(n-3)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-last-child(n+1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']],
+ ['li:nth-last-child(n+3)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li']],
+ ['li:nth-last-child(-n)', []],
+ ['li:nth-last-child(-n-1)', []],
+ ['li:nth-last-child(-n+1)', ['seventh-li']],
+ ['li:nth-last-child(-n+3)', ['fifth-li', 'sixth-li', 'seventh-li']],
+ ['ol:first-of-type', ['first-ol']],
+ ['ol:nth-child(1)', ['first-ol']],
+ ['ol:nth-of-type(2)', ['second-ol']],
+ ['ol:nth-last-of-type(1)', ['second-ol']],
+ ['span:only-child', ['foobar-span']],
+ ['li div:only-child', ['li-div']],
+ ['div *:only-child', ['li-div', 'foobar-span']],
+ ['p:only-of-type', ['paragraph']],
+ ['a:empty', ['name-anchor']],
+ ['a:EMpty', ['name-anchor']],
+ ['li:empty', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li']],
+ [':root', ['html']],
+ ['html:root', ['html']],
+ ['li:root', []],
+ ['* :root', []],
+ ['*:contains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
+ [':CONtains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
+ ['*:contains("LInk")', []], // case sensitive
+ ['*:contains("e")', ['html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em']],
+ ['*:contains("E")', []], // case-sensitive
+ ['.a', ['first-ol']],
+ ['.b', ['first-ol']],
+ ['*.a', ['first-ol']],
+ ['ol.a', ['first-ol']],
+ ['.c', ['first-ol', 'third-li', 'fourth-li']],
+ ['*.c', ['first-ol', 'third-li', 'fourth-li']],
+ ['ol *.c', ['third-li', 'fourth-li']],
+ ['ol li.c', ['third-li', 'fourth-li']],
+ ['li ~ li.c', ['third-li', 'fourth-li']],
+ ['ol > li.c', ['third-li', 'fourth-li']],
+ ['#first-li', ['first-li']],
+ ['li#first-li', ['first-li']],
+ ['*#first-li', ['first-li']],
+ ['li div', ['li-div']],
+ ['li > div', ['li-div']],
+ ['div div', ['li-div']],
+ ['div > div', []],
+ ['div>.c', ['first-ol']],
+ ['div > .c', ['first-ol']],
+ ['div + div', ['foobar-div']],
+ ['a ~ a', ['tag-anchor', 'nofollow-anchor']],
+ ['a[rel="tag"] ~ a', ['nofollow-anchor']],
+ ['ol#first-ol li:last-child', ['seventh-li']],
+ ['ol#first-ol *:last-child', ['li-div', 'seventh-li']],
+ ['#outer-div:first-child', ['outer-div']],
+ ['#outer-div :first-child', ['name-anchor', 'first-li', 'li-div', 'p-b', 'checkbox-fieldset-disabled', 'area-href']],
+ ['a[href]', ['tag-anchor', 'nofollow-anchor']],
+ [':not(*)', []],
+ ['a:not([href])', ['name-anchor']],
+ ['ol :Not(li[class])', ['first-li', 'second-li', 'li-div', 'fifth-li', 'sixth-li', 'seventh-li']],
// HTML-specific
- array(':link', array('link-href', 'tag-anchor', 'nofollow-anchor', 'area-href')),
- array(':visited', array()),
- array(':enabled', array('link-href', 'tag-anchor', 'nofollow-anchor', 'checkbox-unchecked', 'text-checked', 'checkbox-checked', 'area-href')),
- array(':disabled', array('checkbox-disabled', 'checkbox-disabled-checked', 'fieldset', 'checkbox-fieldset-disabled')),
- array(':checked', array('checkbox-checked', 'checkbox-disabled-checked')),
- );
+ [':link', ['link-href', 'tag-anchor', 'nofollow-anchor', 'area-href']],
+ [':visited', []],
+ [':enabled', ['link-href', 'tag-anchor', 'nofollow-anchor', 'checkbox-unchecked', 'text-checked', 'checkbox-checked', 'area-href']],
+ [':disabled', ['checkbox-disabled', 'checkbox-disabled-checked', 'fieldset', 'checkbox-fieldset-disabled']],
+ [':checked', ['checkbox-checked', 'checkbox-disabled-checked']],
+ ];
}
public function getHtmlShakespearTestData()
{
- return array(
- array('*', 246),
- array('div:contains(CELIA)', 26),
- array('div:only-child', 22), // ?
- array('div:nth-child(even)', 106),
- array('div:nth-child(2n)', 106),
- array('div:nth-child(odd)', 137),
- array('div:nth-child(2n+1)', 137),
- array('div:nth-child(n)', 243),
- array('div:last-child', 53),
- array('div:first-child', 51),
- array('div > div', 242),
- array('div + div', 190),
- array('div ~ div', 190),
- array('body', 1),
- array('body div', 243),
- array('div', 243),
- array('div div', 242),
- array('div div div', 241),
- array('div, div, div', 243),
- array('div, a, span', 243),
- array('.dialog', 51),
- array('div.dialog', 51),
- array('div .dialog', 51),
- array('div.character, div.dialog', 99),
- array('div.direction.dialog', 0),
- array('div.dialog.direction', 0),
- array('div.dialog.scene', 1),
- array('div.scene.scene', 1),
- array('div.scene .scene', 0),
- array('div.direction .dialog ', 0),
- array('div .dialog .direction', 4),
- array('div.dialog .dialog .direction', 4),
- array('#speech5', 1),
- array('div#speech5', 1),
- array('div #speech5', 1),
- array('div.scene div.dialog', 49),
- array('div#scene1 div.dialog div', 142),
- array('#scene1 #speech1', 1),
- array('div[class]', 103),
- array('div[class=dialog]', 50),
- array('div[class^=dia]', 51),
- array('div[class$=log]', 50),
- array('div[class*=sce]', 1),
- array('div[class|=dialog]', 50), // ? Seems right
- array('div[class!=madeup]', 243), // ? Seems right
- array('div[class~=dialog]', 51), // ? Seems right
- );
+ return [
+ ['*', 246],
+ ['div:contains(CELIA)', 26],
+ ['div:only-child', 22], // ?
+ ['div:nth-child(even)', 106],
+ ['div:nth-child(2n)', 106],
+ ['div:nth-child(odd)', 137],
+ ['div:nth-child(2n+1)', 137],
+ ['div:nth-child(n)', 243],
+ ['div:last-child', 53],
+ ['div:first-child', 51],
+ ['div > div', 242],
+ ['div + div', 190],
+ ['div ~ div', 190],
+ ['body', 1],
+ ['body div', 243],
+ ['div', 243],
+ ['div div', 242],
+ ['div div div', 241],
+ ['div, div, div', 243],
+ ['div, a, span', 243],
+ ['.dialog', 51],
+ ['div.dialog', 51],
+ ['div .dialog', 51],
+ ['div.character, div.dialog', 99],
+ ['div.direction.dialog', 0],
+ ['div.dialog.direction', 0],
+ ['div.dialog.scene', 1],
+ ['div.scene.scene', 1],
+ ['div.scene .scene', 0],
+ ['div.direction .dialog ', 0],
+ ['div .dialog .direction', 4],
+ ['div.dialog .dialog .direction', 4],
+ ['#speech5', 1],
+ ['div#speech5', 1],
+ ['div #speech5', 1],
+ ['div.scene div.dialog', 49],
+ ['div#scene1 div.dialog div', 142],
+ ['#scene1 #speech1', 1],
+ ['div[class]', 103],
+ ['div[class=dialog]', 50],
+ ['div[class^=dia]', 51],
+ ['div[class$=log]', 50],
+ ['div[class*=sce]', 1],
+ ['div[class|=dialog]', 50], // ? Seems right
+ ['div[class!=madeup]', 243], // ? Seems right
+ ['div[class~=dialog]', 51], // ? Seems right
+ ];
}
}
diff --git a/application/vendor/symfony/css-selector/XPath/Extension/AbstractExtension.php b/application/vendor/symfony/css-selector/XPath/Extension/AbstractExtension.php
index 026ac06..1dce1ed 100644
--- a/application/vendor/symfony/css-selector/XPath/Extension/AbstractExtension.php
+++ b/application/vendor/symfony/css-selector/XPath/Extension/AbstractExtension.php
@@ -28,7 +28,7 @@ abstract class AbstractExtension implements ExtensionInterface
*/
public function getNodeTranslators()
{
- return array();
+ return [];
}
/**
@@ -36,7 +36,7 @@ public function getNodeTranslators()
*/
public function getCombinationTranslators()
{
- return array();
+ return [];
}
/**
@@ -44,7 +44,7 @@ public function getCombinationTranslators()
*/
public function getFunctionTranslators()
{
- return array();
+ return [];
}
/**
@@ -52,7 +52,7 @@ public function getFunctionTranslators()
*/
public function getPseudoClassTranslators()
{
- return array();
+ return [];
}
/**
@@ -60,6 +60,6 @@ public function getPseudoClassTranslators()
*/
public function getAttributeMatchingTranslators()
{
- return array();
+ return [];
}
}
diff --git a/application/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php b/application/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php
index 2078dca..f27878b 100644
--- a/application/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php
+++ b/application/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php
@@ -31,22 +31,21 @@ class AttributeMatchingExtension extends AbstractExtension
*/
public function getAttributeMatchingTranslators()
{
- return array(
- 'exists' => array($this, 'translateExists'),
- '=' => array($this, 'translateEquals'),
- '~=' => array($this, 'translateIncludes'),
- '|=' => array($this, 'translateDashMatch'),
- '^=' => array($this, 'translatePrefixMatch'),
- '$=' => array($this, 'translateSuffixMatch'),
- '*=' => array($this, 'translateSubstringMatch'),
- '!=' => array($this, 'translateDifferent'),
- );
+ return [
+ 'exists' => [$this, 'translateExists'],
+ '=' => [$this, 'translateEquals'],
+ '~=' => [$this, 'translateIncludes'],
+ '|=' => [$this, 'translateDashMatch'],
+ '^=' => [$this, 'translatePrefixMatch'],
+ '$=' => [$this, 'translateSuffixMatch'],
+ '*=' => [$this, 'translateSubstringMatch'],
+ '!=' => [$this, 'translateDifferent'],
+ ];
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
@@ -56,9 +55,8 @@ public function translateExists(XPathExpr $xpath, $attribute, $value)
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
@@ -68,9 +66,8 @@ public function translateEquals(XPathExpr $xpath, $attribute, $value)
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
@@ -84,9 +81,8 @@ public function translateIncludes(XPathExpr $xpath, $attribute, $value)
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
@@ -101,9 +97,8 @@ public function translateDashMatch(XPathExpr $xpath, $attribute, $value)
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
@@ -117,9 +112,8 @@ public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value)
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
@@ -134,9 +128,8 @@ public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value)
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
@@ -150,9 +143,8 @@ public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value)
}
/**
- * @param XPathExpr $xpath
- * @param string $attribute
- * @param string $value
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*/
diff --git a/application/vendor/symfony/css-selector/XPath/Extension/CombinationExtension.php b/application/vendor/symfony/css-selector/XPath/Extension/CombinationExtension.php
index 0c9cc03..d962dc5 100644
--- a/application/vendor/symfony/css-selector/XPath/Extension/CombinationExtension.php
+++ b/application/vendor/symfony/css-selector/XPath/Extension/CombinationExtension.php
@@ -30,12 +30,12 @@ class CombinationExtension extends AbstractExtension
*/
public function getCombinationTranslators()
{
- return array(
- ' ' => array($this, 'translateDescendant'),
- '>' => array($this, 'translateChild'),
- '+' => array($this, 'translateDirectAdjacent'),
- '~' => array($this, 'translateIndirectAdjacent'),
- );
+ return [
+ ' ' => [$this, 'translateDescendant'],
+ '>' => [$this, 'translateChild'],
+ '+' => [$this, 'translateDirectAdjacent'],
+ '~' => [$this, 'translateIndirectAdjacent'],
+ ];
}
/**
diff --git a/application/vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php b/application/vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php
index 4d34d0e..a121ab8 100644
--- a/application/vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php
+++ b/application/vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php
@@ -35,21 +35,19 @@ class FunctionExtension extends AbstractExtension
*/
public function getFunctionTranslators()
{
- return array(
- 'nth-child' => array($this, 'translateNthChild'),
- 'nth-last-child' => array($this, 'translateNthLastChild'),
- 'nth-of-type' => array($this, 'translateNthOfType'),
- 'nth-last-of-type' => array($this, 'translateNthLastOfType'),
- 'contains' => array($this, 'translateContains'),
- 'lang' => array($this, 'translateLang'),
- );
+ return [
+ 'nth-child' => [$this, 'translateNthChild'],
+ 'nth-last-child' => [$this, 'translateNthLastChild'],
+ 'nth-of-type' => [$this, 'translateNthOfType'],
+ 'nth-last-of-type' => [$this, 'translateNthLastOfType'],
+ 'contains' => [$this, 'translateContains'],
+ 'lang' => [$this, 'translateLang'],
+ ];
}
/**
- * @param XPathExpr $xpath
- * @param FunctionNode $function
- * @param bool $last
- * @param bool $addNameTest
+ * @param bool $last
+ * @param bool $addNameTest
*
* @return XPathExpr
*
@@ -60,7 +58,7 @@ public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $las
try {
list($a, $b) = Parser::parseSeries($function->getArguments());
} catch (SyntaxErrorException $e) {
- throw new ExpressionErrorException(sprintf('Invalid series: %s', implode(', ', $function->getArguments())), 0, $e);
+ throw new ExpressionErrorException(sprintf('Invalid series: "%s".', implode('", "', $function->getArguments())), 0, $e);
}
$xpath->addStarPrefix();
@@ -93,7 +91,7 @@ public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $las
$expr .= ' - '.$b;
}
- $conditions = array(sprintf('%s %s 0', $expr, $sign));
+ $conditions = [sprintf('%s %s 0', $expr, $sign)];
if (1 !== $a && -1 !== $a) {
$conditions[] = sprintf('(%s) mod %d = 0', $expr, $a);
diff --git a/application/vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php b/application/vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php
index cd8e0d5..99c1166 100644
--- a/application/vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php
+++ b/application/vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php
@@ -41,16 +41,16 @@ public function __construct(Translator $translator)
*/
public function getPseudoClassTranslators()
{
- return array(
- 'checked' => array($this, 'translateChecked'),
- 'link' => array($this, 'translateLink'),
- 'disabled' => array($this, 'translateDisabled'),
- 'enabled' => array($this, 'translateEnabled'),
- 'selected' => array($this, 'translateSelected'),
- 'invalid' => array($this, 'translateInvalid'),
- 'hover' => array($this, 'translateHover'),
- 'visited' => array($this, 'translateVisited'),
- );
+ return [
+ 'checked' => [$this, 'translateChecked'],
+ 'link' => [$this, 'translateLink'],
+ 'disabled' => [$this, 'translateDisabled'],
+ 'enabled' => [$this, 'translateEnabled'],
+ 'selected' => [$this, 'translateSelected'],
+ 'invalid' => [$this, 'translateInvalid'],
+ 'hover' => [$this, 'translateHover'],
+ 'visited' => [$this, 'translateVisited'],
+ ];
}
/**
@@ -58,9 +58,9 @@ public function getPseudoClassTranslators()
*/
public function getFunctionTranslators()
{
- return array(
- 'lang' => array($this, 'translateLang'),
- );
+ return [
+ 'lang' => [$this, 'translateLang'],
+ ];
}
/**
diff --git a/application/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php b/application/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php
index 715d961..de222af 100644
--- a/application/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php
+++ b/application/vendor/symfony/css-selector/XPath/Extension/NodeExtension.php
@@ -75,17 +75,17 @@ public function hasFlag($flag)
*/
public function getNodeTranslators()
{
- return array(
- 'Selector' => array($this, 'translateSelector'),
- 'CombinedSelector' => array($this, 'translateCombinedSelector'),
- 'Negation' => array($this, 'translateNegation'),
- 'Function' => array($this, 'translateFunction'),
- 'Pseudo' => array($this, 'translatePseudo'),
- 'Attribute' => array($this, 'translateAttribute'),
- 'Class' => array($this, 'translateClass'),
- 'Hash' => array($this, 'translateHash'),
- 'Element' => array($this, 'translateElement'),
- );
+ return [
+ 'Selector' => [$this, 'translateSelector'],
+ 'CombinedSelector' => [$this, 'translateCombinedSelector'],
+ 'Negation' => [$this, 'translateNegation'],
+ 'Function' => [$this, 'translateFunction'],
+ 'Pseudo' => [$this, 'translatePseudo'],
+ 'Attribute' => [$this, 'translateAttribute'],
+ 'Class' => [$this, 'translateClass'],
+ 'Hash' => [$this, 'translateHash'],
+ 'Element' => [$this, 'translateElement'],
+ ];
}
/**
diff --git a/application/vendor/symfony/css-selector/XPath/Extension/PseudoClassExtension.php b/application/vendor/symfony/css-selector/XPath/Extension/PseudoClassExtension.php
index 378dfb7..288a9e6 100644
--- a/application/vendor/symfony/css-selector/XPath/Extension/PseudoClassExtension.php
+++ b/application/vendor/symfony/css-selector/XPath/Extension/PseudoClassExtension.php
@@ -31,16 +31,16 @@ class PseudoClassExtension extends AbstractExtension
*/
public function getPseudoClassTranslators()
{
- return array(
- 'root' => array($this, 'translateRoot'),
- 'first-child' => array($this, 'translateFirstChild'),
- 'last-child' => array($this, 'translateLastChild'),
- 'first-of-type' => array($this, 'translateFirstOfType'),
- 'last-of-type' => array($this, 'translateLastOfType'),
- 'only-child' => array($this, 'translateOnlyChild'),
- 'only-of-type' => array($this, 'translateOnlyOfType'),
- 'empty' => array($this, 'translateEmpty'),
- );
+ return [
+ 'root' => [$this, 'translateRoot'],
+ 'first-child' => [$this, 'translateFirstChild'],
+ 'last-child' => [$this, 'translateLastChild'],
+ 'first-of-type' => [$this, 'translateFirstOfType'],
+ 'last-of-type' => [$this, 'translateLastOfType'],
+ 'only-child' => [$this, 'translateOnlyChild'],
+ 'only-of-type' => [$this, 'translateOnlyOfType'],
+ 'empty' => [$this, 'translateEmpty'],
+ ];
}
/**
@@ -123,11 +123,13 @@ public function translateOnlyChild(XPathExpr $xpath)
*/
public function translateOnlyOfType(XPathExpr $xpath)
{
- if ('*' === $xpath->getElement()) {
+ $element = $xpath->getElement();
+
+ if ('*' === $element) {
throw new ExpressionErrorException('"*:only-of-type" is not implemented.');
}
- return $xpath->addCondition('last() = 1');
+ return $xpath->addCondition(sprintf('count(preceding-sibling::%s)=0 and count(following-sibling::%s)=0', $element, $element));
}
/**
diff --git a/application/vendor/symfony/css-selector/XPath/Translator.php b/application/vendor/symfony/css-selector/XPath/Translator.php
index f8585a0..7388860 100644
--- a/application/vendor/symfony/css-selector/XPath/Translator.php
+++ b/application/vendor/symfony/css-selector/XPath/Translator.php
@@ -35,18 +35,18 @@ class Translator implements TranslatorInterface
/**
* @var ParserInterface[]
*/
- private $shortcutParsers = array();
+ private $shortcutParsers = [];
/**
* @var Extension\ExtensionInterface[]
*/
- private $extensions = array();
+ private $extensions = [];
- private $nodeTranslators = array();
- private $combinationTranslators = array();
- private $functionTranslators = array();
- private $pseudoClassTranslators = array();
- private $attributeMatchingTranslators = array();
+ private $nodeTranslators = [];
+ private $combinationTranslators = [];
+ private $functionTranslators = [];
+ private $pseudoClassTranslators = [];
+ private $attributeMatchingTranslators = [];
public function __construct(ParserInterface $parser = null)
{
@@ -77,7 +77,7 @@ public static function getXpathLiteral($element)
}
$string = $element;
- $parts = array();
+ $parts = [];
while (true) {
if (false !== $pos = strpos($string, "'")) {
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
@@ -180,9 +180,7 @@ public function nodeToXPath(NodeInterface $node)
}
/**
- * @param string $combiner
- * @param NodeInterface $xpath
- * @param NodeInterface $combinedXpath
+ * @param string $combiner
*
* @return XPathExpr
*
@@ -212,8 +210,7 @@ public function addFunction(XPathExpr $xpath, FunctionNode $function)
}
/**
- * @param XPathExpr $xpath
- * @param string $pseudoClass
+ * @param string $pseudoClass
*
* @return XPathExpr
*
@@ -229,10 +226,9 @@ public function addPseudoClass(XPathExpr $xpath, $pseudoClass)
}
/**
- * @param XPathExpr $xpath
- * @param string $operator
- * @param string $attribute
- * @param string $value
+ * @param string $operator
+ * @param string $attribute
+ * @param string $value
*
* @return XPathExpr
*
diff --git a/application/vendor/symfony/css-selector/XPath/TranslatorInterface.php b/application/vendor/symfony/css-selector/XPath/TranslatorInterface.php
index 0b5de83..fdbdf22 100644
--- a/application/vendor/symfony/css-selector/XPath/TranslatorInterface.php
+++ b/application/vendor/symfony/css-selector/XPath/TranslatorInterface.php
@@ -38,8 +38,7 @@ public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::');
/**
* Translates a parsed selector node to an XPath expression.
*
- * @param SelectorNode $selector
- * @param string $prefix
+ * @param string $prefix
*
* @return string
*/
diff --git a/application/vendor/symfony/css-selector/XPath/XPathExpr.php b/application/vendor/symfony/css-selector/XPath/XPathExpr.php
index 63e3ac3..a1e244c 100644
--- a/application/vendor/symfony/css-selector/XPath/XPathExpr.php
+++ b/application/vendor/symfony/css-selector/XPath/XPathExpr.php
@@ -53,8 +53,6 @@ public function getElement()
}
/**
- * @param $condition
- *
* @return $this
*/
public function addCondition($condition)
diff --git a/application/vendor/symfony/css-selector/composer.json b/application/vendor/symfony/css-selector/composer.json
index e5bbdcc..435063f 100644
--- a/application/vendor/symfony/css-selector/composer.json
+++ b/application/vendor/symfony/css-selector/composer.json
@@ -20,7 +20,7 @@
}
],
"require": {
- "php": ">=5.3.9"
+ "php": "^5.5.9|>=7.0.8"
},
"autoload": {
"psr-4": { "Symfony\\Component\\CssSelector\\": "" },
@@ -28,10 +28,5 @@
"/Tests/"
]
},
- "minimum-stability": "dev",
- "extra": {
- "branch-alias": {
- "dev-master": "2.8-dev"
- }
- }
+ "minimum-stability": "dev"
}
diff --git a/application/vendor/symfony/debug/BufferingLogger.php b/application/vendor/symfony/debug/BufferingLogger.php
new file mode 100644
index 0000000..a2ed75b
--- /dev/null
+++ b/application/vendor/symfony/debug/BufferingLogger.php
@@ -0,0 +1,37 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Debug;
+
+use Psr\Log\AbstractLogger;
+
+/**
+ * A buffering logger that stacks logs for later.
+ *
+ * @author Nicolas Grekas
+ */
+class BufferingLogger extends AbstractLogger
+{
+ private $logs = array();
+
+ public function log($level, $message, array $context = array())
+ {
+ $this->logs[] = array($level, $message, $context);
+ }
+
+ public function cleanLogs()
+ {
+ $logs = $this->logs;
+ $this->logs = array();
+
+ return $logs;
+ }
+}
diff --git a/application/vendor/symfony/debug/CHANGELOG.md b/application/vendor/symfony/debug/CHANGELOG.md
index 31f0de9..c81bccf 100644
--- a/application/vendor/symfony/debug/CHANGELOG.md
+++ b/application/vendor/symfony/debug/CHANGELOG.md
@@ -1,6 +1,18 @@
CHANGELOG
=========
+3.0.0
+-----
+
+* removed classes, methods and interfaces deprecated in 2.x
+
+2.8.0
+-----
+
+* added BufferingLogger for errors that happen before a proper logger is configured
+* allow throwing from `__toString()` with `return trigger_error($e, E_USER_ERROR);`
+* deprecate ExceptionHandler::createResponse
+
2.7.0
-----
diff --git a/application/vendor/symfony/debug/Debug.php b/application/vendor/symfony/debug/Debug.php
index 9ae3496..e3665ae 100644
--- a/application/vendor/symfony/debug/Debug.php
+++ b/application/vendor/symfony/debug/Debug.php
@@ -31,7 +31,7 @@ class Debug
* @param int $errorReportingLevel The level of error reporting you want
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
*/
- public static function enable($errorReportingLevel = null, $displayErrors = true)
+ public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
{
if (static::$enabled) {
return;
@@ -42,19 +42,20 @@ public static function enable($errorReportingLevel = null, $displayErrors = true
if (null !== $errorReportingLevel) {
error_reporting($errorReportingLevel);
} else {
- error_reporting(-1);
+ error_reporting(E_ALL);
}
- if (!\in_array(PHP_SAPI, array('cli', 'phpdbg'), true)) {
+ if ('cli' !== PHP_SAPI) {
ini_set('display_errors', 0);
ExceptionHandler::register();
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
// CLI - display errors only if they're not already logged to STDERR
ini_set('display_errors', 1);
}
- $handler = ErrorHandler::register();
- if (!$displayErrors) {
- $handler->throwAt(0, true);
+ if ($displayErrors) {
+ ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
+ } else {
+ ErrorHandler::register()->throwAt(0, true);
}
DebugClassLoader::enable();
diff --git a/application/vendor/symfony/debug/DebugClassLoader.php b/application/vendor/symfony/debug/DebugClassLoader.php
index c34605c..9fd6887 100644
--- a/application/vendor/symfony/debug/DebugClassLoader.php
+++ b/application/vendor/symfony/debug/DebugClassLoader.php
@@ -26,28 +26,20 @@ class DebugClassLoader
{
private $classLoader;
private $isFinder;
- private $loaded = array();
- private $wasFinder;
private static $caseCheck;
private static $deprecated = array();
private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
private static $darwinCache = array('/' => array('/', array()));
/**
- * @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0
+ * Constructor.
+ *
+ * @param callable $classLoader A class loader
*/
- public function __construct($classLoader)
+ public function __construct(callable $classLoader)
{
- $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile');
-
- if ($this->wasFinder) {
- @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
- $this->classLoader = array($classLoader, 'loadClass');
- $this->isFinder = true;
- } else {
- $this->classLoader = $classLoader;
- $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');
- }
+ $this->classLoader = $classLoader;
+ $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');
if (!isset(self::$caseCheck)) {
$file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR);
@@ -76,11 +68,11 @@ public function __construct($classLoader)
/**
* Gets the wrapped class loader.
*
- * @return callable|object A class loader. Since version 2.5, returning an object is @deprecated and support for it will be removed in 3.0
+ * @return callable The wrapped class loader
*/
public function getClassLoader()
{
- return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
+ return $this->classLoader;
}
/**
@@ -131,24 +123,6 @@ public static function disable()
}
}
- /**
- * Finds a file by class name.
- *
- * @param string $class A class name to resolve to file
- *
- * @return string|null
- *
- * @deprecated since version 2.5, to be removed in 3.0.
- */
- public function findFile($class)
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
-
- if ($this->wasFinder) {
- return $this->classLoader[0]->findFile($class);
- }
- }
-
/**
* Loads the given class or interface.
*
@@ -163,30 +137,21 @@ public function loadClass($class)
ErrorHandler::stackErrors();
try {
- if ($this->isFinder && !isset($this->loaded[$class])) {
- $this->loaded[$class] = true;
+ if ($this->isFinder) {
if ($file = $this->classLoader[0]->findFile($class)) {
- require $file;
+ require_once $file;
}
} else {
call_user_func($this->classLoader, $class);
$file = false;
}
- } catch (\Exception $e) {
+ } finally {
ErrorHandler::unstackErrors();
-
- throw $e;
- } catch (\Throwable $e) {
- ErrorHandler::unstackErrors();
-
- throw $e;
}
- ErrorHandler::unstackErrors();
+ $exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);
- $exists = class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false));
-
- if ($class && '\\' === $class[0]) {
+ if ('\\' === $class[0]) {
$class = substr($class, 1);
}
@@ -203,11 +168,18 @@ public function loadClass($class)
} elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
} else {
- if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
+ if (2 > $len = 1 + (strpos($name, '\\', 1 + strpos($name, '\\')) ?: strpos($name, '_'))) {
$len = 0;
$ns = '';
} else {
- $ns = substr($name, 0, $len);
+ switch ($ns = substr($name, 0, $len)) {
+ case 'Symfony\Bridge\\':
+ case 'Symfony\Bundle\\':
+ case 'Symfony\Component\\':
+ $ns = 'Symfony\\';
+ $len = strlen($ns);
+ break;
+ }
}
$parent = get_parent_class($class);
@@ -216,9 +188,26 @@ public function loadClass($class)
@trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
}
- foreach (class_implements($class) as $interface) {
- if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len) && !is_subclass_of($parent, $interface)) {
- @trigger_error(sprintf('The %s %s %s that is deprecated %s', $name, interface_exists($class) ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
+ $parentInterfaces = array();
+ $deprecatedInterfaces = array();
+ if ($parent) {
+ foreach (class_implements($parent) as $interface) {
+ $parentInterfaces[$interface] = 1;
+ }
+ }
+
+ foreach ($refl->getInterfaceNames() as $interface) {
+ if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
+ $deprecatedInterfaces[] = $interface;
+ }
+ foreach (class_implements($interface) as $interface) {
+ $parentInterfaces[$interface] = 1;
+ }
+ }
+
+ foreach ($deprecatedInterfaces as $interface) {
+ if (!isset($parentInterfaces[$interface])) {
+ @trigger_error(sprintf('The %s %s %s that is deprecated %s', $name, $refl->isInterface() ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
}
}
}
diff --git a/application/vendor/symfony/debug/ErrorHandler.php b/application/vendor/symfony/debug/ErrorHandler.php
index 4671b85..04fba93 100644
--- a/application/vendor/symfony/debug/ErrorHandler.php
+++ b/application/vendor/symfony/debug/ErrorHandler.php
@@ -46,11 +46,6 @@
*/
class ErrorHandler
{
- /**
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- const TYPE_DEPRECATION = -100;
-
private $levels = array(
E_DEPRECATED => 'Deprecated',
E_USER_DEPRECATED => 'User Deprecated',
@@ -97,42 +92,29 @@ class ErrorHandler
private $isRecursive = 0;
private $isRoot = false;
private $exceptionHandler;
+ private $bootstrappingLogger;
private static $reservedMemory;
private static $stackedErrors = array();
private static $stackedErrorLevels = array();
- private static $exitCode = 0;
-
- /**
- * Same init value as thrownErrors.
- *
- * @deprecated since version 2.6, to be removed in 3.0.
- */
- private $displayErrors = 0x1FFF;
+ private static $toStringException = null;
/**
* Registers the error handler.
*
- * @param self|null|int $handler The handler to register, or @deprecated (since version 2.6, to be removed in 3.0) bit field of thrown levels
- * @param bool $replace Whether to replace or not any existing handler
+ * @param self|null $handler The handler to register
+ * @param bool $replace Whether to replace or not any existing handler
*
* @return self The registered error handler
*/
- public static function register($handler = null, $replace = true)
+ public static function register(self $handler = null, $replace = true)
{
if (null === self::$reservedMemory) {
self::$reservedMemory = str_repeat('x', 10240);
register_shutdown_function(__CLASS__.'::handleFatalError');
}
- $levels = -1;
-
- if ($handlerIsNew = !$handler instanceof self) {
- // @deprecated polymorphism, to be removed in 3.0
- if (null !== $handler) {
- $levels = $replace ? $handler : 0;
- $replace = true;
- }
+ if ($handlerIsNew = null === $handler) {
$handler = new static();
}
@@ -147,31 +129,25 @@ public static function register($handler = null, $replace = true)
$handler = $prev[0];
$replace = false;
}
- if (!$replace && $prev) {
- restore_error_handler();
- $handlerIsRegistered = is_array($prev) && $handler === $prev[0];
- } else {
- $handlerIsRegistered = true;
- }
- if (is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
- restore_exception_handler();
- if (!$handlerIsRegistered) {
- $handler = $prev[0];
- } elseif ($handler !== $prev[0] && $replace) {
- set_exception_handler(array($handler, 'handleException'));
- $p = $prev[0]->setExceptionHandler(null);
- $handler->setExceptionHandler($p);
- $prev[0]->setExceptionHandler($p);
- }
+ if ($replace || !$prev) {
+ $handler->setExceptionHandler(set_exception_handler(array($handler, 'handleException')));
} else {
- $handler->setExceptionHandler($prev);
+ restore_error_handler();
}
- $handler->throwAt($levels & $handler->thrownErrors, true);
+ $handler->throwAt(E_ALL & $handler->thrownErrors, true);
return $handler;
}
+ public function __construct(BufferingLogger $bootstrappingLogger = null)
+ {
+ if ($bootstrappingLogger) {
+ $this->bootstrappingLogger = $bootstrappingLogger;
+ $this->setDefaultLogger($bootstrappingLogger);
+ }
+ }
+
/**
* Sets a logger to non assigned errors levels.
*
@@ -179,22 +155,22 @@ public static function register($handler = null, $replace = true)
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
* @param bool $replace Whether to replace or not any existing logger
*/
- public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
+ public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false)
{
$loggers = array();
if (is_array($levels)) {
foreach ($levels as $type => $logLevel) {
- if (empty($this->loggers[$type][0]) || $replace) {
+ if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
$loggers[$type] = array($logger, $logLevel);
}
}
} else {
if (null === $levels) {
- $levels = E_ALL | E_STRICT;
+ $levels = E_ALL;
}
foreach ($this->loggers as $type => $log) {
- if (($type & $levels) && (empty($log[0]) || $replace)) {
+ if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
$log[0] = $logger;
$loggers[$type] = $log;
}
@@ -217,6 +193,7 @@ public function setLoggers(array $loggers)
{
$prevLogged = $this->loggedErrors;
$prev = $this->loggers;
+ $flush = array();
foreach ($loggers as $type => $log) {
if (!isset($prev[$type])) {
@@ -235,9 +212,24 @@ public function setLoggers(array $loggers)
throw new \InvalidArgumentException('Invalid logger provided');
}
$this->loggers[$type] = $log + $prev[$type];
+
+ if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
+ $flush[$type] = $type;
+ }
}
$this->reRegister($prevLogged | $this->thrownErrors);
+ if ($flush) {
+ foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
+ $type = $log[2]['type'];
+ if (!isset($flush[$type])) {
+ $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
+ } elseif ($this->loggers[$type][0]) {
+ $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
+ }
+ }
+ }
+
return $prev;
}
@@ -247,14 +239,9 @@ public function setLoggers(array $loggers)
* @param callable $handler A handler that will be called on Exception
*
* @return callable|null The previous exception handler
- *
- * @throws \InvalidArgumentException
*/
- public function setExceptionHandler($handler)
+ public function setExceptionHandler(callable $handler = null)
{
- if (null !== $handler && !is_callable($handler)) {
- throw new \LogicException('The exception handler must be a valid PHP callable.');
- }
$prev = $this->exceptionHandler;
$this->exceptionHandler = $handler;
@@ -278,9 +265,6 @@ public function throwAt($levels, $replace = false)
}
$this->reRegister($prev | $this->loggedErrors);
- // $this->displayErrors is @deprecated since version 2.6
- $this->displayErrors = $this->thrownErrors;
-
return $prev;
}
@@ -365,9 +349,9 @@ private function reRegister($prev)
* Handles errors by filtering then logging them according to the configured bit fields.
*
* @param int $type One of the E_* constants
- * @param string $message
* @param string $file
* @param int $line
+ * @param array $context
*
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
*
@@ -375,32 +359,15 @@ private function reRegister($prev)
*
* @internal
*/
- public function handleError($type, $message, $file, $line)
+ public function handleError($type, $message, $file, $line, array $context, array $backtrace = null)
{
- $level = error_reporting();
- $silenced = 0 === ($level & $type);
- $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
+ $level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
$log = $this->loggedErrors & $type;
$throw = $this->thrownErrors & $type & $level;
$type &= $level | $this->screamedErrors;
if (!$type || (!$log && !$throw)) {
- return !$silenced && $type && $log;
- }
- $scope = $this->scopedErrors & $type;
-
- if (4 < $numArgs = func_num_args()) {
- $context = $scope ? (func_get_arg(4) ?: array()) : array();
- $backtrace = 5 < $numArgs ? func_get_arg(5) : null; // defined on HHVM
- } else {
- $context = array();
- $backtrace = null;
- }
-
- if (isset($context['GLOBALS']) && $scope) {
- $e = $context; // Whatever the signature of the method,
- unset($e['GLOBALS'], $context); // $context is always a reference in 5.3
- $context = $e;
+ return $type && $log;
}
if (null !== $backtrace && $type & E_ERROR) {
@@ -413,19 +380,54 @@ public function handleError($type, $message, $file, $line)
}
if ($throw) {
- if ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
- // Checking for class existence is a work around for https://bugs.php.net/42098
+ if (null !== self::$toStringException) {
+ $throw = self::$toStringException;
+ self::$toStringException = null;
+ } elseif (($this->scopedErrors & $type) && class_exists(ContextErrorException::class)) {
$throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
} else {
$throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
}
- if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
- // Exceptions thrown from error handlers are sometimes not caught by the exception
- // handler and shutdown handlers are bypassed before 5.4.8/5.3.18.
- // We temporarily re-enable display_errors to prevent any blank page related to this bug.
-
- $throw->errorHandlerCanary = new ErrorHandlerCanary();
+ if (E_USER_ERROR & $type) {
+ $backtrace = $backtrace ?: $throw->getTrace();
+
+ for ($i = 1; isset($backtrace[$i]); ++$i) {
+ if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
+ && '__toString' === $backtrace[$i]['function']
+ && '->' === $backtrace[$i]['type']
+ && !isset($backtrace[$i - 1]['class'])
+ && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
+ ) {
+ // Here, we know trigger_error() has been called from __toString().
+ // HHVM is fine with throwing from __toString() but PHP triggers a fatal error instead.
+ // A small convention allows working around the limitation:
+ // given a caught $e exception in __toString(), quitting the method with
+ // `return trigger_error($e, E_USER_ERROR);` allows this error handler
+ // to make $e get through the __toString() barrier.
+
+ foreach ($context as $e) {
+ if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
+ if (1 === $i) {
+ // On HHVM
+ $throw = $e;
+ break;
+ }
+ self::$toStringException = $e;
+
+ return true;
+ }
+ }
+
+ if (1 < $i) {
+ // On PHP (not on HHVM), display the original error message instead of the default one.
+ $this->handleException($throw);
+
+ // Stop the process by giving back the error to the native handler.
+ return false;
+ }
+ }
+ }
}
throw $throw;
@@ -444,7 +446,7 @@ public function handleError($type, $message, $file, $line)
$e = compact('type', 'file', 'line', 'level');
if ($type & $level) {
- if ($scope) {
+ if ($this->scopedErrors & $type) {
$e['scope_vars'] = $context;
if ($trace) {
$e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
@@ -469,19 +471,12 @@ public function handleError($type, $message, $file, $line)
try {
$this->isRecursive = true;
$this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
+ } finally {
$this->isRecursive = false;
- } catch (\Exception $e) {
- $this->isRecursive = false;
-
- throw $e;
- } catch (\Throwable $e) {
- $this->isRecursive = false;
-
- throw $e;
}
}
- return !$silenced && $type && $log;
+ return $type && $log;
}
/**
@@ -494,14 +489,10 @@ public function handleError($type, $message, $file, $line)
*/
public function handleException($exception, array $error = null)
{
- if (null === $error) {
- self::$exitCode = 255;
- }
if (!$exception instanceof \Exception) {
$exception = new FatalThrowableError($exception);
}
$type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
- $handlerException = null;
if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
$e = array(
@@ -532,11 +523,7 @@ public function handleException($exception, array $error = null)
}
}
if ($this->loggedErrors & $type) {
- try {
- $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
- } catch (\Exception $handlerException) {
- } catch (\Throwable $handlerException) {
- }
+ $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
}
if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
foreach ($this->getFatalErrorHandlers() as $handler) {
@@ -546,21 +533,18 @@ public function handleException($exception, array $error = null)
}
}
}
- $exceptionHandler = $this->exceptionHandler;
- $this->exceptionHandler = null;
+ if (empty($this->exceptionHandler)) {
+ throw $exception; // Give back $exception to the native handler
+ }
try {
- if (null !== $exceptionHandler) {
- return \call_user_func($exceptionHandler, $exception);
- }
- $handlerException = $handlerException ?: $exception;
+ call_user_func($this->exceptionHandler, $exception);
} catch (\Exception $handlerException) {
} catch (\Throwable $handlerException) {
}
- if ($exception === $handlerException) {
- self::$reservedMemory = null; // Disable the fatal error handler
- throw $exception; // Give back $exception to the native handler
+ if (isset($handlerException)) {
+ $this->exceptionHandler = null;
+ $this->handleException($handlerException);
}
- $this->handleException($handlerException);
}
/**
@@ -576,41 +560,17 @@ public static function handleFatalError(array $error = null)
return;
}
- $handler = self::$reservedMemory = null;
- $handlers = array();
- $previousHandler = null;
- $sameHandlerLimit = 10;
+ self::$reservedMemory = null;
- while (!is_array($handler) || !$handler[0] instanceof self) {
- $handler = set_exception_handler('var_dump');
- restore_exception_handler();
+ $handler = set_error_handler('var_dump');
+ $handler = is_array($handler) ? $handler[0] : null;
+ restore_error_handler();
- if (!$handler) {
- break;
- }
- restore_exception_handler();
-
- if ($handler !== $previousHandler) {
- array_unshift($handlers, $handler);
- $previousHandler = $handler;
- } elseif (0 === --$sameHandlerLimit) {
- $handler = null;
- break;
- }
- }
- foreach ($handlers as $h) {
- set_exception_handler($h);
- }
- if (!$handler) {
+ if (!$handler instanceof self) {
return;
}
- if ($handler !== $h) {
- $handler[0]->setExceptionHandler($h);
- }
- $handler = $handler[0];
- $handlers = array();
- if ($exit = null === $error) {
+ if (null === $error) {
$error = error_get_last();
}
@@ -634,21 +594,15 @@ public static function handleFatalError(array $error = null)
} else {
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
}
+ } elseif (!isset($exception)) {
+ return;
}
try {
- if (isset($exception)) {
- self::$exitCode = 255;
- $handler->handleException($exception, $error);
- }
+ $handler->handleException($exception, $error);
} catch (FatalErrorException $e) {
// Ignore this re-throw
}
-
- if ($exit && self::$exitCode) {
- $exitCode = self::$exitCode;
- register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
- }
}
/**
@@ -707,118 +661,4 @@ protected function getFatalErrorHandlers()
new ClassNotFoundFatalErrorHandler(),
);
}
-
- /**
- * Sets the level at which the conversion to Exception is done.
- *
- * @param int|null $level The level (null to use the error_reporting() value and 0 to disable)
- *
- * @deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.
- */
- public function setLevel($level)
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the throwAt() method instead.', E_USER_DEPRECATED);
-
- $level = null === $level ? error_reporting() : $level;
- $this->throwAt($level, true);
- }
-
- /**
- * Sets the display_errors flag value.
- *
- * @param int $displayErrors The display_errors flag value
- *
- * @deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.
- */
- public function setDisplayErrors($displayErrors)
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the throwAt() method instead.', E_USER_DEPRECATED);
-
- if ($displayErrors) {
- $this->throwAt($this->displayErrors, true);
- } else {
- $displayErrors = $this->displayErrors;
- $this->throwAt(0, true);
- $this->displayErrors = $displayErrors;
- }
- }
-
- /**
- * Sets a logger for the given channel.
- *
- * @param LoggerInterface $logger A logger interface
- * @param string $channel The channel associated with the logger (deprecation, emergency or scream)
- *
- * @deprecated since version 2.6, to be removed in 3.0. Use setLoggers() or setDefaultLogger() instead.
- */
- public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
- {
- @trigger_error('The '.__METHOD__.' static method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the setLoggers() or setDefaultLogger() methods instead.', E_USER_DEPRECATED);
-
- $handler = set_error_handler('var_dump');
- $handler = is_array($handler) ? $handler[0] : null;
- restore_error_handler();
- if (!$handler instanceof self) {
- return;
- }
- if ('deprecation' === $channel) {
- $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
- $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
- } elseif ('scream' === $channel) {
- $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
- $handler->screamAt(E_ALL | E_STRICT);
- } elseif ('emergency' === $channel) {
- $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
- $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
- }
- }
-
- /**
- * @deprecated since version 2.6, to be removed in 3.0. Use handleError() instead.
- */
- public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
- {
- $this->handleError(E_USER_DEPRECATED, 'The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the handleError() method instead.', __FILE__, __LINE__, array());
-
- return $this->handleError($level, $message, $file, $line, (array) $context);
- }
-
- /**
- * Handles PHP fatal errors.
- *
- * @deprecated since version 2.6, to be removed in 3.0. Use handleFatalError() instead.
- */
- public function handleFatal()
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the handleFatalError() method instead.', E_USER_DEPRECATED);
-
- static::handleFatalError();
- }
-}
-
-/**
- * Private class used to work around https://bugs.php.net/54275.
- *
- * @author Nicolas Grekas
- *
- * @internal
- */
-class ErrorHandlerCanary
-{
- private static $displayErrors = null;
-
- public function __construct()
- {
- if (null === self::$displayErrors) {
- self::$displayErrors = ini_set('display_errors', 1);
- }
- }
-
- public function __destruct()
- {
- if (null !== self::$displayErrors) {
- ini_set('display_errors', self::$displayErrors);
- self::$displayErrors = null;
- }
- }
}
diff --git a/application/vendor/symfony/debug/Exception/DummyException.php b/application/vendor/symfony/debug/Exception/DummyException.php
deleted file mode 100644
index 1b9082b..0000000
--- a/application/vendor/symfony/debug/Exception/DummyException.php
+++ /dev/null
@@ -1,23 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Debug\Exception;
-
-@trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
-
-/**
- * @author Fabien Potencier
- *
- * @deprecated since version 2.5, to be removed in 3.0.
- */
-class DummyException extends \ErrorException
-{
-}
diff --git a/application/vendor/symfony/debug/Exception/FatalErrorException.php b/application/vendor/symfony/debug/Exception/FatalErrorException.php
index db2fb43..f24a54e 100644
--- a/application/vendor/symfony/debug/Exception/FatalErrorException.php
+++ b/application/vendor/symfony/debug/Exception/FatalErrorException.php
@@ -9,31 +9,14 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\HttpKernel\Exception;
-
-/**
- * Fatal Error Exception.
- *
- * @author Fabien Potencier
- * @author Konstanton Myakshin
- * @author Nicolas Grekas
- *
- * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
- */
-class FatalErrorException extends \ErrorException
-{
-}
-
namespace Symfony\Component\Debug\Exception;
-use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
-
/**
* Fatal Error Exception.
*
* @author Konstanton Myakshin
*/
-class FatalErrorException extends LegacyFatalErrorException
+class FatalErrorException extends \ErrorException
{
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null)
{
diff --git a/application/vendor/symfony/debug/Exception/FatalThrowableError.php b/application/vendor/symfony/debug/Exception/FatalThrowableError.php
index fafc922..34f43b1 100644
--- a/application/vendor/symfony/debug/Exception/FatalThrowableError.php
+++ b/application/vendor/symfony/debug/Exception/FatalThrowableError.php
@@ -36,8 +36,7 @@ public function __construct(\Throwable $e)
$e->getCode(),
$severity,
$e->getFile(),
- $e->getLine(),
- $e->getPrevious()
+ $e->getLine()
);
$this->setTrace($e->getTrace());
diff --git a/application/vendor/symfony/debug/Exception/FlattenException.php b/application/vendor/symfony/debug/Exception/FlattenException.php
index b3a98ac..5802c50 100644
--- a/application/vendor/symfony/debug/Exception/FlattenException.php
+++ b/application/vendor/symfony/debug/Exception/FlattenException.php
@@ -9,49 +9,8 @@
* file that was distributed with this source code.
*/
-namespace Symfony\Component\HttpKernel\Exception;
-
-use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
-
-/**
- * FlattenException wraps a PHP Exception to be able to serialize it.
- *
- * Basically, this class removes all objects from the trace.
- *
- * @author Fabien Potencier
- *
- * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
- */
-class FlattenException
-{
- private $handler;
-
- public static function __callStatic($method, $args)
- {
- if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
- throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_called_class(), $method));
- }
-
- return call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
- }
-
- public function __call($method, $args)
- {
- if (!isset($this->handler)) {
- $this->handler = new DebugFlattenException();
- }
-
- if (!method_exists($this->handler, $method)) {
- throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method));
- }
-
- return call_user_func_array(array($this->handler, $method), $args);
- }
-}
-
namespace Symfony\Component\Debug\Exception;
-use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
/**
@@ -61,7 +20,7 @@ public function __call($method, $args)
*
* @author Fabien Potencier
*/
-class FlattenException extends LegacyFlattenException
+class FlattenException
{
private $message;
private $code;
@@ -263,10 +222,7 @@ private function flattenArgs($args, $level = 0, &$count = 0)
if (++$count > 1e4) {
return array('array', '*SKIPPED over 10000 entries*');
}
- if ($value instanceof \__PHP_Incomplete_Class) {
- // is_object() returns false on PHP<=7.1
- $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
- } elseif (is_object($value)) {
+ if (is_object($value)) {
$result[$key] = array('object', get_class($value));
} elseif (is_array($value)) {
if ($level > 10) {
@@ -280,6 +236,9 @@ private function flattenArgs($args, $level = 0, &$count = 0)
$result[$key] = array('boolean', $value);
} elseif (is_resource($value)) {
$result[$key] = array('resource', get_resource_type($value));
+ } elseif ($value instanceof \__PHP_Incomplete_Class) {
+ // Special case of object, is_object will return false
+ $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
} else {
$result[$key] = array('string', (string) $value);
}
diff --git a/application/vendor/symfony/debug/ExceptionHandler.php b/application/vendor/symfony/debug/ExceptionHandler.php
index 472073c..8fedc1b 100644
--- a/application/vendor/symfony/debug/ExceptionHandler.php
+++ b/application/vendor/symfony/debug/ExceptionHandler.php
@@ -11,7 +11,6 @@
namespace Symfony\Component\Debug;
-use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\Exception\OutOfMemoryException;
@@ -38,12 +37,6 @@ class ExceptionHandler
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
{
- if (false !== strpos($charset, '%')) {
- // Swap $charset and $fileLinkFormat for BC reasons
- $pivot = $fileLinkFormat;
- $fileLinkFormat = $charset;
- $charset = $pivot;
- }
$this->debug = $debug;
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
@@ -56,7 +49,7 @@ public function __construct($debug = true, $charset = null, $fileLinkFormat = nu
* @param string|null $charset The charset used by exception messages
* @param string|null $fileLinkFormat The IDE link template
*
- * @return static
+ * @return ExceptionHandler The registered exception handler
*/
public static function register($debug = true, $charset = null, $fileLinkFormat = null)
{
@@ -78,11 +71,8 @@ public static function register($debug = true, $charset = null, $fileLinkFormat
*
* @return callable|null The previous exception handler if any
*/
- public function setHandler($handler)
+ public function setHandler(callable $handler = null)
{
- if (null !== $handler && !is_callable($handler)) {
- throw new \LogicException('The exception handler must be a valid PHP callable.');
- }
$old = $this->handler;
$this->handler = $handler;
@@ -115,20 +105,36 @@ public function setFileLinkFormat($format)
public function handle(\Exception $exception)
{
if (null === $this->handler || $exception instanceof OutOfMemoryException) {
- $this->failSafeHandle($exception);
+ $this->sendPhpResponse($exception);
return;
}
$caughtLength = $this->caughtLength = 0;
- ob_start(array($this, 'catchOutput'));
- $this->failSafeHandle($exception);
+ ob_start(function ($buffer) {
+ $this->caughtBuffer = $buffer;
+
+ return '';
+ });
+
+ $this->sendPhpResponse($exception);
while (null === $this->caughtBuffer && ob_end_flush()) {
// Empty loop, everything is in the condition
}
if (isset($this->caughtBuffer[0])) {
- ob_start(array($this, 'cleanOutput'));
+ ob_start(function ($buffer) {
+ if ($this->caughtLength) {
+ // use substr_replace() instead of substr() for mbstring overloading resistance
+ $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
+ if (isset($cleanBuffer[0])) {
+ $buffer = $cleanBuffer;
+ }
+ }
+
+ return $buffer;
+ });
+
echo $this->caughtBuffer;
$caughtLength = ob_get_length();
}
@@ -145,37 +151,13 @@ public function handle(\Exception $exception)
}
}
- /**
- * Sends a response for the given Exception.
- *
- * If you have the Symfony HttpFoundation component installed,
- * this method will use it to create and send the response. If not,
- * it will fallback to plain PHP functions.
- */
- private function failSafeHandle(\Exception $exception)
- {
- if (class_exists('Symfony\Component\HttpFoundation\Response', false)
- && __CLASS__ !== get_class($this)
- && ($reflector = new \ReflectionMethod($this, 'createResponse'))
- && __CLASS__ !== $reflector->class
- ) {
- $response = $this->createResponse($exception);
- $response->sendHeaders();
- $response->sendContent();
-
- return;
- }
-
- $this->sendPhpResponse($exception);
- }
-
/**
* Sends the error associated with the given Exception as a plain PHP response.
*
* This method uses plain PHP functions like header() and echo to output
* the response.
*
- * @param \Exception|FlattenException $exception An \Exception instance
+ * @param \Exception|FlattenException $exception An \Exception or FlattenException instance
*/
public function sendPhpResponse($exception)
{
@@ -195,24 +177,26 @@ public function sendPhpResponse($exception)
}
/**
- * Creates the error Response associated with the given Exception.
+ * Gets the full HTML content associated with the given exception.
*
- * @param \Exception|FlattenException $exception An \Exception instance
+ * @param \Exception|FlattenException $exception An \Exception or FlattenException instance
*
- * @return Response A Response instance
+ * @return string The HTML content as a string
*/
- public function createResponse($exception)
+ public function getHtml($exception)
{
if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception);
}
- return Response::create($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
+ return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
}
/**
* Gets the HTML content associated with the given exception.
*
+ * @param FlattenException $exception A FlattenException instance
+ *
* @return string The content as a string
*/
public function getContent(FlattenException $exception)
@@ -279,6 +263,8 @@ public function getContent(FlattenException $exception)
/**
* Gets the stylesheet associated with the given exception.
*
+ * @param FlattenException $exception A FlattenException instance
+ *
* @return string The stylesheet as a string
*/
public function getStylesheet(FlattenException $exception)
@@ -313,7 +299,6 @@ public function getStylesheet(FlattenException $exception)
border-bottom:1px solid #ccc;
border-right:1px solid #ccc;
border-left:1px solid #ccc;
- word-wrap: break-word;
}
.sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
-webkit-border-top-left-radius: 16px;
@@ -413,55 +398,17 @@ private function formatArgs(array $args)
$formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
}
- $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
+ $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
}
return implode(', ', $result);
}
- /**
- * Returns an UTF-8 and HTML encoded string.
- *
- * @deprecated since version 2.7, to be removed in 3.0.
- */
- protected static function utf8Htmlize($str)
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
-
- return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
- }
-
/**
* HTML-encodes a string.
*/
private function escapeHtml($str)
{
- return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
- }
-
- /**
- * @internal
- */
- public function catchOutput($buffer)
- {
- $this->caughtBuffer = $buffer;
-
- return '';
- }
-
- /**
- * @internal
- */
- public function cleanOutput($buffer)
- {
- if ($this->caughtLength) {
- // use substr_replace() instead of substr() for mbstring overloading resistance
- $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
- if (isset($cleanBuffer[0])) {
- $buffer = $cleanBuffer;
- }
- }
-
- return $buffer;
+ return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset);
}
}
diff --git a/application/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/application/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php
index 612bfca..c48d0d3 100644
--- a/application/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php
+++ b/application/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php
@@ -16,7 +16,6 @@
use Symfony\Component\Debug\DebugClassLoader;
use Composer\Autoload\ClassLoader as ComposerClassLoader;
use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
-use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
/**
* ErrorHandler for classes that do not exist.
@@ -101,17 +100,12 @@ private function getClassCandidates($class)
if ($function[0] instanceof DebugClassLoader) {
$function = $function[0]->getClassLoader();
- // @deprecated since version 2.5. Returning an object from DebugClassLoader::getClassLoader() is deprecated.
- if (is_object($function)) {
- $function = array($function);
- }
-
if (!is_array($function)) {
continue;
}
}
- if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
+ if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader) {
foreach ($function[0]->getPrefixes() as $prefix => $paths) {
foreach ($paths as $path) {
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
@@ -179,7 +173,7 @@ private function convertFileToClass($path, $file, $prefix)
);
if ($prefix) {
- $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
+ $candidates = array_filter($candidates, function ($candidate) use ($prefix) {return 0 === strpos($candidate, $prefix);});
}
// We cannot use the autoloader here as most of them use require; but if the class
@@ -207,6 +201,6 @@ private function convertFileToClass($path, $file, $prefix)
*/
private function classExists($class)
{
- return class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false));
+ return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);
}
}
diff --git a/application/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/application/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php
index 6fa62b6..f734d6b 100644
--- a/application/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php
+++ b/application/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php
@@ -36,13 +36,8 @@ public function handleError(array $error, FatalErrorException $exception)
$message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
- if (!class_exists($className) || null === $methods = get_class_methods($className)) {
- // failed to get the class or its methods on which an unknown method was called (for example on an anonymous class)
- return new UndefinedMethodException($message, $exception);
- }
-
$candidates = array();
- foreach ($methods as $definedMethodName) {
+ foreach (get_class_methods($className) as $definedMethodName) {
$lev = levenshtein($methodName, $definedMethodName);
if ($lev <= strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
$candidates[] = $definedMethodName;
@@ -57,7 +52,6 @@ public function handleError(array $error, FatalErrorException $exception)
} else {
$candidates = '"'.$last;
}
-
$message .= "\nDid you mean to call ".$candidates;
}
diff --git a/application/vendor/symfony/debug/LICENSE b/application/vendor/symfony/debug/LICENSE
index 21d7fb9..12a7453 100644
--- a/application/vendor/symfony/debug/LICENSE
+++ b/application/vendor/symfony/debug/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2018 Fabien Potencier
+Copyright (c) 2004-2016 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
diff --git a/application/vendor/symfony/debug/Resources/ext/tests/001.phpt b/application/vendor/symfony/debug/Resources/ext/tests/001.phpt
index 4a87cd3..4d41417 100644
--- a/application/vendor/symfony/debug/Resources/ext/tests/001.phpt
+++ b/application/vendor/symfony/debug/Resources/ext/tests/001.phpt
@@ -1,16 +1,14 @@
--TEST--
Test symfony_zval_info API
--SKIPIF--
-
+
--FILE--
$int,
- 'float' => $float,
- 'str' => $str,
- 'object' => $object,
- 'array' => $array,
- 'resource' => $resource,
- 'null' => $null,
- 'bool' => $bool,
- 'refcount' => &$refcount2,
-);
+$var = array('int' => $int,
+ 'float' => $float,
+ 'str' => $str,
+ 'object' => $object,
+ 'array' => $array,
+ 'resource' => $resource,
+ 'null' => $null,
+ 'bool' => $bool,
+ 'refcount' => &$refcount2);
var_dump(symfony_zval_info('int', $var));
var_dump(symfony_zval_info('float', $var));
diff --git a/application/vendor/symfony/debug/Resources/ext/tests/002.phpt b/application/vendor/symfony/debug/Resources/ext/tests/002.phpt
index afc7bb4..ebe2f32 100644
--- a/application/vendor/symfony/debug/Resources/ext/tests/002.phpt
+++ b/application/vendor/symfony/debug/Resources/ext/tests/002.phpt
@@ -1,9 +1,7 @@
--TEST--
Test symfony_debug_backtrace in case of fatal error
--SKIPIF--
-
+
--FILE--
+
--FILE--
+
--FILE--
errorReporting = error_reporting(E_ALL | E_STRICT);
+ $this->errorReporting = error_reporting(E_ALL);
$this->loader = new ClassLoader();
spl_autoload_register(array($this->loader, 'loadClass'), true, true);
DebugClassLoader::enable();
@@ -59,26 +58,9 @@ public function testIdempotence()
$this->fail('DebugClassLoader did not register');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage boo
- */
- public function testThrowingClass()
- {
- try {
- class_exists(__NAMESPACE__.'\Fixtures\Throwing');
- $this->fail('Exception expected');
- } catch (\Exception $e) {
- $this->assertSame('boo', $e->getMessage());
- }
-
- // the second call also should throw
- class_exists(__NAMESPACE__.'\Fixtures\Throwing');
- }
-
public function testUnsilencing()
{
- if (\PHP_VERSION_ID >= 70000) {
+ if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.');
}
if (defined('HHVM_VERSION')) {
@@ -125,27 +107,22 @@ class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
$this->fail('ContextErrorException expected');
} catch (\ErrorException $exception) {
// if an exception is thrown, the test passed
- restore_error_handler();
- restore_exception_handler();
$this->assertStringStartsWith(__FILE__, $exception->getFile());
- if (\PHP_VERSION_ID < 70000) {
+ if (PHP_VERSION_ID < 70000) {
$this->assertRegExp('/^Runtime Notice: Declaration/', $exception->getMessage());
$this->assertEquals(E_STRICT, $exception->getSeverity());
} else {
$this->assertRegExp('/^Warning: Declaration/', $exception->getMessage());
$this->assertEquals(E_WARNING, $exception->getSeverity());
}
- } catch (\Exception $exception) {
+ } finally {
restore_error_handler();
restore_exception_handler();
-
- throw $exception;
}
}
/**
* @expectedException \RuntimeException
- * @expectedExceptionMessage Case mismatch between loaded and declared class names
*/
public function testNameCaseMismatch()
{
@@ -167,7 +144,6 @@ class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true);
/**
* @expectedException \RuntimeException
- * @expectedExceptionMessage Case mismatch between loaded and declared class names
*/
public function testPsr4CaseMismatch()
{
@@ -208,7 +184,7 @@ class_exists('Test\\'.__NAMESPACE__.'\\'.$class, true);
$xError = array(
'type' => E_USER_DEPRECATED,
- 'message' => 'The Test\Symfony\Component\Debug\Tests\\'.$class.' class '.$type.' Symfony\Component\Debug\Tests\Fixtures\\'.$super.' that is deprecated but this is a test deprecation notice',
+ 'message' => 'The Test\Symfony\Component\Debug\Tests\\'.$class.' class '.$type.' Symfony\Component\Debug\Tests\Fixtures\\'.$super.' that is deprecated but this is a test deprecation notice.',
);
$this->assertSame($xError, $lastError);
@@ -222,6 +198,28 @@ public function provideDeprecatedSuper()
);
}
+ public function testInterfaceExtendsDeprecatedInterface()
+ {
+ set_error_handler(function () { return false; });
+ $e = error_reporting(0);
+ trigger_error('', E_USER_NOTICE);
+
+ class_exists('Test\\'.__NAMESPACE__.'\\NonDeprecatedInterfaceClass', true);
+
+ error_reporting($e);
+ restore_error_handler();
+
+ $lastError = error_get_last();
+ unset($lastError['file'], $lastError['line']);
+
+ $xError = array(
+ 'type' => E_USER_NOTICE,
+ 'message' => '',
+ );
+
+ $this->assertSame($xError, $lastError);
+ }
+
public function testDeprecatedSuperInSameNamespace()
{
set_error_handler(function () { return false; });
@@ -246,7 +244,7 @@ class_exists('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent', true
public function testReservedForPhp7()
{
- if (\PHP_VERSION_ID >= 70000) {
+ if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('PHP7 already prevents using reserved names.');
}
@@ -308,6 +306,8 @@ public function findFile($class)
eval('namespace Test\\'.__NAMESPACE__.'; class DeprecatedParentClass extends \\'.__NAMESPACE__.'\Fixtures\DeprecatedClass {}');
} elseif ('Test\\'.__NAMESPACE__.'\DeprecatedInterfaceClass' === $class) {
eval('namespace Test\\'.__NAMESPACE__.'; class DeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\DeprecatedInterface {}');
+ } elseif ('Test\\'.__NAMESPACE__.'\NonDeprecatedInterfaceClass' === $class) {
+ eval('namespace Test\\'.__NAMESPACE__.'; class NonDeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\NonDeprecatedInterface {}');
} elseif ('Test\\'.__NAMESPACE__.'\Float' === $class) {
eval('namespace Test\\'.__NAMESPACE__.'; class Float {}');
}
diff --git a/application/vendor/symfony/debug/Tests/ErrorHandlerTest.php b/application/vendor/symfony/debug/Tests/ErrorHandlerTest.php
index d8f4a74..163ef53 100644
--- a/application/vendor/symfony/debug/Tests/ErrorHandlerTest.php
+++ b/application/vendor/symfony/debug/Tests/ErrorHandlerTest.php
@@ -11,9 +11,9 @@
namespace Symfony\Component\Debug\Tests;
-use PHPUnit\Framework\TestCase;
use Psr\Log\LogLevel;
use Symfony\Component\Debug\ErrorHandler;
+use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\Exception\ContextErrorException;
/**
@@ -22,7 +22,7 @@
* @author Robert Schönthal
* @author Nicolas Grekas
*/
-class ErrorHandlerTest extends TestCase
+class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
{
public function testRegister()
{
@@ -34,7 +34,7 @@ public function testRegister()
$newHandler = new ErrorHandler();
- $this->assertSame($handler, ErrorHandler::register($newHandler, false));
+ $this->assertSame($newHandler, ErrorHandler::register($newHandler, false));
$h = set_error_handler('var_dump');
restore_error_handler();
$this->assertSame(array($handler, 'handleError'), $h);
@@ -64,30 +64,6 @@ public function testRegister()
}
}
- public function testErrorGetLast()
- {
- $handler = ErrorHandler::register();
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
- $handler->setDefaultLogger($logger);
- $handler->screamAt(E_ALL);
-
- try {
- @trigger_error('Hello', E_USER_WARNING);
- $expected = array(
- 'type' => E_USER_WARNING,
- 'message' => 'Hello',
- 'file' => __FILE__,
- 'line' => __LINE__ - 5,
- );
- $this->assertSame($expected, error_get_last());
- } catch (\Exception $e) {
- restore_error_handler();
- restore_exception_handler();
-
- throw $e;
- }
- }
-
public function testNotice()
{
ErrorHandler::register();
@@ -97,15 +73,10 @@ public function testNotice()
$this->fail('ContextErrorException expected');
} catch (ContextErrorException $exception) {
// if an exception is thrown, the test passed
- restore_error_handler();
- restore_exception_handler();
-
$this->assertEquals(E_NOTICE, $exception->getSeverity());
$this->assertEquals(__FILE__, $exception->getFile());
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
- if (\PHP_VERSION_ID < 70200) {
- $this->assertArrayHasKey('foobar', $exception->getContext());
- }
+ $this->assertArrayHasKey('foobar', $exception->getContext());
$trace = $exception->getTrace();
$this->assertEquals(__FILE__, $trace[0]['file']);
@@ -122,11 +93,9 @@ public function testNotice()
$this->assertEquals(__CLASS__, $trace[2]['class']);
$this->assertEquals(__FUNCTION__, $trace[2]['function']);
$this->assertEquals('->', $trace[2]['type']);
- } catch (\Exception $e) {
+ } finally {
restore_error_handler();
restore_exception_handler();
-
- throw $e;
}
}
@@ -144,14 +113,9 @@ public function testConstruct()
$handler = ErrorHandler::register();
$handler->throwAt(3, true);
$this->assertEquals(3 | E_RECOVERABLE_ERROR | E_USER_ERROR, $handler->throwAt(0));
-
+ } finally {
restore_error_handler();
restore_exception_handler();
- } catch (\Exception $e) {
- restore_error_handler();
- restore_exception_handler();
-
- throw $e;
}
}
@@ -160,7 +124,7 @@ public function testDefaultLogger()
try {
$handler = ErrorHandler::register();
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
$handler->setDefaultLogger($logger, E_NOTICE);
$handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL));
@@ -183,14 +147,9 @@ public function testDefaultLogger()
E_CORE_ERROR => array(null, LogLevel::CRITICAL),
);
$this->assertSame($loggers, $handler->setLoggers(array()));
-
- restore_error_handler();
- restore_exception_handler();
- } catch (\Exception $e) {
+ } finally {
restore_error_handler();
restore_exception_handler();
-
- throw $e;
}
}
@@ -239,16 +198,15 @@ public function testHandleError()
restore_error_handler();
restore_exception_handler();
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
- $that = $this;
- $warnArgCheck = function ($logLevel, $message, $context) use ($that) {
- $that->assertEquals('info', $logLevel);
- $that->assertEquals('foo', $message);
- $that->assertArrayHasKey('type', $context);
- $that->assertEquals($context['type'], E_USER_DEPRECATED);
- $that->assertArrayHasKey('stack', $context);
- $that->assertInternalType('array', $context['stack']);
+ $warnArgCheck = function ($logLevel, $message, $context) {
+ $this->assertEquals('info', $logLevel);
+ $this->assertEquals('foo', $message);
+ $this->assertArrayHasKey('type', $context);
+ $this->assertEquals($context['type'], E_USER_DEPRECATED);
+ $this->assertArrayHasKey('stack', $context);
+ $this->assertInternalType('array', $context['stack']);
};
$logger
@@ -264,13 +222,12 @@ public function testHandleError()
restore_error_handler();
restore_exception_handler();
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
- $that = $this;
- $logArgCheck = function ($level, $message, $context) use ($that) {
- $that->assertEquals('Undefined variable: undefVar', $message);
- $that->assertArrayHasKey('type', $context);
- $that->assertEquals($context['type'], E_NOTICE);
+ $logArgCheck = function ($level, $message, $context) {
+ $this->assertEquals('Undefined variable: undefVar', $message);
+ $this->assertArrayHasKey('type', $context);
+ $this->assertEquals($context['type'], E_NOTICE);
};
$logger
@@ -295,17 +252,38 @@ public function testHandleError()
}
}
+ public function testHandleUserError()
+ {
+ try {
+ $handler = ErrorHandler::register();
+ $handler->throwAt(0, true);
+
+ $e = null;
+ $x = new \Exception('Foo');
+
+ try {
+ $f = new Fixtures\ToStringThrower($x);
+ $f .= ''; // Trigger $f->__toString()
+ } catch (\Exception $e) {
+ }
+
+ $this->assertSame($x, $e);
+ } finally {
+ restore_error_handler();
+ restore_exception_handler();
+ }
+ }
+
public function testHandleDeprecation()
{
- $that = $this;
- $logArgCheck = function ($level, $message, $context) use ($that) {
- $that->assertEquals(LogLevel::INFO, $level);
- $that->assertArrayHasKey('level', $context);
- $that->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']);
- $that->assertArrayHasKey('stack', $context);
+ $logArgCheck = function ($level, $message, $context) {
+ $this->assertEquals(LogLevel::INFO, $level);
+ $this->assertArrayHasKey('level', $context);
+ $this->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']);
+ $this->assertArrayHasKey('stack', $context);
};
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
$logger
->expects($this->once())
->method('log')
@@ -317,9 +295,6 @@ public function testHandleDeprecation()
@$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array());
}
- /**
- * @group no-hhvm
- */
public function testHandleException()
{
try {
@@ -327,13 +302,12 @@ public function testHandleException()
$exception = new \Exception('foo');
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
- $that = $this;
- $logArgCheck = function ($level, $message, $context) use ($that) {
- $that->assertEquals('Uncaught Exception: foo', $message);
- $that->assertArrayHasKey('type', $context);
- $that->assertEquals($context['type'], E_ERROR);
+ $logArgCheck = function ($level, $message, $context) {
+ $this->assertEquals('Uncaught Exception: foo', $message);
+ $this->assertArrayHasKey('type', $context);
+ $this->assertEquals($context['type'], E_ERROR);
};
$logger
@@ -351,20 +325,14 @@ public function testHandleException()
$this->assertSame($exception, $e);
}
- $that = $this;
- $handler->setExceptionHandler(function ($e) use ($exception, $that) {
- $that->assertSame($exception, $e);
+ $handler->setExceptionHandler(function ($e) use ($exception) {
+ $this->assertSame($exception, $e);
});
$handler->handleException($exception);
-
- restore_error_handler();
- restore_exception_handler();
- } catch (\Exception $e) {
+ } finally {
restore_error_handler();
restore_exception_handler();
-
- throw $e;
}
}
@@ -374,7 +342,7 @@ public function testErrorStacking()
$handler = ErrorHandler::register();
$handler->screamAt(E_USER_WARNING);
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
$logger
->expects($this->exactly(2))
@@ -391,20 +359,55 @@ public function testErrorStacking()
@trigger_error('Silenced warning', E_USER_WARNING);
$logger->log(LogLevel::WARNING, 'Dummy log');
ErrorHandler::unstackErrors();
-
+ } finally {
restore_error_handler();
restore_exception_handler();
- } catch (\Exception $e) {
- restore_error_handler();
- restore_exception_handler();
-
- throw $e;
}
}
- /**
- * @group no-hhvm
- */
+ public function testBootstrappingLogger()
+ {
+ $bootLogger = new BufferingLogger();
+ $handler = new ErrorHandler($bootLogger);
+
+ $loggers = array(
+ E_DEPRECATED => array($bootLogger, LogLevel::INFO),
+ E_USER_DEPRECATED => array($bootLogger, LogLevel::INFO),
+ E_NOTICE => array($bootLogger, LogLevel::WARNING),
+ E_USER_NOTICE => array($bootLogger, LogLevel::WARNING),
+ E_STRICT => array($bootLogger, LogLevel::WARNING),
+ E_WARNING => array($bootLogger, LogLevel::WARNING),
+ E_USER_WARNING => array($bootLogger, LogLevel::WARNING),
+ E_COMPILE_WARNING => array($bootLogger, LogLevel::WARNING),
+ E_CORE_WARNING => array($bootLogger, LogLevel::WARNING),
+ E_USER_ERROR => array($bootLogger, LogLevel::CRITICAL),
+ E_RECOVERABLE_ERROR => array($bootLogger, LogLevel::CRITICAL),
+ E_COMPILE_ERROR => array($bootLogger, LogLevel::CRITICAL),
+ E_PARSE => array($bootLogger, LogLevel::CRITICAL),
+ E_ERROR => array($bootLogger, LogLevel::CRITICAL),
+ E_CORE_ERROR => array($bootLogger, LogLevel::CRITICAL),
+ );
+
+ $this->assertSame($loggers, $handler->setLoggers(array()));
+
+ $handler->handleError(E_DEPRECATED, 'Foo message', __FILE__, 123, array());
+ $expectedLog = array(LogLevel::INFO, 'Foo message', array('type' => E_DEPRECATED, 'file' => __FILE__, 'line' => 123, 'level' => error_reporting()));
+
+ $logs = $bootLogger->cleanLogs();
+ unset($logs[0][2]['stack']);
+
+ $this->assertSame(array($expectedLog), $logs);
+
+ $bootLogger->log($expectedLog[0], $expectedLog[1], $expectedLog[2]);
+
+ $mockLogger = $this->getMock('Psr\Log\LoggerInterface');
+ $mockLogger->expects($this->once())
+ ->method('log')
+ ->with(LogLevel::WARNING, 'Foo message', $expectedLog[2]);
+
+ $handler->setLoggers(array(E_DEPRECATED => array($mockLogger, LogLevel::WARNING)));
+ }
+
public function testHandleFatalError()
{
try {
@@ -417,13 +420,12 @@ public function testHandleFatalError()
'line' => 123,
);
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
- $that = $this;
- $logArgCheck = function ($level, $message, $context) use ($that) {
- $that->assertEquals('Fatal Parse Error: foo', $message);
- $that->assertArrayHasKey('type', $context);
- $that->assertEquals($context['type'], E_PARSE);
+ $logArgCheck = function ($level, $message, $context) {
+ $this->assertEquals('Fatal Parse Error: foo', $message);
+ $this->assertArrayHasKey('type', $context);
+ $this->assertEquals($context['type'], E_PARSE);
};
$logger
@@ -464,15 +466,12 @@ public function testHandleErrorException()
$this->assertStringStartsWith("Attempted to load class \"Foo\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage());
}
- /**
- * @group no-hhvm
- */
public function testHandleFatalErrorOnHHVM()
{
try {
$handler = ErrorHandler::register();
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
$logger
->expects($this->once())
->method('log')
@@ -502,70 +501,9 @@ public function testHandleFatalErrorOnHHVM()
call_user_func_array(array($handler, 'handleError'), $error);
$handler->handleFatalError($error);
-
- restore_error_handler();
- restore_exception_handler();
- } catch (\Exception $e) {
- restore_error_handler();
- restore_exception_handler();
-
- throw $e;
- }
- }
-
- /**
- * @group legacy
- */
- public function testLegacyInterface()
- {
- try {
- $handler = ErrorHandler::register(0);
- $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array()));
-
+ } finally {
restore_error_handler();
restore_exception_handler();
-
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
-
- $that = $this;
- $logArgCheck = function ($level, $message, $context) use ($that) {
- $that->assertEquals('Undefined variable: undefVar', $message);
- $that->assertArrayHasKey('type', $context);
- $that->assertEquals($context['type'], E_NOTICE);
- };
-
- $logger
- ->expects($this->once())
- ->method('log')
- ->will($this->returnCallback($logArgCheck))
- ;
-
- $handler = ErrorHandler::register(E_NOTICE);
- @$handler->setLogger($logger, 'scream');
- unset($undefVar);
- @$undefVar++;
-
- restore_error_handler();
- restore_exception_handler();
- } catch (\Exception $e) {
- restore_error_handler();
- restore_exception_handler();
-
- throw $e;
}
}
-
- /**
- * @expectedException \Exception
- * @group no-hhvm
- */
- public function testCustomExceptionHandler()
- {
- $handler = new ErrorHandler();
- $handler->setExceptionHandler(function ($e) use ($handler) {
- $handler->handleException($e);
- });
-
- $handler->handleException(new \Exception());
- }
}
diff --git a/application/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php b/application/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php
index 269abf0..6c570e2 100644
--- a/application/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php
+++ b/application/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php
@@ -11,7 +11,6 @@
namespace Symfony\Component\Debug\Tests\Exception;
-use PHPUnit\Framework\TestCase;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
@@ -28,7 +27,7 @@
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
-class FlattenExceptionTest extends TestCase
+class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testStatusCode()
{
@@ -105,7 +104,7 @@ public function testHeadersForHttpException()
/**
* @dataProvider flattenDataProvider
*/
- public function testFlattenHttpException(\Exception $exception)
+ public function testFlattenHttpException(\Exception $exception, $statusCode)
{
$flattened = FlattenException::create($exception);
$flattened2 = FlattenException::create($exception);
@@ -120,7 +119,7 @@ public function testFlattenHttpException(\Exception $exception)
/**
* @dataProvider flattenDataProvider
*/
- public function testPrevious(\Exception $exception)
+ public function testPrevious(\Exception $exception, $statusCode)
{
$flattened = FlattenException::create($exception);
$flattened2 = FlattenException::create($exception);
@@ -167,7 +166,7 @@ public function testFile(\Exception $exception)
/**
* @dataProvider flattenDataProvider
*/
- public function testToArray(\Exception $exception)
+ public function testToArray(\Exception $exception, $statusCode)
{
$flattened = FlattenException::create($exception);
$flattened->setTrace(array(), 'foo.php', 123);
@@ -187,13 +186,12 @@ public function testToArray(\Exception $exception)
public function flattenDataProvider()
{
return array(
- array(new \Exception('test', 123)),
+ array(new \Exception('test', 123), 500),
);
}
public function testRecursionInArguments()
{
- $a = null;
$a = array('foo', array(2, &$a));
$exception = $this->createException($a);
diff --git a/application/vendor/symfony/debug/Tests/ExceptionHandlerTest.php b/application/vendor/symfony/debug/Tests/ExceptionHandlerTest.php
index 77cc0b5..1703da6 100644
--- a/application/vendor/symfony/debug/Tests/ExceptionHandlerTest.php
+++ b/application/vendor/symfony/debug/Tests/ExceptionHandlerTest.php
@@ -11,7 +11,6 @@
namespace Symfony\Component\Debug\Tests;
-use PHPUnit\Framework\TestCase;
use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\Debug\Exception\OutOfMemoryException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -19,7 +18,7 @@
require_once __DIR__.'/HeaderMock.php';
-class ExceptionHandlerTest extends TestCase
+class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
@@ -101,16 +100,15 @@ public function testHandle()
{
$exception = new \Exception('foo');
- $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock();
+ $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler
->expects($this->exactly(2))
->method('sendPhpResponse');
$handler->handle($exception);
- $that = $this;
- $handler->setHandler(function ($e) use ($exception, $that) {
- $that->assertSame($exception, $e);
+ $handler->setHandler(function ($e) use ($exception) {
+ $this->assertSame($exception, $e);
});
$handler->handle($exception);
@@ -120,14 +118,13 @@ public function testHandleOutOfMemoryException()
{
$exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__);
- $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock();
+ $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler
->expects($this->once())
->method('sendPhpResponse');
- $that = $this;
- $handler->setHandler(function ($e) use ($that) {
- $that->fail('OutOfMemoryException should bypass the handler');
+ $handler->setHandler(function ($e) {
+ $this->fail('OutOfMemoryException should bypass the handler');
});
$handler->handle($exception);
diff --git a/application/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/application/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php
index 0611ed9..360e6ed 100644
--- a/application/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php
+++ b/application/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php
@@ -11,15 +11,13 @@
namespace Symfony\Component\Debug\Tests\FatalErrorHandler;
-use PHPUnit\Framework\TestCase;
-use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
-use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
use Symfony\Component\Debug\Exception\FatalErrorException;
+use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
use Symfony\Component\Debug\DebugClassLoader;
use Composer\Autoload\ClassLoader as ComposerClassLoader;
-class ClassNotFoundFatalErrorHandlerTest extends TestCase
+class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
{
public static function setUpBeforeClass()
{
@@ -69,27 +67,6 @@ public function testHandleClassNotFound($error, $translatedMessage, $autoloader
$this->assertSame($error['line'], $exception->getLine());
}
- /**
- * @group legacy
- */
- public function testLegacyHandleClassNotFound()
- {
- $prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception'));
- $symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
- $symfonyUniversalClassLoader->registerPrefixes($prefixes);
-
- $this->testHandleClassNotFound(
- array(
- 'type' => 1,
- 'line' => 12,
- 'file' => 'foo.php',
- 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found',
- ),
- "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?",
- array($symfonyUniversalClassLoader, 'loadClass')
- );
- }
-
public function provideClassNotFoundData()
{
$prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception'));
diff --git a/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php
index 1dc2120..795b747 100644
--- a/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php
+++ b/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php
@@ -11,11 +11,10 @@
namespace Symfony\Component\Debug\Tests\FatalErrorHandler;
-use PHPUnit\Framework\TestCase;
use Symfony\Component\Debug\Exception\FatalErrorException;
use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
-class UndefinedFunctionFatalErrorHandlerTest extends TestCase
+class UndefinedFunctionFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider provideUndefinedFunctionData
diff --git a/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php
index 739e5b2..de7b21c 100644
--- a/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php
+++ b/application/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php
@@ -11,11 +11,10 @@
namespace Symfony\Component\Debug\Tests\FatalErrorHandler;
-use PHPUnit\Framework\TestCase;
use Symfony\Component\Debug\Exception\FatalErrorException;
use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
-class UndefinedMethodFatalErrorHandlerTest extends TestCase
+class UndefinedMethodFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider provideUndefinedMethodData
@@ -62,15 +61,6 @@ public function provideUndefinedMethodData()
),
"Attempted to call an undefined method named \"offsetFet\" of class \"SplObjectStorage\".\nDid you mean to call e.g. \"offsetGet\", \"offsetSet\" or \"offsetUnset\"?",
),
- array(
- array(
- 'type' => 1,
- 'message' => 'Call to undefined method class@anonymous::test()',
- 'file' => '/home/possum/work/symfony/test.php',
- 'line' => 11,
- ),
- 'Attempted to call an undefined method named "test" of class "class@anonymous".',
- ),
);
}
}
diff --git a/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php b/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php
index 51fde5a..b4c78cd 100644
--- a/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php
+++ b/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php
@@ -4,7 +4,7 @@
/**
* @deprecated but this is a test
- * deprecation notice
+ * deprecation notice.
* @foobar
*/
class DeprecatedClass
diff --git a/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php b/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php
index 6bab62f..505ecca 100644
--- a/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php
+++ b/application/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php
@@ -4,7 +4,7 @@
/**
* @deprecated but this is a test
- * deprecation notice
+ * deprecation notice.
* @foobar
*/
interface DeprecatedInterface
diff --git a/application/vendor/symfony/debug/Tests/Fixtures/NonDeprecatedInterface.php b/application/vendor/symfony/debug/Tests/Fixtures/NonDeprecatedInterface.php
new file mode 100644
index 0000000..a4179a5
--- /dev/null
+++ b/application/vendor/symfony/debug/Tests/Fixtures/NonDeprecatedInterface.php
@@ -0,0 +1,7 @@
+exception = $e;
+ }
+
+ public function __toString()
+ {
+ try {
+ throw $this->exception;
+ } catch (\Exception $e) {
+ // Using user_error() here is on purpose so we do not forget
+ // that this alias also should work alongside with trigger_error().
+ return user_error($e, E_USER_ERROR);
+ }
+ }
+}
diff --git a/application/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt b/application/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt
deleted file mode 100644
index 1de9b29..0000000
--- a/application/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Test catching fatal errors when handlers are nested
---FILE--
-
---EXPECTF--
-Fatal error: Class 'Symfony\Component\Debug\missing' not found in %s on line %d
-object(Symfony\Component\Debug\Exception\ClassNotFoundException)#%d (8) {
- ["message":protected]=>
- string(131) "Attempted to load class "missing" from namespace "Symfony\Component\Debug".
-Did you forget a "use" statement for another namespace?"
- ["string":"Exception":private]=>
- string(0) ""
- ["code":protected]=>
- int(0)
- ["file":protected]=>
- string(%d) "%s"
- ["line":protected]=>
- int(%d)
- ["trace":"Exception":private]=>
- array(%d) {%A}
- ["previous":"Exception":private]=>
- NULL
- ["severity":protected]=>
- int(1)
-}
diff --git a/application/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt b/application/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt
deleted file mode 100644
index 9df0a65..0000000
--- a/application/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-Test rethrowing in custom exception handler
---FILE--
-setDefaultLogger(new TestLogger());
-ini_set('display_errors', 1);
-
-throw new \Exception('foo');
-?>
---EXPECTF--
-Uncaught Exception: foo
-123
-Fatal error: Uncaught %s:25
-Stack trace:
-%a
diff --git a/application/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt b/application/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt
deleted file mode 100644
index 897be3e..0000000
--- a/application/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Test catching fatal errors when handlers are nested
---FILE--
-setExceptionHandler('print_r');
-
-if (true) {
- class Broken implements \Serializable
- {
- }
-}
-
-?>
---EXPECTF--
-array(1) {
- [0]=>
- string(37) "Error and exception handlers do match"
-}
-object(Symfony\Component\Debug\Exception\FatalErrorException)#%d (8) {
- ["message":protected]=>
- string(199) "Error: Class Symfony\Component\Debug\Broken contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize)"
-%a
-}
diff --git a/application/vendor/symfony/debug/composer.json b/application/vendor/symfony/debug/composer.json
index 2ae0685..0eef83e 100644
--- a/application/vendor/symfony/debug/composer.json
+++ b/application/vendor/symfony/debug/composer.json
@@ -16,15 +16,15 @@
}
],
"require": {
- "php": ">=5.3.9",
+ "php": ">=5.5.9",
"psr/log": "~1.0"
},
"conflict": {
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
},
"require-dev": {
- "symfony/class-loader": "~2.2",
- "symfony/http-kernel": "~2.3.24|~2.5.9|^2.6.2"
+ "symfony/class-loader": "~2.8|~3.0",
+ "symfony/http-kernel": "~2.8|~3.0"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Debug\\": "" },
@@ -35,7 +35,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.7-dev"
+ "dev-master": "3.0-dev"
}
}
}
diff --git a/application/vendor/symfony/debug/phpunit.xml.dist b/application/vendor/symfony/debug/phpunit.xml.dist
index 12e5861..e99c4dd 100644
--- a/application/vendor/symfony/debug/phpunit.xml.dist
+++ b/application/vendor/symfony/debug/phpunit.xml.dist
@@ -5,8 +5,6 @@
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
- failOnRisky="true"
- failOnWarning="true"
>
diff --git a/application/vendor/symfony/dom-crawler/AbstractUriElement.php b/application/vendor/symfony/dom-crawler/AbstractUriElement.php
new file mode 100644
index 0000000..97604bc
--- /dev/null
+++ b/application/vendor/symfony/dom-crawler/AbstractUriElement.php
@@ -0,0 +1,212 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DomCrawler;
+
+/**
+ * Any HTML element that can link to an URI.
+ *
+ * @author Fabien Potencier
+ */
+abstract class AbstractUriElement
+{
+ /**
+ * @var \DOMElement
+ */
+ protected $node;
+
+ /**
+ * @var string The method to use for the element
+ */
+ protected $method;
+
+ /**
+ * @var string The URI of the page where the element is embedded (or the base href)
+ */
+ protected $currentUri;
+
+ /**
+ * @param \DOMElement $node A \DOMElement instance
+ * @param string $currentUri The URI of the page where the link is embedded (or the base href)
+ * @param string $method The method to use for the link (get by default)
+ *
+ * @throws \InvalidArgumentException if the node is not a link
+ */
+ public function __construct(\DOMElement $node, $currentUri, $method = 'GET')
+ {
+ if (!\in_array(strtolower(substr($currentUri, 0, 4)), ['http', 'file'])) {
+ throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
+ }
+
+ $this->setNode($node);
+ $this->method = $method ? strtoupper($method) : null;
+ $this->currentUri = $currentUri;
+ }
+
+ /**
+ * Gets the node associated with this link.
+ *
+ * @return \DOMElement A \DOMElement instance
+ */
+ public function getNode()
+ {
+ return $this->node;
+ }
+
+ /**
+ * Gets the method associated with this link.
+ *
+ * @return string The method
+ */
+ public function getMethod()
+ {
+ return $this->method;
+ }
+
+ /**
+ * Gets the URI associated with this link.
+ *
+ * @return string The URI
+ */
+ public function getUri()
+ {
+ $uri = trim($this->getRawUri());
+
+ // absolute URL?
+ if (null !== parse_url($uri, \PHP_URL_SCHEME)) {
+ return $uri;
+ }
+
+ // empty URI
+ if (!$uri) {
+ return $this->currentUri;
+ }
+
+ // an anchor
+ if ('#' === $uri[0]) {
+ return $this->cleanupAnchor($this->currentUri).$uri;
+ }
+
+ $baseUri = $this->cleanupUri($this->currentUri);
+
+ if ('?' === $uri[0]) {
+ return $baseUri.$uri;
+ }
+
+ // absolute URL with relative schema
+ if (0 === strpos($uri, '//')) {
+ return preg_replace('#^([^/]*)//.*$#', '$1', $baseUri).$uri;
+ }
+
+ $baseUri = preg_replace('#^(.*?//[^/]*)(?:\/.*)?$#', '$1', $baseUri);
+
+ // absolute path
+ if ('/' === $uri[0]) {
+ return $baseUri.$uri;
+ }
+
+ // relative path
+ $path = parse_url(substr($this->currentUri, \strlen($baseUri)), \PHP_URL_PATH);
+ $path = $this->canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri);
+
+ return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path;
+ }
+
+ /**
+ * Returns raw URI data.
+ *
+ * @return string
+ */
+ abstract protected function getRawUri();
+
+ /**
+ * Returns the canonicalized URI path (see RFC 3986, section 5.2.4).
+ *
+ * @param string $path URI path
+ *
+ * @return string
+ */
+ protected function canonicalizePath($path)
+ {
+ if ('' === $path || '/' === $path) {
+ return $path;
+ }
+
+ if ('.' === substr($path, -1)) {
+ $path .= '/';
+ }
+
+ $output = [];
+
+ foreach (explode('/', $path) as $segment) {
+ if ('..' === $segment) {
+ array_pop($output);
+ } elseif ('.' !== $segment) {
+ $output[] = $segment;
+ }
+ }
+
+ return implode('/', $output);
+ }
+
+ /**
+ * Sets current \DOMElement instance.
+ *
+ * @param \DOMElement $node A \DOMElement instance
+ *
+ * @throws \LogicException If given node is not an anchor
+ */
+ abstract protected function setNode(\DOMElement $node);
+
+ /**
+ * Removes the query string and the anchor from the given uri.
+ *
+ * @param string $uri The uri to clean
+ *
+ * @return string
+ */
+ private function cleanupUri($uri)
+ {
+ return $this->cleanupQuery($this->cleanupAnchor($uri));
+ }
+
+ /**
+ * Remove the query string from the uri.
+ *
+ * @param string $uri
+ *
+ * @return string
+ */
+ private function cleanupQuery($uri)
+ {
+ if (false !== $pos = strpos($uri, '?')) {
+ return substr($uri, 0, $pos);
+ }
+
+ return $uri;
+ }
+
+ /**
+ * Remove the anchor from the uri.
+ *
+ * @param string $uri
+ *
+ * @return string
+ */
+ private function cleanupAnchor($uri)
+ {
+ if (false !== $pos = strpos($uri, '#')) {
+ return substr($uri, 0, $pos);
+ }
+
+ return $uri;
+ }
+}
diff --git a/application/vendor/symfony/dom-crawler/CHANGELOG.md b/application/vendor/symfony/dom-crawler/CHANGELOG.md
index 48fd323..e65176f 100644
--- a/application/vendor/symfony/dom-crawler/CHANGELOG.md
+++ b/application/vendor/symfony/dom-crawler/CHANGELOG.md
@@ -1,6 +1,14 @@
CHANGELOG
=========
+3.1.0
+-----
+
+* All the URI parsing logic have been abstracted in the `AbstractUriElement` class.
+ The `Link` class is now a child of `AbstractUriElement`.
+* Added an `Image` class to crawl images and parse their `src` attribute,
+ and `selectImage`, `image`, `images` methods in the `Crawler` (the image version of the equivalent `link` methods).
+
2.5.0
-----
diff --git a/application/vendor/symfony/dom-crawler/Crawler.php b/application/vendor/symfony/dom-crawler/Crawler.php
index 8cfd510..21f7fab 100644
--- a/application/vendor/symfony/dom-crawler/Crawler.php
+++ b/application/vendor/symfony/dom-crawler/Crawler.php
@@ -11,14 +11,14 @@
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
*/
-class Crawler extends \SplObjectStorage
+class Crawler implements \Countable, \IteratorAggregate
{
protected $uri;
@@ -30,7 +30,7 @@ class Crawler extends \SplObjectStorage
/**
* @var array A map of manually registered namespaces
*/
- private $namespaces = array();
+ private $namespaces = [];
/**
* @var string The base href value
@@ -38,9 +38,24 @@ class Crawler extends \SplObjectStorage
private $baseHref;
/**
- * @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
+ * @var \DOMDocument|null
+ */
+ private $document;
+
+ /**
+ * @var \DOMNode[]
+ */
+ private $nodes = [];
+
+ /**
+ * Whether the Crawler contains HTML or XML content (used when converting CSS to XPath).
+ *
+ * @var bool
+ */
+ private $isHtml = true;
+
+ /**
+ * @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A Node to use as the base for the crawling
*/
public function __construct($node = null, $uri = null, $baseHref = null)
{
@@ -50,12 +65,33 @@ public function __construct($node = null, $uri = null, $baseHref = null)
$this->add($node);
}
+ /**
+ * Returns the current URI.
+ *
+ * @return string
+ */
+ public function getUri()
+ {
+ return $this->uri;
+ }
+
+ /**
+ * Returns base href.
+ *
+ * @return string
+ */
+ public function getBaseHref()
+ {
+ return $this->baseHref;
+ }
+
/**
* Removes all the nodes.
*/
public function clear()
{
- $this->removeAll($this);
+ $this->nodes = [];
+ $this->document = null;
}
/**
@@ -64,7 +100,7 @@ public function clear()
* This method uses the appropriate specialized add*() method based
* on the type of the argument.
*
- * @param \DOMNodeList|\DOMNode|array|string|null $node A node
+ * @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A node
*
* @throws \InvalidArgumentException when node is not the expected type
*/
@@ -74,24 +110,24 @@ public function add($node)
$this->addNodeList($node);
} elseif ($node instanceof \DOMNode) {
$this->addNode($node);
- } elseif (is_array($node)) {
+ } elseif (\is_array($node)) {
$this->addNodes($node);
- } elseif (is_string($node)) {
+ } elseif (\is_string($node)) {
$this->addContent($node);
} elseif (null !== $node) {
- throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', is_object($node) ? get_class($node) : gettype($node)));
+ throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', \is_object($node) ? \get_class($node) : \gettype($node)));
}
}
/**
* 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
- * @param null|string $type The content type of the string
+ * @param string|null $type The content type of the string
*/
public function addContent($content, $type = null)
{
@@ -120,7 +156,7 @@ public function addContent($content, $type = null)
}
if (null === $charset) {
- $charset = 'ISO-8859-1';
+ $charset = preg_match('//u', $content) ? 'UTF-8' : 'ISO-8859-1';
}
if ('x' === $xmlMatches[1]) {
@@ -146,7 +182,9 @@ public function addContent($content, $type = null)
public function addHtmlContent($content, $charset = 'UTF-8')
{
$internalErrors = libxml_use_internal_errors(true);
- $disableEntities = libxml_disable_entity_loader(true);
+ if (\LIBXML_VERSION < 20900) {
+ $disableEntities = libxml_disable_entity_loader(true);
+ }
$dom = new \DOMDocument('1.0', $charset);
$dom->validateOnParse = true;
@@ -155,52 +193,28 @@ public function addHtmlContent($content, $charset = 'UTF-8')
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) {
+ } catch (\ValueError $e) {
+ } finally {
+ restore_error_handler();
}
- restore_error_handler();
-
if ('' !== trim($content)) {
@$dom->loadHTML($content);
}
libxml_use_internal_errors($internalErrors);
- libxml_disable_entity_loader($disableEntities);
+ if (\LIBXML_VERSION < 20900) {
+ libxml_disable_entity_loader($disableEntities);
+ }
$this->addDocument($dom);
- $base = $this->filterRelativeXPath('descendant-or-self::base')->extract(array('href'));
+ $base = $this->filterRelativeXPath('descendant-or-self::base')->extract(['href']);
$baseHref = current($base);
- if (count($base) && !empty($baseHref)) {
+ if (\count($base) && !empty($baseHref)) {
if ($this->baseHref) {
$linkNode = $dom->createElement('a');
$linkNode->setAttribute('href', $baseHref);
@@ -228,7 +242,7 @@ function ($m) {
* LIBXML_PARSEHUGE is dangerous, see
* http://symfony.com/blog/security-release-symfony-2-0-17-released
*/
- public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NONET)
+ 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)) {
@@ -236,7 +250,9 @@ public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NO
}
$internalErrors = libxml_use_internal_errors(true);
- $disableEntities = libxml_disable_entity_loader(true);
+ if (\LIBXML_VERSION < 20900) {
+ $disableEntities = libxml_disable_entity_loader(true);
+ }
$dom = new \DOMDocument('1.0', $charset);
$dom->validateOnParse = true;
@@ -246,9 +262,13 @@ public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NO
}
libxml_use_internal_errors($internalErrors);
- libxml_disable_entity_loader($disableEntities);
+ if (\LIBXML_VERSION < 20900) {
+ libxml_disable_entity_loader($disableEntities);
+ }
$this->addDocument($dom);
+
+ $this->isHtml = false;
}
/**
@@ -297,21 +317,23 @@ public function addNodes(array $nodes)
public function addNode(\DOMNode $node)
{
if ($node instanceof \DOMDocument) {
- $this->attach($node->documentElement);
- } else {
- $this->attach($node);
+ $node = $node->documentElement;
}
- }
- // Serializing and unserializing a crawler creates DOM objects in a corrupted state. DOM elements are not properly serializable.
- public function unserialize($serialized)
- {
- throw new \BadMethodCallException('A Crawler cannot be serialized.');
- }
+ if (null !== $this->document && $this->document !== $node->ownerDocument) {
+ throw new \InvalidArgumentException('Attaching DOM nodes from multiple documents in the same crawler is forbidden.');
+ }
- public function serialize()
- {
- throw new \BadMethodCallException('A Crawler cannot be serialized.');
+ if (null === $this->document) {
+ $this->document = $node->ownerDocument;
+ }
+
+ // Don't add duplicate nodes in the Crawler
+ if (\in_array($node, $this->nodes, true)) {
+ return;
+ }
+
+ $this->nodes[] = $node;
}
/**
@@ -319,14 +341,12 @@ public function serialize()
*
* @param int $position The position
*
- * @return self
+ * @return static
*/
public function eq($position)
{
- foreach ($this as $i => $node) {
- if ($i == $position) {
- return $this->createSubCrawler($node);
- }
+ if (isset($this->nodes[$position])) {
+ return $this->createSubCrawler($this->nodes[$position]);
}
return $this->createSubCrawler(null);
@@ -350,8 +370,8 @@ public function eq($position)
*/
public function each(\Closure $closure)
{
- $data = array();
- foreach ($this as $i => $node) {
+ $data = [];
+ foreach ($this->nodes as $i => $node) {
$data[] = $closure($this->createSubCrawler($node), $i);
}
@@ -364,11 +384,11 @@ public function each(\Closure $closure)
* @param int $offset
* @param int $length
*
- * @return self
+ * @return static
*/
- public function slice($offset = 0, $length = -1)
+ public function slice($offset = 0, $length = null)
{
- return $this->createSubCrawler(iterator_to_array(new \LimitIterator($this, $offset, $length)));
+ return $this->createSubCrawler(\array_slice($this->nodes, $offset, $length));
}
/**
@@ -378,12 +398,12 @@ public function slice($offset = 0, $length = -1)
*
* @param \Closure $closure An anonymous function
*
- * @return self
+ * @return static
*/
public function reduce(\Closure $closure)
{
- $nodes = array();
- foreach ($this as $i => $node) {
+ $nodes = [];
+ foreach ($this->nodes as $i => $node) {
if (false !== $closure($this->createSubCrawler($node), $i)) {
$nodes[] = $node;
}
@@ -395,7 +415,7 @@ public function reduce(\Closure $closure)
/**
* Returns the first node of the current selection.
*
- * @return self
+ * @return static
*/
public function first()
{
@@ -405,23 +425,23 @@ public function first()
/**
* Returns the last node of the current selection.
*
- * @return self
+ * @return static
*/
public function last()
{
- return $this->eq(count($this) - 1);
+ return $this->eq(\count($this->nodes) - 1);
}
/**
* Returns the siblings nodes of the current selection.
*
- * @return self
+ * @return static
*
* @throws \InvalidArgumentException When current node is empty
*/
public function siblings()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
@@ -431,13 +451,13 @@ public function siblings()
/**
* Returns the next siblings nodes of the current selection.
*
- * @return self
+ * @return static
*
* @throws \InvalidArgumentException When current node is empty
*/
public function nextAll()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
@@ -447,13 +467,13 @@ public function nextAll()
/**
* Returns the previous sibling nodes of the current selection.
*
- * @return self
+ * @return static
*
* @throws \InvalidArgumentException
*/
public function previousAll()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
@@ -463,21 +483,21 @@ public function previousAll()
/**
* Returns the parents nodes of the current selection.
*
- * @return self
+ * @return static
*
* @throws \InvalidArgumentException When current node is empty
*/
public function parents()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
- $nodes = array();
+ $nodes = [];
while ($node = $node->parentNode) {
- if (XML_ELEMENT_NODE === $node->nodeType) {
+ if (\XML_ELEMENT_NODE === $node->nodeType) {
$nodes[] = $node;
}
}
@@ -488,19 +508,19 @@ public function parents()
/**
* Returns the children nodes of the current selection.
*
- * @return self
+ * @return static
*
* @throws \InvalidArgumentException When current node is empty
*/
public function children()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0)->firstChild;
- return $this->createSubCrawler($node ? $this->sibling($node) : array());
+ return $this->createSubCrawler($node ? $this->sibling($node) : []);
}
/**
@@ -514,7 +534,7 @@ public function children()
*/
public function attr($attribute)
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
@@ -532,7 +552,7 @@ public function attr($attribute)
*/
public function nodeName()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
@@ -548,7 +568,7 @@ public function nodeName()
*/
public function text()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
@@ -564,7 +584,7 @@ public function text()
*/
public function html()
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
@@ -576,6 +596,36 @@ public function html()
return $html;
}
+ /**
+ * Evaluates an XPath expression.
+ *
+ * Since an XPath expression might evaluate to either a simple type or a \DOMNodeList,
+ * this method will return either an array of simple types or a new Crawler instance.
+ *
+ * @param string $xpath An XPath expression
+ *
+ * @return array|Crawler An array of evaluation results or a new Crawler instance
+ */
+ public function evaluate($xpath)
+ {
+ if (null === $this->document) {
+ throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
+ }
+
+ $data = [];
+ $domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));
+
+ foreach ($this->nodes as $node) {
+ $data[] = $domxpath->evaluate($xpath, $node);
+ }
+
+ if (isset($data[0]) && $data[0] instanceof \DOMNodeList) {
+ return $this->createSubCrawler($data);
+ }
+
+ return $data;
+ }
+
/**
* Extracts information from the list of nodes.
*
@@ -583,7 +633,7 @@ public function html()
*
* Example:
*
- * $crawler->filter('h1 a')->extract(array('_text', 'href'));
+ * $crawler->filter('h1 a')->extract(['_text', 'href']);
*
* @param array $attributes An array of attributes
*
@@ -592,11 +642,11 @@ public function html()
public function extract($attributes)
{
$attributes = (array) $attributes;
- $count = count($attributes);
+ $count = \count($attributes);
- $data = array();
- foreach ($this as $node) {
- $elements = array();
+ $data = [];
+ foreach ($this->nodes as $node) {
+ $elements = [];
foreach ($attributes as $attribute) {
if ('_text' === $attribute) {
$elements[] = $node->nodeValue;
@@ -621,7 +671,7 @@ public function extract($attributes)
*
* @param string $xpath An XPath expression
*
- * @return self
+ * @return static
*/
public function filterXPath($xpath)
{
@@ -642,18 +692,20 @@ public function filterXPath($xpath)
*
* @param string $selector A CSS selector
*
- * @return self
+ * @return static
*
* @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(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);
+
// The CssSelector already prefixes the selector with descendant-or-self::
- return $this->filterRelativeXPath(CssSelector::toXPath($selector));
+ return $this->filterRelativeXPath($converter->toXPath($selector));
}
/**
@@ -661,7 +713,7 @@ public function filter($selector)
*
* @param string $value The link text
*
- * @return self
+ * @return static
*/
public function selectLink($value)
{
@@ -671,12 +723,26 @@ public function selectLink($value)
return $this->filterRelativeXPath($xpath);
}
+ /**
+ * Selects images by alt value.
+ *
+ * @param string $value The image alt
+ *
+ * @return static A new instance of Crawler with the filtered list of nodes
+ */
+ public function selectImage($value)
+ {
+ $xpath = sprintf('descendant-or-self::img[contains(normalize-space(string(@alt)), %s)]', static::xpathLiteral($value));
+
+ return $this->filterRelativeXPath($xpath);
+ }
+
/**
* Selects a button by name or alt value for images.
*
* @param string $value The button text
*
- * @return self
+ * @return static
*/
public function selectButton($value)
{
@@ -695,16 +761,20 @@ public function selectButton($value)
*
* @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')
{
- if (!count($this)) {
+ if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$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);
}
@@ -712,17 +782,64 @@ public function link($method = 'get')
* 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) {
+ $links = [];
+ foreach ($this->nodes 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');
}
return $links;
}
+ /**
+ * Returns an Image object for the first node in the list.
+ *
+ * @return Image An Image instance
+ *
+ * @throws \InvalidArgumentException If the current node list is empty
+ */
+ public function image()
+ {
+ if (!\count($this)) {
+ throw new \InvalidArgumentException('The current node list is empty.');
+ }
+
+ $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 Image($node, $this->baseHref);
+ }
+
+ /**
+ * Returns an array of Image objects for the nodes in the list.
+ *
+ * @return Image[] An array of Image instances
+ */
+ public function images()
+ {
+ $images = [];
+ 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)));
+ }
+
+ $images[] = new Image($node, $this->baseHref);
+ }
+
+ return $images;
+ }
+
/**
* Returns a Form object for the first node in the list.
*
@@ -731,15 +848,21 @@ public function links()
*
* @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)
{
- if (!count($this)) {
+ if (!$this->nodes) {
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);
@@ -773,7 +896,7 @@ public function registerNamespace($prefix, $namespace)
* Escaped characters are: quotes (") and apostrophe (').
*
* Examples:
- *
+ *
* echo Crawler::xpathLiteral('foo " bar');
* //prints 'foo " bar'
*
@@ -782,7 +905,6 @@ public function registerNamespace($prefix, $namespace)
*
* echo Crawler::xpathLiteral('a\'b"c');
* //prints concat('a', "'", 'b"c')
- *
*
* @param string $s String to be escaped
*
@@ -799,7 +921,7 @@ public static function xpathLiteral($s)
}
$string = $s;
- $parts = array();
+ $parts = [];
while (true) {
if (false !== $pos = strpos($string, "'")) {
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
@@ -821,7 +943,7 @@ public static function xpathLiteral($s)
*
* @param string $xpath
*
- * @return self
+ * @return static
*/
private function filterRelativeXPath($xpath)
{
@@ -829,7 +951,7 @@ private function filterRelativeXPath($xpath)
$crawler = $this->createSubCrawler(null);
- foreach ($this as $node) {
+ foreach ($this->nodes as $node) {
$domxpath = $this->createDOMXPath($node->ownerDocument, $prefixes);
$crawler->add($domxpath->query($xpath, $node));
}
@@ -849,13 +971,13 @@ private function filterRelativeXPath($xpath)
*/
private function relativize($xpath)
{
- $expressions = array();
+ $expressions = [];
// An expression which will never match to replace expressions which cannot match in the crawler
- // We cannot simply drop
+ // We cannot drop
$nonMatchingExpression = 'a[name() = "b"]';
- $xpathLen = strlen($xpath);
+ $xpathLen = \strlen($xpath);
$openedBrackets = 0;
$startPosition = strspn($xpath, " \t\n\r\0\x0B");
@@ -893,10 +1015,7 @@ private function relativize($xpath)
}
$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/')) {
- $expression = './'.substr($expression, 7);
- } elseif (0 === strpos($expression, 'self::*/')) {
+ if (0 === strpos($expression, 'self::*/')) {
$expression = './'.substr($expression, 8);
}
@@ -911,12 +1030,7 @@ private function relativize($xpath)
$expression = 'self::'.substr($expression, 2);
} elseif (0 === strpos($expression, 'child::')) {
$expression = 'self::'.substr($expression, 7);
- } elseif ('/' === $expression[0] || 0 === strpos($expression, 'self::')) {
- // the only direct child in Symfony 2.4 and lower is _root, which is already handled previously
- // so let's drop the expression entirely
- $expression = $nonMatchingExpression;
- } elseif ('.' === $expression[0]) {
- // '.' is the fake root element in Symfony 2.4 and lower, which is excluded from results
+ } elseif ('/' === $expression[0] || '.' === $expression[0] || 0 === strpos($expression, 'self::')) {
$expression = $nonMatchingExpression;
} elseif (0 === strpos($expression, 'descendant::')) {
$expression = 'descendant-or-self::'.substr($expression, 12);
@@ -942,15 +1056,27 @@ private function relativize($xpath)
/**
* @param int $position
*
- * @return \DOMElement|null
+ * @return \DOMNode|null
*/
public function getNode($position)
{
- foreach ($this as $i => $node) {
- if ($i == $position) {
- return $node;
- }
- }
+ return isset($this->nodes[$position]) ? $this->nodes[$position] : null;
+ }
+
+ /**
+ * @return int
+ */
+ public function count()
+ {
+ return \count($this->nodes);
+ }
+
+ /**
+ * @return \ArrayIterator|\DOMNode[]
+ */
+ public function getIterator()
+ {
+ return new \ArrayIterator($this->nodes);
}
/**
@@ -961,7 +1087,7 @@ public function getNode($position)
*/
protected function sibling($node, $siblingDir = 'nextSibling')
{
- $nodes = array();
+ $nodes = [];
do {
if ($node !== $this->getNode(0) && 1 === $node->nodeType) {
@@ -973,14 +1099,11 @@ protected function sibling($node, $siblingDir = 'nextSibling')
}
/**
- * @param \DOMDocument $document
- * @param array $prefixes
- *
* @return \DOMXPath
*
* @throws \InvalidArgumentException
*/
- private function createDOMXPath(\DOMDocument $document, array $prefixes = array())
+ private function createDOMXPath(\DOMDocument $document, array $prefixes = [])
{
$domxpath = new \DOMXPath($document);
@@ -995,10 +1118,9 @@ private function createDOMXPath(\DOMDocument $document, array $prefixes = array(
}
/**
- * @param \DOMXPath $domxpath
- * @param string $prefix
+ * @param string $prefix
*
- * @return string
+ * @return string|null
*
* @throws \InvalidArgumentException
*/
@@ -1011,9 +1133,7 @@ private function discoverNamespace(\DOMXPath $domxpath, $prefix)
// ask for one namespace, otherwise we'd get a collection with an item for each node
$namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix));
- if ($node = $namespaces->item(0)) {
- return $node->nodeValue;
- }
+ return ($node = $namespaces->item(0)) ? $node->nodeValue : null;
}
/**
@@ -1027,18 +1147,23 @@ private function findNamespacePrefixes($xpath)
return array_unique($matches['prefix']);
}
- return array();
+ return [];
}
/**
* Creates a crawler for some subnodes.
*
- * @param \DOMElement|\DOMElement[]|\DOMNodeList|null $nodes
+ * @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $nodes
*
* @return static
*/
private function createSubCrawler($nodes)
{
- return new static($nodes, $this->uri, $this->baseHref);
+ $crawler = new static($nodes, $this->uri, $this->baseHref);
+ $crawler->isHtml = $this->isHtml;
+ $crawler->document = $this->document;
+ $crawler->namespaces = $this->namespaces;
+
+ return $crawler;
}
}
diff --git a/application/vendor/symfony/dom-crawler/Field/ChoiceFormField.php b/application/vendor/symfony/dom-crawler/Field/ChoiceFormField.php
index a3539bc..a7d2b84 100644
--- a/application/vendor/symfony/dom-crawler/Field/ChoiceFormField.php
+++ b/application/vendor/symfony/dom-crawler/Field/ChoiceFormField.php
@@ -45,7 +45,7 @@ class ChoiceFormField extends FormField
public function hasValue()
{
// don't send a value for unchecked checkboxes
- if (in_array($this->type, array('checkbox', 'radio')) && null === $this->value) {
+ if (\in_array($this->type, ['checkbox', 'radio']) && null === $this->value) {
return false;
}
@@ -75,7 +75,7 @@ public function isDisabled()
/**
* Sets the value of the field.
*
- * @param string $value The value of the field
+ * @param string|array $value The value of the field
*/
public function select($value)
{
@@ -113,7 +113,7 @@ public function untick()
/**
* Sets the value of the field.
*
- * @param string|array $value The value of the field
+ * @param string|array|bool $value The value of the field
*
* @throws \InvalidArgumentException When value type provided is not correct
*/
@@ -126,25 +126,25 @@ public function setValue($value)
// check
$this->value = $this->options[0]['value'];
} else {
- if (is_array($value)) {
+ if (\is_array($value)) {
if (!$this->multiple) {
throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name));
}
foreach ($value as $v) {
if (!$this->containsOption($v, $this->options)) {
- throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->availableOptionValues())));
+ throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: "%s").', $this->name, $v, implode('", "', $this->availableOptionValues())));
}
}
} elseif (!$this->containsOption($value, $this->options)) {
- throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->availableOptionValues())));
+ throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: "%s").', $this->name, $value, implode('", "', $this->availableOptionValues())));
}
if ($this->multiple) {
$value = (array) $value;
}
- if (is_array($value)) {
+ if (\is_array($value)) {
$this->value = $value;
} else {
parent::setValue($value);
@@ -155,8 +155,6 @@ public function setValue($value)
/**
* Adds a choice to the current ones.
*
- * @param \DOMElement $node
- *
* @throws \LogicException When choice provided is not multiple nor radio
*
* @internal
@@ -207,11 +205,11 @@ protected function initialize()
}
if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) {
- throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type')));
+ throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is "%s").', $this->node->getAttribute('type')));
}
$this->value = null;
- $this->options = array();
+ $this->options = [];
$this->multiple = false;
if ('input' == $this->node->nodeName) {
@@ -226,7 +224,7 @@ protected function initialize()
$this->type = 'select';
if ($this->node->hasAttribute('multiple')) {
$this->multiple = true;
- $this->value = array();
+ $this->value = [];
$this->name = str_replace('[]', '', $this->name);
}
@@ -255,13 +253,11 @@ protected function initialize()
/**
* Returns option value with associated disabled flag.
*
- * @param \DOMElement $node
- *
* @return array
*/
private function buildOptionValue(\DOMElement $node)
{
- $option = array();
+ $option = [];
$defaultDefaultValue = 'select' === $this->node->nodeName ? '' : 'on';
$defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : $defaultDefaultValue;
@@ -301,7 +297,7 @@ public function containsOption($optionValue, $options)
*/
public function availableOptionValues()
{
- $values = array();
+ $values = [];
foreach ($this->options as $option) {
$values[] = $option['value'];
diff --git a/application/vendor/symfony/dom-crawler/Field/FileFormField.php b/application/vendor/symfony/dom-crawler/Field/FileFormField.php
index 0e0f943..3d0b22f 100644
--- a/application/vendor/symfony/dom-crawler/Field/FileFormField.php
+++ b/application/vendor/symfony/dom-crawler/Field/FileFormField.php
@@ -27,12 +27,12 @@ class FileFormField extends FormField
*/
public function setErrorCode($error)
{
- $codes = array(UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION);
- if (!in_array($error, $codes)) {
- throw new \InvalidArgumentException(sprintf('The error code %s is not valid.', $error));
+ $codes = [\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION];
+ if (!\in_array($error, $codes)) {
+ throw new \InvalidArgumentException(sprintf('The error code "%s" is not valid.', $error));
}
- $this->value = array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => $error, 'size' => 0);
+ $this->value = ['name' => '', 'type' => '', 'tmp_name' => '', 'error' => $error, 'size' => 0];
}
/**
@@ -48,19 +48,19 @@ public function upload($value)
/**
* Sets the value of the field.
*
- * @param string $value The value of the field
+ * @param string|null $value The value of the field
*/
public function setValue($value)
{
if (null !== $value && is_readable($value)) {
- $error = UPLOAD_ERR_OK;
+ $error = \UPLOAD_ERR_OK;
$size = filesize($value);
$info = pathinfo($value);
$name = $info['basename'];
// copy to a tmp location
- $tmp = sys_get_temp_dir().'/'.sha1(uniqid(mt_rand(), true));
- if (array_key_exists('extension', $info)) {
+ $tmp = sys_get_temp_dir().'/'.strtr(substr(base64_encode(hash('sha256', uniqid(mt_rand(), true), true)), 0, 7), '/', '_');
+ if (\array_key_exists('extension', $info)) {
$tmp .= '.'.$info['extension'];
}
if (is_file($tmp)) {
@@ -69,13 +69,13 @@ public function setValue($value)
copy($value, $tmp);
$value = $tmp;
} else {
- $error = UPLOAD_ERR_NO_FILE;
+ $error = \UPLOAD_ERR_NO_FILE;
$size = 0;
$name = '';
$value = '';
}
- $this->value = array('name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size);
+ $this->value = ['name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size];
}
/**
@@ -100,7 +100,7 @@ protected function initialize()
}
if ('file' !== strtolower($this->node->getAttribute('type'))) {
- throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $this->node->getAttribute('type')));
+ throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is "%s").', $this->node->getAttribute('type')));
}
$this->setValue(null);
diff --git a/application/vendor/symfony/dom-crawler/Field/FormField.php b/application/vendor/symfony/dom-crawler/Field/FormField.php
index 496d45d..0bc4f54 100644
--- a/application/vendor/symfony/dom-crawler/Field/FormField.php
+++ b/application/vendor/symfony/dom-crawler/Field/FormField.php
@@ -55,6 +55,27 @@ public function __construct(\DOMElement $node)
$this->initialize();
}
+ /**
+ * Returns the label tag associated to the field or null if none.
+ *
+ * @return \DOMElement|null
+ */
+ public function getLabel()
+ {
+ $xpath = new \DOMXPath($this->node->ownerDocument);
+
+ if ($this->node->hasAttribute('id')) {
+ $labels = $xpath->query(sprintf('descendant::label[@for="%s"]', $this->node->getAttribute('id')));
+ if ($labels->length > 0) {
+ return $labels->item(0);
+ }
+ }
+
+ $labels = $xpath->query('ancestor::label[1]', $this->node);
+
+ return $labels->length > 0 ? $labels->item(0) : null;
+ }
+
/**
* Returns the name of the field.
*
@@ -78,7 +99,7 @@ public function getValue()
/**
* Sets the value of the field.
*
- * @param string $value The value of the field
+ * @param string|array|bool|null $value The value of the field
*/
public function setValue($value)
{
diff --git a/application/vendor/symfony/dom-crawler/Form.php b/application/vendor/symfony/dom-crawler/Form.php
index 258be96..7c85ec6 100644
--- a/application/vendor/symfony/dom-crawler/Form.php
+++ b/application/vendor/symfony/dom-crawler/Form.php
@@ -87,7 +87,7 @@ public function setValues(array $values)
*/
public function getValues()
{
- $values = array();
+ $values = [];
foreach ($this->fields->all() as $name => $field) {
if ($field->isDisabled()) {
continue;
@@ -108,11 +108,11 @@ public function getValues()
*/
public function getFiles()
{
- if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
- return array();
+ if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) {
+ return [];
}
- $files = array();
+ $files = [];
foreach ($this->fields->all() as $name => $field) {
if ($field->isDisabled()) {
@@ -137,13 +137,13 @@ public function getFiles()
*/
public function getPhpValues()
{
- $values = array();
+ $values = [];
foreach ($this->getValues() as $name => $value) {
- $qs = http_build_query(array($name => $value), '', '&');
+ $qs = http_build_query([$name => $value], '', '&');
if (!empty($qs)) {
parse_str($qs, $expandedValue);
- $varName = substr($name, 0, strlen(key($expandedValue)));
- $values = array_replace_recursive($values, array($varName => current($expandedValue)));
+ $varName = substr($name, 0, \strlen(key($expandedValue)));
+ $values = array_replace_recursive($values, [$varName => current($expandedValue)]);
}
}
@@ -164,12 +164,12 @@ public function getPhpValues()
*/
public function getPhpFiles()
{
- $values = array();
+ $values = [];
foreach ($this->getFiles() as $name => $value) {
- $qs = http_build_query(array($name => $value), '', '&');
+ $qs = http_build_query([$name => $value], '', '&');
if (!empty($qs)) {
parse_str($qs, $expandedValue);
- $varName = substr($name, 0, strlen(key($expandedValue)));
+ $varName = substr($name, 0, \strlen(key($expandedValue)));
array_walk_recursive(
$expandedValue,
@@ -182,7 +182,7 @@ function (&$value, $key) {
reset($expandedValue);
- $values = array_replace_recursive($values, array($varName => current($expandedValue)));
+ $values = array_replace_recursive($values, [$varName => current($expandedValue)]);
}
}
@@ -202,9 +202,9 @@ public function getUri()
{
$uri = parent::getUri();
- if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
- $query = parse_url($uri, PHP_URL_QUERY);
- $currentParameters = array();
+ if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) {
+ $query = parse_url($uri, \PHP_URL_QUERY);
+ $currentParameters = [];
if ($query) {
parse_str($query, $currentParameters);
}
@@ -221,6 +221,11 @@ public function getUri()
protected function getRawUri()
{
+ // If the form was created from a button rather than the form node, check for HTML5 action overrides
+ if ($this->button !== $this->node && $this->button->getAttribute('formaction')) {
+ return $this->button->getAttribute('formaction');
+ }
+
return $this->node->getAttribute('action');
}
@@ -237,6 +242,11 @@ public function getMethod()
return $this->method;
}
+ // If the form was created from a button rather than the form node, check for HTML5 method override
+ if ($this->button !== $this->node && $this->button->getAttribute('formmethod')) {
+ return strtoupper($this->button->getAttribute('formmethod'));
+ }
+
return $this->node->getAttribute('method') ? strtoupper($this->node->getAttribute('method')) : 'GET';
}
@@ -267,7 +277,7 @@ public function remove($name)
*
* @param string $name The field name
*
- * @return FormField The field instance
+ * @return FormField|FormField[]|FormField[][] The value of the field
*
* @throws \InvalidArgumentException When field is not present in this form
*/
@@ -311,7 +321,7 @@ public function offsetExists($name)
*
* @param string $name The field name
*
- * @return FormField The associated Field instance
+ * @return FormField|FormField[]|FormField[][] The value of the field
*
* @throws \InvalidArgumentException if the field does not exist
*/
@@ -369,7 +379,7 @@ public function disableValidation()
protected function setNode(\DOMElement $node)
{
$this->button = $node;
- if ('button' === $node->nodeName || ('input' === $node->nodeName && in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) {
+ if ('button' === $node->nodeName || ('input' === $node->nodeName && \in_array(strtolower($node->getAttribute('type')), ['submit', 'button', 'image']))) {
if ($node->hasAttribute('form')) {
// if the node has the HTML5-compliant 'form' attribute, use it
$formId = $node->getAttribute('form');
@@ -433,14 +443,14 @@ private function initialize()
// corresponding elements are either descendants or have a matching HTML5 form attribute
$formId = Crawler::xpathLiteral($this->node->getAttribute('id'));
- $fieldNodes = $xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%1$s] | descendant::textarea[@form=%1$s] | descendant::select[@form=%1$s] | //form[@id=%1$s]//input[not(@form)] | //form[@id=%1$s]//button[not(@form)] | //form[@id=%1$s]//textarea[not(@form)] | //form[@id=%1$s]//select[not(@form)]', $formId));
+ $fieldNodes = $xpath->query(sprintf('( descendant::input[@form=%s] | descendant::button[@form=%1$s] | descendant::textarea[@form=%1$s] | descendant::select[@form=%1$s] | //form[@id=%1$s]//input[not(@form)] | //form[@id=%1$s]//button[not(@form)] | //form[@id=%1$s]//textarea[not(@form)] | //form[@id=%1$s]//select[not(@form)] )[not(ancestor::template)]', $formId));
foreach ($fieldNodes as $node) {
$this->addField($node);
}
} else {
// do the xpath query with $this->node as the context node, to only find descendant elements
// however, descendant elements with form attribute are not part of this form
- $fieldNodes = $xpath->query('descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)]', $this->node);
+ $fieldNodes = $xpath->query('( descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)] )[not(ancestor::template)]', $this->node);
foreach ($fieldNodes as $node) {
$this->addField($node);
}
@@ -470,7 +480,7 @@ private function addField(\DOMElement $node)
}
} elseif ('input' == $nodeName && 'file' == strtolower($node->getAttribute('type'))) {
$this->set(new Field\FileFormField($node));
- } elseif ('input' == $nodeName && !in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image'))) {
+ } elseif ('input' == $nodeName && !\in_array(strtolower($node->getAttribute('type')), ['submit', 'button', 'image'])) {
$this->set(new Field\InputFormField($node));
} elseif ('textarea' == $nodeName) {
$this->set(new Field\TextareaFormField($node));
diff --git a/application/vendor/symfony/dom-crawler/FormFieldRegistry.php b/application/vendor/symfony/dom-crawler/FormFieldRegistry.php
index 6ad6d93..af8bcfb 100644
--- a/application/vendor/symfony/dom-crawler/FormFieldRegistry.php
+++ b/application/vendor/symfony/dom-crawler/FormFieldRegistry.php
@@ -20,7 +20,7 @@
*/
class FormFieldRegistry
{
- private $fields = array();
+ private $fields = [];
private $base;
@@ -33,8 +33,8 @@ public function add(FormField $field)
$target = &$this->fields;
while ($segments) {
- if (!is_array($target)) {
- $target = array();
+ if (!\is_array($target)) {
+ $target = [];
}
$path = array_shift($segments);
if ('' === $path) {
@@ -55,9 +55,9 @@ public function remove($name)
{
$segments = $this->getSegments($name);
$target = &$this->fields;
- while (count($segments) > 1) {
+ while (\count($segments) > 1) {
$path = array_shift($segments);
- if (!array_key_exists($path, $target)) {
+ if (!\is_array($target) || !\array_key_exists($path, $target)) {
return;
}
$target = &$target[$path];
@@ -70,7 +70,7 @@ public function remove($name)
*
* @param string $name The fully qualified name of the field
*
- * @return mixed The value of the field
+ * @return FormField|FormField[]|FormField[][] The value of the field
*
* @throws \InvalidArgumentException if the field does not exist
*/
@@ -80,8 +80,8 @@ public function &get($name)
$target = &$this->fields;
while ($segments) {
$path = array_shift($segments);
- if (!array_key_exists($path, $target)) {
- throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path));
+ if (!\is_array($target) || !\array_key_exists($path, $target)) {
+ throw new \InvalidArgumentException(sprintf('Unreachable field "%s".', $path));
}
$target = &$target[$path];
}
@@ -118,11 +118,13 @@ public function has($name)
public function set($name, $value)
{
$target = &$this->get($name);
- if ((!is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {
+ if ((!\is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {
$target->setValue($value);
- } elseif (is_array($value)) {
- $fields = self::create($name, $value);
- foreach ($fields->all() as $k => $v) {
+ } elseif (\is_array($value)) {
+ $registry = new static();
+ $registry->base = $name;
+ $registry->fields = $value;
+ foreach ($registry->all() as $k => $v) {
$this->set($k, $v);
}
} else {
@@ -133,33 +135,13 @@ public function set($name, $value)
/**
* Returns the list of field with their value.
*
- * @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value)
+ * @return FormField[] The list of fields as [string] Fully qualified name => (mixed) value)
*/
public function all()
{
return $this->walk($this->fields, $this->base);
}
- /**
- * Creates an instance of the class.
- *
- * This function is made private because it allows overriding the $base and
- * the $values properties without any type checking.
- *
- * @param string $base The fully qualified name of the base field
- * @param array $values The values of the fields
- *
- * @return static
- */
- private static function create($base, array $values)
- {
- $registry = new static();
- $registry->base = $base;
- $registry->fields = $values;
-
- return $registry;
- }
-
/**
* Transforms a PHP array in a list of fully qualified name / value.
*
@@ -167,13 +149,13 @@ private static function create($base, array $values)
* @param string $base The name of the base field
* @param array $output The initial values
*
- * @return array The list of fields as array((string) Fully qualified name => (mixed) value)
+ * @return array The list of fields as [string] Fully qualified name => (mixed) value)
*/
- private function walk(array $array, $base = '', array &$output = array())
+ private function walk(array $array, $base = '', array &$output = [])
{
foreach ($array as $k => $v) {
$path = empty($base) ? $k : sprintf('%s[%s]', $base, $k);
- if (is_array($v)) {
+ if (\is_array($v)) {
$this->walk($v, $path, $output);
} else {
$output[$path] = $v;
@@ -186,9 +168,7 @@ private function walk(array $array, $base = '', array &$output = array())
/**
* Splits a field name into segments as a web browser would do.
*
- *
- * getSegments('base[foo][3][]') = array('base', 'foo, '3', '');
- *
+ * getSegments('base[foo][3][]') = ['base', 'foo, '3', ''];
*
* @param string $name The name of the field
*
@@ -197,7 +177,7 @@ private function walk(array $array, $base = '', array &$output = array())
private function getSegments($name)
{
if (preg_match('/^(?P[^[]+)(?P(\[.*)|$)/', $name, $m)) {
- $segments = array($m['base']);
+ $segments = [$m['base']];
while (!empty($m['extra'])) {
$extra = $m['extra'];
if (preg_match('/^\[(?P.*?)\](?P.*)$/', $extra, $m)) {
@@ -210,6 +190,6 @@ private function getSegments($name)
return $segments;
}
- return array($name);
+ return [$name];
}
}
diff --git a/application/vendor/symfony/dom-crawler/Image.php b/application/vendor/symfony/dom-crawler/Image.php
new file mode 100644
index 0000000..4d64032
--- /dev/null
+++ b/application/vendor/symfony/dom-crawler/Image.php
@@ -0,0 +1,37 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DomCrawler;
+
+/**
+ * Image represents an HTML image (an HTML img tag).
+ */
+class Image extends AbstractUriElement
+{
+ public function __construct(\DOMElement $node, $currentUri)
+ {
+ parent::__construct($node, $currentUri, 'GET');
+ }
+
+ protected function getRawUri()
+ {
+ return $this->node->getAttribute('src');
+ }
+
+ protected function setNode(\DOMElement $node)
+ {
+ if ('img' !== $node->nodeName) {
+ throw new \LogicException(sprintf('Unable to visualize a "%s" tag.', $node->nodeName));
+ }
+
+ $this->node = $node;
+ }
+}
diff --git a/application/vendor/symfony/dom-crawler/LICENSE b/application/vendor/symfony/dom-crawler/LICENSE
index 21d7fb9..9e936ec 100644
--- a/application/vendor/symfony/dom-crawler/LICENSE
+++ b/application/vendor/symfony/dom-crawler/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2018 Fabien Potencier
+Copyright (c) 2004-2020 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
diff --git a/application/vendor/symfony/dom-crawler/Link.php b/application/vendor/symfony/dom-crawler/Link.php
index b68f246..80a356e 100644
--- a/application/vendor/symfony/dom-crawler/Link.php
+++ b/application/vendor/symfony/dom-crawler/Link.php
@@ -16,157 +16,13 @@
*
* @author Fabien Potencier
*/
-class Link
+class Link extends AbstractUriElement
{
- /**
- * @var \DOMElement
- */
- protected $node;
-
- /**
- * @var string The method to use for the link
- */
- protected $method;
-
- /**
- * @var string The URI of the page where the link is embedded (or the base href)
- */
- protected $currentUri;
-
- /**
- * @param \DOMElement $node A \DOMElement instance
- * @param string $currentUri The URI of the page where the link is embedded (or the base href)
- * @param string $method The method to use for the link (get by default)
- *
- * @throws \InvalidArgumentException if the node is not a link
- */
- public function __construct(\DOMElement $node, $currentUri, $method = 'GET')
- {
- if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) {
- throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
- }
-
- $this->setNode($node);
- $this->method = $method ? strtoupper($method) : null;
- $this->currentUri = $currentUri;
- }
-
- /**
- * Gets the node associated with this link.
- *
- * @return \DOMElement A \DOMElement instance
- */
- public function getNode()
- {
- return $this->node;
- }
-
- /**
- * Gets the method associated with this link.
- *
- * @return string The method
- */
- public function getMethod()
- {
- return $this->method;
- }
-
- /**
- * Gets the URI associated with this link.
- *
- * @return string The URI
- */
- public function getUri()
- {
- $uri = trim($this->getRawUri());
-
- // absolute URL?
- if (null !== parse_url($uri, PHP_URL_SCHEME)) {
- return $uri;
- }
-
- // empty URI
- if (!$uri) {
- return $this->currentUri;
- }
-
- // an anchor
- if ('#' === $uri[0]) {
- return $this->cleanupAnchor($this->currentUri).$uri;
- }
-
- $baseUri = $this->cleanupUri($this->currentUri);
-
- if ('?' === $uri[0]) {
- return $baseUri.$uri;
- }
-
- // absolute URL with relative schema
- if (0 === strpos($uri, '//')) {
- return preg_replace('#^([^/]*)//.*$#', '$1', $baseUri).$uri;
- }
-
- $baseUri = preg_replace('#^(.*?//[^/]*)(?:\/.*)?$#', '$1', $baseUri);
-
- // absolute path
- if ('/' === $uri[0]) {
- return $baseUri.$uri;
- }
-
- // relative path
- $path = parse_url(substr($this->currentUri, strlen($baseUri)), PHP_URL_PATH);
- $path = $this->canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri);
-
- return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path;
- }
-
- /**
- * Returns raw URI data.
- *
- * @return string
- */
protected function getRawUri()
{
return $this->node->getAttribute('href');
}
- /**
- * Returns the canonicalized URI path (see RFC 3986, section 5.2.4).
- *
- * @param string $path URI path
- *
- * @return string
- */
- protected function canonicalizePath($path)
- {
- if ('' === $path || '/' === $path) {
- return $path;
- }
-
- if ('.' === substr($path, -1)) {
- $path .= '/';
- }
-
- $output = array();
-
- foreach (explode('/', $path) as $segment) {
- if ('..' === $segment) {
- array_pop($output);
- } elseif ('.' !== $segment) {
- $output[] = $segment;
- }
- }
-
- return implode('/', $output);
- }
-
- /**
- * Sets current \DOMElement instance.
- *
- * @param \DOMElement $node A \DOMElement instance
- *
- * @throws \LogicException If given node is not an anchor
- */
protected function setNode(\DOMElement $node)
{
if ('a' !== $node->nodeName && 'area' !== $node->nodeName && 'link' !== $node->nodeName) {
@@ -175,48 +31,4 @@ protected function setNode(\DOMElement $node)
$this->node = $node;
}
-
- /**
- * Removes the query string and the anchor from the given uri.
- *
- * @param string $uri The uri to clean
- *
- * @return string
- */
- private function cleanupUri($uri)
- {
- return $this->cleanupQuery($this->cleanupAnchor($uri));
- }
-
- /**
- * Remove the query string from the uri.
- *
- * @param string $uri
- *
- * @return string
- */
- private function cleanupQuery($uri)
- {
- if (false !== $pos = strpos($uri, '?')) {
- return substr($uri, 0, $pos);
- }
-
- return $uri;
- }
-
- /**
- * Remove the anchor from the uri.
- *
- * @param string $uri
- *
- * @return string
- */
- private function cleanupAnchor($uri)
- {
- if (false !== $pos = strpos($uri, '#')) {
- return substr($uri, 0, $pos);
- }
-
- return $uri;
- }
}
diff --git a/application/vendor/symfony/dom-crawler/Tests/CrawlerTest.php b/application/vendor/symfony/dom-crawler/Tests/CrawlerTest.php
index 74acfdf..26164dc 100644
--- a/application/vendor/symfony/dom-crawler/Tests/CrawlerTest.php
+++ b/application/vendor/symfony/dom-crawler/Tests/CrawlerTest.php
@@ -12,7 +12,6 @@
namespace Symfony\Component\DomCrawler\Tests;
use PHPUnit\Framework\TestCase;
-use Symfony\Component\CssSelector\CssSelector;
use Symfony\Component\DomCrawler\Crawler;
class CrawlerTest extends TestCase
@@ -22,10 +21,27 @@ public function testConstructor()
$crawler = new Crawler();
$this->assertCount(0, $crawler, '__construct() returns an empty crawler');
- $crawler = new Crawler(new \DOMNode());
+ $doc = new \DOMDocument();
+ $node = $doc->createElement('test');
+
+ $crawler = new Crawler($node);
$this->assertCount(1, $crawler, '__construct() takes a node as a first argument');
}
+ public function testGetUri()
+ {
+ $uri = 'http://symfony.com';
+ $crawler = new Crawler(null, $uri);
+ $this->assertEquals($uri, $crawler->getUri());
+ }
+
+ public function testGetBaseHref()
+ {
+ $baseHref = 'http://symfony.com';
+ $crawler = new Crawler(null, null, $baseHref);
+ $this->assertEquals($baseHref, $crawler->getBaseHref());
+ }
+
public function testAdd()
{
$crawler = new Crawler();
@@ -36,6 +52,7 @@ public function testAdd()
$crawler->add($this->createNodeList());
$this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from a \DOMNodeList');
+ $list = [];
foreach ($this->createNodeList() as $node) {
$list[] = $node;
}
@@ -45,28 +62,39 @@ public function testAdd()
$crawler = new Crawler();
$crawler->add($this->createNodeList()->item(0));
- $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from a \DOMElement');
+ $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from a \DOMNode');
$crawler = new Crawler();
$crawler->add('Foo');
$this->assertEquals('Foo', $crawler->filterXPath('//body')->text(), '->add() adds nodes from a string');
}
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testAddInvalidNode()
+ public function testAddInvalidType()
{
+ $this->expectException('InvalidArgumentException');
$crawler = new Crawler();
$crawler->add(1);
}
+ public function testAddMultipleDocumentNode()
+ {
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Attaching DOM nodes from multiple documents in the same crawler is forbidden.');
+ $crawler = $this->createTestCrawler();
+ $crawler->addHtmlContent('', 'UTF-8');
+ }
+
public function testAddHtmlContent()
{
$crawler = new Crawler();
$crawler->addHtmlContent('
', 'UTF-8');
$this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addHtmlContent() adds nodes from an HTML string');
+ }
+
+ public function testAddHtmlContentWithBaseTag()
+ {
+ $crawler = new Crawler();
$crawler->addHtmlContent('
', 'UTF-8');
@@ -237,6 +265,7 @@ public function testAddNodeList()
public function testAddNodes()
{
+ $list = [];
foreach ($this->createNodeList() as $node) {
$list[] = $node;
}
@@ -252,12 +281,15 @@ public function testAddNode()
$crawler = new Crawler();
$crawler->addNode($this->createNodeList()->item(0));
- $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addNode() adds nodes from a \DOMElement');
+ $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addNode() adds nodes from a \DOMNode');
}
public function testClear()
{
- $crawler = new Crawler(new \DOMNode());
+ $doc = new \DOMDocument();
+ $node = $doc->createElement('test');
+
+ $crawler = new Crawler($node);
$crawler->clear();
$this->assertCount(0, $crawler, '->clear() removes all the nodes from the crawler');
}
@@ -278,7 +310,15 @@ public function testEach()
return $i.'-'.$node->text();
});
- $this->assertEquals(array('0-One', '1-Two', '2-Three'), $data, '->each() executes an anonymous function on each node of the list');
+ $this->assertEquals(['0-One', '1-Two', '2-Three'], $data, '->each() executes an anonymous function on each node of the list');
+ }
+
+ public function testIteration()
+ {
+ $crawler = $this->createTestCrawler()->filterXPath('//li');
+
+ $this->assertInstanceOf('Traversable', $crawler);
+ $this->assertContainsOnlyInstancesOf('DOMElement', iterator_to_array($crawler), 'Iterating a Crawler gives DOMElement instances');
}
public function testSlice()
@@ -367,11 +407,11 @@ public function testExtract()
{
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
- $this->assertEquals(array('One', 'Two', 'Three'), $crawler->extract('_text'), '->extract() returns an array of extracted data from the node list');
- $this->assertEquals(array(array('One', 'first'), array('Two', ''), array('Three', '')), $crawler->extract(array('_text', 'class')), '->extract() returns an array of extracted data from the node list');
- $this->assertEquals(array(array(), array(), array()), $crawler->extract(array()), '->extract() returns empty arrays if the attribute list is empty');
+ $this->assertEquals(['One', 'Two', 'Three'], $crawler->extract('_text'), '->extract() returns an array of extracted data from the node list');
+ $this->assertEquals([['One', 'first'], ['Two', ''], ['Three', '']], $crawler->extract(['_text', 'class']), '->extract() returns an array of extracted data from the node list');
+ $this->assertEquals([[], [], []], $crawler->extract([]), '->extract() returns empty arrays if the attribute list is empty');
- $this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty');
+ $this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty');
}
public function testFilterXpathComplexQueries()
@@ -380,7 +420,6 @@ public function testFilterXpathComplexQueries()
$this->assertCount(0, $crawler->filterXPath('/input'));
$this->assertCount(0, $crawler->filterXPath('/body'));
- $this->assertCount(1, $crawler->filterXPath('/_root/body'));
$this->assertCount(1, $crawler->filterXPath('./body'));
$this->assertCount(1, $crawler->filterXPath('.//body'));
$this->assertCount(5, $crawler->filterXPath('.//input'));
@@ -411,6 +450,12 @@ public function testFilterXPath()
$this->assertCount(3, $crawler->filterXPath('//body')->filterXPath('//button')->parents(), '->filterXpath() preserves parents when chained');
}
+ public function testFilterRemovesDuplicates()
+ {
+ $crawler = $this->createTestCrawler()->filter('html, body')->filter('li');
+ $this->assertCount(6, $crawler, 'The crawler removes duplicates when filtering.');
+ }
+
public function testFilterXPathWithDefaultNamespace()
{
$crawler = $this->createTestXmlCrawler()->filterXPath('//default:entry/default:id');
@@ -464,7 +509,6 @@ public function testFilterXPathWithFakeRoot()
{
$crawler = $this->createTestCrawler();
$this->assertCount(0, $crawler->filterXPath('.'), '->filterXPath() returns an empty result if the XPath references the fake root node');
- $this->assertCount(0, $crawler->filterXPath('/_root'), '->filterXPath() returns an empty result if the XPath references the fake root node');
$this->assertCount(0, $crawler->filterXPath('self::*'), '->filterXPath() returns an empty result if the XPath references the fake root node');
$this->assertCount(0, $crawler->filterXPath('self::_root'), '->filterXPath() returns an empty result if the XPath references the fake root node');
}
@@ -580,16 +624,12 @@ public function testFilterWithDefaultNamespace()
public function testFilterWithNamespace()
{
- CssSelector::disableHtmlExtension();
-
$crawler = $this->createTestXmlCrawler()->filter('yt|accessControl');
$this->assertCount(2, $crawler, '->filter() automatically registers namespaces');
}
public function testFilterWithMultipleNamespaces()
{
- CssSelector::disableHtmlExtension();
-
$crawler = $this->createTestXmlCrawler()->filter('media|group yt|aspectRatio');
$this->assertCount(1, $crawler, '->filter() automatically registers namespaces');
$this->assertSame('widescreen', $crawler->text());
@@ -636,6 +676,17 @@ public function testSelectLink()
$this->assertCount(4, $crawler->selectLink('Bar'), '->selectLink() selects links by the node values');
}
+ public function testSelectImage()
+ {
+ $crawler = $this->createTestCrawler();
+ $this->assertNotSame($crawler, $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler');
+ $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectImage() returns a new instance of a crawler');
+
+ $this->assertCount(1, $crawler->selectImage('Fabien\'s Bar'), '->selectImage() selects images by alt attribute');
+ $this->assertCount(2, $crawler->selectImage('Fabien"s Bar'), '->selectImage() selects images by alt attribute');
+ $this->assertCount(1, $crawler->selectImage('\' Fabien"s Bar'), '->selectImage() selects images by alt attribute');
+ }
+
public function testSelectButton()
{
$crawler = $this->createTestCrawler();
@@ -714,6 +765,35 @@ public function testLink()
}
}
+ public function testInvalidLink()
+ {
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The selected node should be instance of DOMElement');
+ $crawler = $this->createTestCrawler('http://example.com/bar/');
+ $crawler->filterXPath('//li/text()')->link();
+ }
+
+ public function testInvalidLinks()
+ {
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The selected node should be instance of DOMElement');
+ $crawler = $this->createTestCrawler('http://example.com/bar/');
+ $crawler->filterXPath('//li/text()')->link();
+ }
+
+ public function testImage()
+ {
+ $crawler = $this->createTestCrawler('http://example.com/bar/')->selectImage('Bar');
+ $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Image', $crawler->image(), '->image() returns an Image instance');
+
+ try {
+ $this->createTestCrawler()->filterXPath('//ol')->image();
+ $this->fail('->image() throws an \InvalidArgumentException if the node list is empty');
+ } catch (\InvalidArgumentException $e) {
+ $this->assertTrue(true, '->image() throws an \InvalidArgumentException if the node list is empty');
+ }
+ }
+
public function testSelectLinkAndLinkFiltered()
{
$html = <<<'HTML'
@@ -755,13 +835,25 @@ public function testChaining()
public function testLinks()
{
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo');
- $this->assertInternalType('array', $crawler->links(), '->links() returns an array');
+ $this->assertIsArray($crawler->links(), '->links() returns an array');
$this->assertCount(4, $crawler->links(), '->links() returns an array');
$links = $crawler->links();
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $links[0], '->links() returns an array of Link instances');
- $this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
+ $this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
+ }
+
+ public function testImages()
+ {
+ $crawler = $this->createTestCrawler('http://example.com/bar/')->selectImage('Bar');
+ $this->assertIsArray($crawler->images(), '->images() returns an array');
+
+ $this->assertCount(4, $crawler->images(), '->images() returns an array');
+ $images = $crawler->images();
+ $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Image', $images[0], '->images() returns an array of Image instances');
+
+ $this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
}
public function testForm()
@@ -774,9 +866,9 @@ public function testForm()
$this->assertEquals($crawler->form()->getFormNode()->getAttribute('id'), $crawler2->form()->getFormNode()->getAttribute('id'), '->form() works on elements with form attribute');
- $this->assertEquals(array('FooName' => 'FooBar', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler->form(array('FooName' => 'FooBar'))->getValues(), '->form() takes an array of values to submit as its first argument');
- $this->assertEquals(array('FooName' => 'FooValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler->form()->getValues(), '->getValues() returns correct form values');
- $this->assertEquals(array('FooBarName' => 'FooBarValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler2->form()->getValues(), '->getValues() returns correct form values');
+ $this->assertEquals(['FooName' => 'FooBar', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'], $crawler->form(['FooName' => 'FooBar'])->getValues(), '->form() takes an array of values to submit as its first argument');
+ $this->assertEquals(['FooName' => 'FooValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'], $crawler->form()->getValues(), '->getValues() returns correct form values');
+ $this->assertEquals(['FooBarName' => 'FooBarValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'], $crawler2->form()->getValues(), '->getValues() returns correct form values');
try {
$this->createTestCrawler()->filterXPath('//ol')->form();
@@ -786,6 +878,14 @@ public function testForm()
}
}
+ public function testInvalidForm()
+ {
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The selected node should be instance of DOMElement');
+ $crawler = $this->createTestCrawler('http://example.com/bar/');
+ $crawler->filterXPath('//li/text()')->form();
+ }
+
public function testLast()
{
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
@@ -889,7 +989,7 @@ public function testChildren()
$this->assertTrue(true, '->children() does not trigger a notice if the node has no children');
} catch (\PHPUnit\Framework\Error\Notice $e) {
$this->fail('->children() does not trigger a notice if the node has no children');
- } catch (\PHPUnit_Framework_Error_Notice $e) {
+ } catch (\PHPUnit\Framework\Error\Notice $e) {
$this->fail('->children() does not trigger a notice if the node has no children');
}
}
@@ -917,7 +1017,7 @@ public function testParents()
/**
* @dataProvider getBaseTagData
*/
- public function testBaseTag($baseValue, $linkValue, $expectedUri, $currentUri = null, $description = null)
+ public function testBaseTag($baseValue, $linkValue, $expectedUri, $currentUri = null, $description = '')
{
$crawler = new Crawler('
', $currentUri);
$this->assertEquals($expectedUri, $crawler->filterXPath('//a')->link()->getUri(), $description);
@@ -925,13 +1025,13 @@ public function testBaseTag($baseValue, $linkValue, $expectedUri, $currentUri =
public function getBaseTagData()
{
- return array(
- array('http://base.com', 'link', 'http://base.com/link'),
- array('//base.com', 'link', 'https://base.com/link', 'https://domain.com', '
tag can use a schema-less URL'),
- array('path/', 'link', 'https://domain.com/path/link', 'https://domain.com', '
tag can set a path'),
- array('http://base.com', '#', 'http://base.com#', 'http://domain.com/path/link', '
tag does work with links to an anchor'),
- array('http://base.com', '', 'http://base.com', 'http://domain.com/path/link', '
tag does work with empty links'),
- );
+ return [
+ ['http://base.com', 'link', 'http://base.com/link'],
+ ['//base.com', 'link', 'https://base.com/link', 'https://domain.com', '
tag can use a schema-less URL'],
+ ['path/', 'link', 'https://domain.com/path/link', 'https://domain.com', '
tag can set a path'],
+ ['http://base.com', '#', 'http://base.com#', 'http://domain.com/path/link', '
tag does work with links to an anchor'],
+ ['http://base.com', '', 'http://base.com', 'http://domain.com/path/link', '
tag does work with empty links'],
+ ];
}
/**
@@ -945,14 +1045,14 @@ public function testBaseTagWithForm($baseValue, $actionValue, $expectedUri, $cur
public function getBaseTagWithFormData()
{
- return array(
- array('https://base.com/', 'link/', 'https://base.com/link/', 'https://base.com/link/', '
tag does work with a path and relative form action'),
- array('/basepath', '/registration', 'http://domain.com/registration', 'http://domain.com/registration', '
tag does work with a path and form action'),
- array('/basepath', '', 'http://domain.com/registration', 'http://domain.com/registration', '
tag does work with a path and empty form action'),
- array('http://base.com/', '/registration', 'http://base.com/registration', 'http://domain.com/registration', '
tag does work with a URL and form action'),
- array('http://base.com', '', 'http://domain.com/path/form', 'http://domain.com/path/form', '
tag does work with a URL and an empty form action'),
- array('http://base.com/path', '/registration', 'http://base.com/registration', 'http://domain.com/path/form', '
tag does work with a URL and form action'),
- );
+ return [
+ ['https://base.com/', 'link/', 'https://base.com/link/', 'https://base.com/link/', '
tag does work with a path and relative form action'],
+ ['/basepath', '/registration', 'http://domain.com/registration', 'http://domain.com/registration', '
tag does work with a path and form action'],
+ ['/basepath', '', 'http://domain.com/registration', 'http://domain.com/registration', '
tag does work with a path and empty form action'],
+ ['http://base.com/', '/registration', 'http://base.com/registration', 'http://domain.com/registration', '
tag does work with a URL and form action'],
+ ['http://base.com', '', 'http://domain.com/path/form', 'http://domain.com/path/form', '
tag does work with a URL and an empty form action'],
+ ['http://base.com/path', '/registration', 'http://base.com/registration', 'http://domain.com/path/form', '
tag does work with a URL and form action'],
+ ];
}
public function testCountOfNestedElements()
@@ -962,6 +1062,49 @@ public function testCountOfNestedElements()
$this->assertCount(1, $crawler->filter('li:contains("List item 1")'));
}
+ public function testEvaluateReturnsTypedResultOfXPathExpressionOnADocumentSubset()
+ {
+ $crawler = $this->createTestCrawler();
+
+ $result = $crawler->filterXPath('//form/input')->evaluate('substring-before(@name, "Name")');
+
+ $this->assertSame(['Text', 'Foo', 'Bar'], $result);
+ }
+
+ public function testEvaluateReturnsTypedResultOfNamespacedXPathExpressionOnADocumentSubset()
+ {
+ $crawler = $this->createTestXmlCrawler();
+
+ $result = $crawler->filterXPath('//yt:accessControl/@action')->evaluate('string(.)');
+
+ $this->assertSame(['comment', 'videoRespond'], $result);
+ }
+
+ public function testEvaluateReturnsTypedResultOfNamespacedXPathExpression()
+ {
+ $crawler = $this->createTestXmlCrawler();
+ $crawler->registerNamespace('youtube', 'http://gdata.youtube.com/schemas/2007');
+
+ $result = $crawler->evaluate('string(//youtube:accessControl/@action)');
+
+ $this->assertSame(['comment'], $result);
+ }
+
+ public function testEvaluateReturnsACrawlerIfXPathExpressionEvaluatesToANode()
+ {
+ $crawler = $this->createTestCrawler()->evaluate('//form/input[1]');
+
+ $this->assertInstanceOf(Crawler::class, $crawler);
+ $this->assertCount(1, $crawler);
+ $this->assertSame('input', $crawler->first()->nodeName());
+ }
+
+ public function testEvaluateThrowsAnExceptionIfDocumentIsEmpty()
+ {
+ $this->expectException('LogicException');
+ (new Crawler())->evaluate('//form/input[1]');
+ }
+
public function createTestCrawler($uri = null)
{
$dom = new \DOMDocument();
diff --git a/application/vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php b/application/vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php
index 9592286..176ea59 100644
--- a/application/vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php
+++ b/application/vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php
@@ -19,15 +19,15 @@ public function testInitialize()
{
$node = $this->createNode('textarea', '');
try {
- $field = new ChoiceFormField($node);
+ new ChoiceFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not an input or a select');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input or a select');
}
- $node = $this->createNode('input', '', array('type' => 'text'));
+ $node = $this->createNode('input', '', ['type' => 'text']);
try {
- $field = new ChoiceFormField($node);
+ new ChoiceFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is an input with a type different from checkbox or radio');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is an input with a type different from checkbox or radio');
@@ -36,12 +36,12 @@ public function testInitialize()
public function testGetType()
{
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'foo']);
$field = new ChoiceFormField($node);
$this->assertEquals('radio', $field->getType(), '->getType() returns radio for radio buttons');
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'value' => 'foo']);
$field = new ChoiceFormField($node);
$this->assertEquals('checkbox', $field->getType(), '->getType() returns radio for a checkbox');
@@ -54,12 +54,12 @@ public function testGetType()
public function testIsMultiple()
{
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'foo']);
$field = new ChoiceFormField($node);
$this->assertFalse($field->isMultiple(), '->isMultiple() returns false for radio buttons');
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'value' => 'foo']);
$field = new ChoiceFormField($node);
$this->assertFalse($field->isMultiple(), '->isMultiple() returns false for checkboxes');
@@ -69,12 +69,12 @@ public function testIsMultiple()
$this->assertFalse($field->isMultiple(), '->isMultiple() returns false for selects without the multiple attribute');
- $node = $this->createNode('select', '', array('multiple' => 'multiple'));
+ $node = $this->createNode('select', '', ['multiple' => 'multiple']);
$field = new ChoiceFormField($node);
$this->assertTrue($field->isMultiple(), '->isMultiple() returns true for selects with the multiple attribute');
- $node = $this->createNode('select', '', array('multiple' => ''));
+ $node = $this->createNode('select', '', ['multiple' => '']);
$field = new ChoiceFormField($node);
$this->assertTrue($field->isMultiple(), '->isMultiple() returns true for selects with an empty multiple attribute');
@@ -82,14 +82,14 @@ public function testIsMultiple()
public function testSelects()
{
- $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => false]);
$field = new ChoiceFormField($node);
$this->assertTrue($field->hasValue(), '->hasValue() returns true for selects');
$this->assertEquals('foo', $field->getValue(), '->getValue() returns the first option if none are selected');
$this->assertFalse($field->isMultiple(), '->isMultiple() returns false when no multiple attribute is defined');
- $node = $this->createSelectNode(array('foo' => false, 'bar' => true));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => true]);
$field = new ChoiceFormField($node);
$this->assertEquals('bar', $field->getValue(), '->getValue() returns the selected option');
@@ -105,7 +105,7 @@ public function testSelects()
}
try {
- $field->setValue(array('foobar'));
+ $field->setValue(['foobar']);
$this->fail('->setValue() throws an \InvalidArgumentException if the value is an array');
} catch (\InvalidArgumentException $e) {
$this->assertTrue(true, '->setValue() throws an \InvalidArgumentException if the value is an array');
@@ -114,7 +114,7 @@ public function testSelects()
public function testSelectWithEmptyBooleanAttribute()
{
- $node = $this->createSelectNode(array('foo' => false, 'bar' => true), array(), '');
+ $node = $this->createSelectNode(['foo' => false, 'bar' => true], [], '');
$field = new ChoiceFormField($node);
$this->assertEquals('bar', $field->getValue());
@@ -122,7 +122,7 @@ public function testSelectWithEmptyBooleanAttribute()
public function testSelectIsDisabled()
{
- $node = $this->createSelectNode(array('foo' => false, 'bar' => true), array('disabled' => 'disabled'));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => true], ['disabled' => 'disabled']);
$field = new ChoiceFormField($node);
$this->assertTrue($field->isDisabled(), '->isDisabled() returns true for selects with a disabled attribute');
@@ -130,27 +130,27 @@ public function testSelectIsDisabled()
public function testMultipleSelects()
{
- $node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple'));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => false], ['multiple' => 'multiple']);
$field = new ChoiceFormField($node);
- $this->assertEquals(array(), $field->getValue(), '->setValue() returns an empty array if multiple is true and no option is selected');
+ $this->assertEquals([], $field->getValue(), '->setValue() returns an empty array if multiple is true and no option is selected');
$field->setValue('foo');
- $this->assertEquals(array('foo'), $field->getValue(), '->setValue() returns an array of options if multiple is true');
+ $this->assertEquals(['foo'], $field->getValue(), '->setValue() returns an array of options if multiple is true');
$field->setValue('bar');
- $this->assertEquals(array('bar'), $field->getValue(), '->setValue() returns an array of options if multiple is true');
+ $this->assertEquals(['bar'], $field->getValue(), '->setValue() returns an array of options if multiple is true');
- $field->setValue(array('foo', 'bar'));
- $this->assertEquals(array('foo', 'bar'), $field->getValue(), '->setValue() returns an array of options if multiple is true');
+ $field->setValue(['foo', 'bar']);
+ $this->assertEquals(['foo', 'bar'], $field->getValue(), '->setValue() returns an array of options if multiple is true');
- $node = $this->createSelectNode(array('foo' => true, 'bar' => true), array('multiple' => 'multiple'));
+ $node = $this->createSelectNode(['foo' => true, 'bar' => true], ['multiple' => 'multiple']);
$field = new ChoiceFormField($node);
- $this->assertEquals(array('foo', 'bar'), $field->getValue(), '->getValue() returns the selected options');
+ $this->assertEquals(['foo', 'bar'], $field->getValue(), '->getValue() returns the selected options');
try {
- $field->setValue(array('foobar'));
+ $field->setValue(['foobar']);
$this->fail('->setValue() throws an \InvalidArgumentException if the value is not one of the options');
} catch (\InvalidArgumentException $e) {
$this->assertTrue(true, '->setValue() throws an \InvalidArgumentException if the value is not one of the options');
@@ -159,18 +159,18 @@ public function testMultipleSelects()
public function testRadioButtons()
{
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'foo']);
$field = new ChoiceFormField($node);
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'bar'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'bar']);
$field->addChoice($node);
$this->assertFalse($field->hasValue(), '->hasValue() returns false when no radio button is selected');
$this->assertNull($field->getValue(), '->getValue() returns null if no radio button is selected');
$this->assertFalse($field->isMultiple(), '->isMultiple() returns false for radio buttons');
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'foo']);
$field = new ChoiceFormField($node);
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'bar', 'checked' => 'checked'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'bar', 'checked' => 'checked']);
$field->addChoice($node);
$this->assertTrue($field->hasValue(), '->hasValue() returns true when a radio button is selected');
@@ -189,9 +189,9 @@ public function testRadioButtons()
public function testRadioButtonsWithEmptyBooleanAttribute()
{
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'foo']);
$field = new ChoiceFormField($node);
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'bar', 'checked' => ''));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'bar', 'checked' => '']);
$field->addChoice($node);
$this->assertTrue($field->hasValue(), '->hasValue() returns true when a radio button is selected');
@@ -200,11 +200,11 @@ public function testRadioButtonsWithEmptyBooleanAttribute()
public function testRadioButtonIsDisabled()
{
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo', 'disabled' => 'disabled'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'foo', 'disabled' => 'disabled']);
$field = new ChoiceFormField($node);
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'bar'));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'bar']);
$field->addChoice($node);
- $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'baz', 'disabled' => ''));
+ $node = $this->createNode('input', '', ['type' => 'radio', 'name' => 'name', 'value' => 'baz', 'disabled' => '']);
$field->addChoice($node);
$field->select('foo');
@@ -222,7 +222,7 @@ public function testRadioButtonIsDisabled()
public function testCheckboxes()
{
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name']);
$field = new ChoiceFormField($node);
$this->assertFalse($field->hasValue(), '->hasValue() returns false when the checkbox is not checked');
@@ -235,18 +235,18 @@ public function testCheckboxes()
$this->assertTrue(true, '->initialize() throws a \LogicException for checkboxes');
}
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'checked' => 'checked']);
$field = new ChoiceFormField($node);
$this->assertTrue($field->hasValue(), '->hasValue() returns true when the checkbox is checked');
$this->assertEquals('on', $field->getValue(), '->getValue() returns 1 if the checkbox is checked and has no value attribute');
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'checked' => 'checked', 'value' => 'foo']);
$field = new ChoiceFormField($node);
$this->assertEquals('foo', $field->getValue(), '->getValue() returns the value attribute if the checkbox is checked');
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked', 'value' => 'foo'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'checked' => 'checked', 'value' => 'foo']);
$field = new ChoiceFormField($node);
$field->setValue(false);
@@ -265,7 +265,7 @@ public function testCheckboxes()
public function testCheckboxWithEmptyBooleanAttribute()
{
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'value' => 'foo', 'checked' => ''));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'value' => 'foo', 'checked' => '']);
$field = new ChoiceFormField($node);
$this->assertTrue($field->hasValue(), '->hasValue() returns true when the checkbox is checked');
@@ -274,7 +274,7 @@ public function testCheckboxWithEmptyBooleanAttribute()
public function testTick()
{
- $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => false]);
$field = new ChoiceFormField($node);
try {
@@ -284,7 +284,7 @@ public function testTick()
$this->assertTrue(true, '->tick() throws a \LogicException for select boxes');
}
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name']);
$field = new ChoiceFormField($node);
$field->tick();
$this->assertEquals('on', $field->getValue(), '->tick() ticks checkboxes');
@@ -292,7 +292,7 @@ public function testTick()
public function testUntick()
{
- $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => false]);
$field = new ChoiceFormField($node);
try {
@@ -302,7 +302,7 @@ public function testUntick()
$this->assertTrue(true, '->untick() throws a \LogicException for select boxes');
}
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'checked' => 'checked']);
$field = new ChoiceFormField($node);
$field->untick();
$this->assertNull($field->getValue(), '->untick() unticks checkboxes');
@@ -310,14 +310,14 @@ public function testUntick()
public function testSelect()
{
- $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked'));
+ $node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'checked' => 'checked']);
$field = new ChoiceFormField($node);
$field->select(true);
$this->assertEquals('on', $field->getValue(), '->select() changes the value of the field');
$field->select(false);
$this->assertNull($field->getValue(), '->select() changes the value of the field');
- $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => false]);
$field = new ChoiceFormField($node);
$field->select('foo');
$this->assertEquals('foo', $field->getValue(), '->select() changes the selected option');
@@ -325,11 +325,11 @@ public function testSelect()
public function testOptionWithNoValue()
{
- $node = $this->createSelectNodeWithEmptyOption(array('foo' => false, 'bar' => false));
+ $node = $this->createSelectNodeWithEmptyOption(['foo' => false, 'bar' => false]);
$field = new ChoiceFormField($node);
$this->assertEquals('foo', $field->getValue());
- $node = $this->createSelectNodeWithEmptyOption(array('foo' => false, 'bar' => true));
+ $node = $this->createSelectNodeWithEmptyOption(['foo' => false, 'bar' => true]);
$field = new ChoiceFormField($node);
$this->assertEquals('bar', $field->getValue());
$field->select('foo');
@@ -338,28 +338,28 @@ public function testOptionWithNoValue()
public function testDisableValidation()
{
- $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => false]);
$field = new ChoiceFormField($node);
$field->disableValidation();
$field->setValue('foobar');
$this->assertEquals('foobar', $field->getValue(), '->disableValidation() allows to set a value which is not in the selected options.');
- $node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple'));
+ $node = $this->createSelectNode(['foo' => false, 'bar' => false], ['multiple' => 'multiple']);
$field = new ChoiceFormField($node);
$field->disableValidation();
- $field->setValue(array('foobar'));
- $this->assertEquals(array('foobar'), $field->getValue(), '->disableValidation() allows to set a value which is not in the selected options.');
+ $field->setValue(['foobar']);
+ $this->assertEquals(['foobar'], $field->getValue(), '->disableValidation() allows to set a value which is not in the selected options.');
}
public function testSelectWithEmptyValue()
{
- $node = $this->createSelectNodeWithEmptyOption(array('' => true, 'Female' => false, 'Male' => false));
+ $node = $this->createSelectNodeWithEmptyOption(['' => true, 'Female' => false, 'Male' => false]);
$field = new ChoiceFormField($node);
$this->assertSame('', $field->getValue());
}
- protected function createSelectNode($options, $attributes = array(), $selectedAttrText = 'selected')
+ protected function createSelectNode($options, $attributes = [], $selectedAttrText = 'selected')
{
$document = new \DOMDocument();
$node = $document->createElement('select');
@@ -381,7 +381,7 @@ protected function createSelectNode($options, $attributes = array(), $selectedAt
return $node;
}
- protected function createSelectNodeWithEmptyOption($options, $attributes = array())
+ protected function createSelectNodeWithEmptyOption($options, $attributes = [])
{
$document = new \DOMDocument();
$node = $document->createElement('select');
diff --git a/application/vendor/symfony/dom-crawler/Tests/Field/FileFormFieldTest.php b/application/vendor/symfony/dom-crawler/Tests/Field/FileFormFieldTest.php
index 3ce49a4..ef216aa 100644
--- a/application/vendor/symfony/dom-crawler/Tests/Field/FileFormFieldTest.php
+++ b/application/vendor/symfony/dom-crawler/Tests/Field/FileFormFieldTest.php
@@ -17,22 +17,22 @@ class FileFormFieldTest extends FormFieldTestCase
{
public function testInitialize()
{
- $node = $this->createNode('input', '', array('type' => 'file'));
+ $node = $this->createNode('input', '', ['type' => 'file']);
$field = new FileFormField($node);
- $this->assertEquals(array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0), $field->getValue(), '->initialize() sets the value of the field to no file uploaded');
+ $this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), '->initialize() sets the value of the field to no file uploaded');
$node = $this->createNode('textarea', '');
try {
- $field = new FileFormField($node);
+ new FileFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not an input field');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input field');
}
- $node = $this->createNode('input', '', array('type' => 'text'));
+ $node = $this->createNode('input', '', ['type' => 'text']);
try {
- $field = new FileFormField($node);
+ new FileFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not a file input field');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a file input field');
@@ -44,18 +44,18 @@ public function testInitialize()
*/
public function testSetValue($method)
{
- $node = $this->createNode('input', '', array('type' => 'file'));
+ $node = $this->createNode('input', '', ['type' => 'file']);
$field = new FileFormField($node);
$field->$method(null);
- $this->assertEquals(array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0), $field->getValue(), "->$method() clears the uploaded file if the value is null");
+ $this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), "->$method() clears the uploaded file if the value is null");
$field->$method(__FILE__);
$value = $field->getValue();
$this->assertEquals(basename(__FILE__), $value['name'], "->$method() sets the name of the file field");
$this->assertEquals('', $value['type'], "->$method() sets the type of the file field");
- $this->assertInternalType('string', $value['tmp_name'], "->$method() sets the tmp_name of the file field");
+ $this->assertIsString($value['tmp_name'], "->$method() sets the tmp_name of the file field");
$this->assertFileExists($value['tmp_name'], "->$method() creates a copy of the file at the tmp_name path");
$this->assertEquals(0, $value['error'], "->$method() sets the error of the file field");
$this->assertEquals(filesize(__FILE__), $value['size'], "->$method() sets the size of the file field");
@@ -80,20 +80,20 @@ public function testSetValue($method)
public function getSetValueMethods()
{
- return array(
- array('setValue'),
- array('upload'),
- );
+ return [
+ ['setValue'],
+ ['upload'],
+ ];
}
public function testSetErrorCode()
{
- $node = $this->createNode('input', '', array('type' => 'file'));
+ $node = $this->createNode('input', '', ['type' => 'file']);
$field = new FileFormField($node);
- $field->setErrorCode(UPLOAD_ERR_FORM_SIZE);
+ $field->setErrorCode(\UPLOAD_ERR_FORM_SIZE);
$value = $field->getValue();
- $this->assertEquals(UPLOAD_ERR_FORM_SIZE, $value['error'], '->setErrorCode() sets the file input field error code');
+ $this->assertEquals(\UPLOAD_ERR_FORM_SIZE, $value['error'], '->setErrorCode() sets the file input field error code');
try {
$field->setErrorCode('foobar');
@@ -105,7 +105,7 @@ public function testSetErrorCode()
public function testSetRawFilePath()
{
- $node = $this->createNode('input', '', array('type' => 'file'));
+ $node = $this->createNode('input', '', ['type' => 'file']);
$field = new FileFormField($node);
$field->setFilePath(__FILE__);
diff --git a/application/vendor/symfony/dom-crawler/Tests/Field/FormFieldTest.php b/application/vendor/symfony/dom-crawler/Tests/Field/FormFieldTest.php
index 510f762..e2daa03 100644
--- a/application/vendor/symfony/dom-crawler/Tests/Field/FormFieldTest.php
+++ b/application/vendor/symfony/dom-crawler/Tests/Field/FormFieldTest.php
@@ -17,7 +17,7 @@ class FormFieldTest extends FormFieldTestCase
{
public function testGetName()
{
- $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
+ $node = $this->createNode('input', '', ['type' => 'text', 'name' => 'name', 'value' => 'value']);
$field = new InputFormField($node);
$this->assertEquals('name', $field->getName(), '->getName() returns the name of the field');
@@ -25,7 +25,7 @@ public function testGetName()
public function testGetSetHasValue()
{
- $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
+ $node = $this->createNode('input', '', ['type' => 'text', 'name' => 'name', 'value' => 'value']);
$field = new InputFormField($node);
$this->assertEquals('value', $field->getValue(), '->getValue() returns the value of the field');
@@ -35,4 +35,38 @@ public function testGetSetHasValue()
$this->assertTrue($field->hasValue(), '->hasValue() always returns true');
}
+
+ public function testLabelReturnsNullIfNoneIsDefined()
+ {
+ $dom = new \DOMDocument();
+ $dom->loadHTML('
');
+
+ $field = new InputFormField($dom->getElementById('foo'));
+ $this->assertNull($field->getLabel(), '->getLabel() returns null if no label is defined');
+ }
+
+ public function testLabelIsAssignedByForAttribute()
+ {
+ $dom = new \DOMDocument();
+ $dom->loadHTML('
');
+
+ $field = new InputFormField($dom->getElementById('foo'));
+ $this->assertEquals('Foo label', $field->getLabel()->textContent, '->getLabel() returns the associated label');
+ }
+
+ public function testLabelIsAssignedByParentingRelation()
+ {
+ $dom = new \DOMDocument();
+ $dom->loadHTML('