Skip to content

Commit a7a2166

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Config] Handle nullable node name + fix inheritdocs [Security] added userChecker to SimpleAuthenticationProvider [Debug] fix test Fix typo in test method name Fixes #26563 (open_basedir restriction in effect) [Debug] Reset previous exception handler ealier to prevent infinite loop add hint in Github pull request template [Validator] Fix docblock of ClassMetadata#members [BrowserKit] Fix cookie path handling when $domain is null [DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore [BrowserKit] Improves CookieJar::get [BrowserKit] Fix Cookie's PHPDoc [DomCrawler] Change bad wording in ChoiceFormField::untick [DomCrawler] Fix the PHPDoc of ChoiceFormField::setValue [DomCrawler] Avoid a useless call to strtolower [FrameworkBundle] HttpCache is not longer abstract [DomCrawler] extract(): fix a bug when the attribute list is empty [Config] Backport string|null api for node names
2 parents 91d247d + fafe026 commit a7a2166

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Crawler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ public function extract($attributes)
601601
}
602602
}
603603

604-
$data[] = $count > 1 ? $elements : $elements[0];
604+
$data[] = 1 === $count ? $elements[0] : $elements;
605605
}
606606

607607
return $data;

Field/ChoiceFormField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ public function tick()
9797
}
9898

9999
/**
100-
* Ticks a checkbox.
100+
* Unticks a checkbox.
101101
*
102102
* @throws \LogicException When the type provided is not correct
103103
*/
104104
public function untick()
105105
{
106106
if ('checkbox' !== $this->type) {
107-
throw new \LogicException(sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->name, $this->type));
107+
throw new \LogicException(sprintf('You cannot untick "%s" as it is not a checkbox (%s).', $this->name, $this->type));
108108
}
109109

110110
$this->setValue(false);
@@ -113,7 +113,7 @@ public function untick()
113113
/**
114114
* Sets the value of the field.
115115
*
116-
* @param string $value The value of the field
116+
* @param string|array $value The value of the field
117117
*
118118
* @throws \InvalidArgumentException When value type provided is not correct
119119
*/

Field/InputFormField.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ protected function initialize()
3232
throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName));
3333
}
3434

35-
if ('checkbox' === strtolower($this->node->getAttribute('type'))) {
35+
$type = strtolower($this->node->getAttribute('type'));
36+
if ('checkbox' === $type) {
3637
throw new \LogicException('Checkboxes should be instances of ChoiceFormField.');
3738
}
3839

39-
if ('file' === strtolower($this->node->getAttribute('type'))) {
40+
if ('file' === $type) {
4041
throw new \LogicException('File inputs should be instances of FileFormField.');
4142
}
4243

Tests/CrawlerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ public function testExtract()
389389

390390
$this->assertEquals(array('One', 'Two', 'Three'), $crawler->extract('_text'), '->extract() returns an array of extracted data from the node list');
391391
$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');
392+
$this->assertEquals(array(array(), array(), array()), $crawler->extract(array()), '->extract() returns empty arrays if the attribute list is empty');
392393

393394
$this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty');
394395
}

0 commit comments

Comments
 (0)