Skip to content

Commit 7b2b7db

Browse files
committed
Merge pull request #95 from stof/cleanup
Minor code cleanup
2 parents 601d8d1 + d1a3a03 commit 7b2b7db

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Diff for: src/Behat/Mink/Driver/BrowserKitDriver.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public function getAttribute($xpath, $name)
415415
*/
416416
public function getValue($xpath)
417417
{
418-
if (in_array($this->getAttribute($xpath, 'type'), array('submit', 'image', 'button'))) {
418+
if (in_array($this->getAttribute($xpath, 'type'), array('submit', 'image', 'button'), true)) {
419419
return $this->getAttribute($xpath, 'value');
420420
}
421421

@@ -487,25 +487,25 @@ public function isSelected($xpath)
487487
$selectField = $this->getFormField('(' . $xpath . ')/ancestor-or-self::*[local-name()="select"]');
488488
$selectValue = $selectField->getValue();
489489

490-
return is_array($selectValue) ? in_array($optionValue, $selectValue) : $optionValue == $selectValue;
490+
return is_array($selectValue) ? in_array($optionValue, $selectValue, true) : $optionValue === $selectValue;
491491
}
492492

493493
/**
494494
* {@inheritdoc}
495495
*/
496496
public function click($xpath)
497497
{
498-
$node = $this->getFilteredCrawler($xpath);
499-
$crawlerNode = $this->getCrawlerNode($node);
500-
$tagName = $crawlerNode->nodeName;
498+
$crawler = $this->getFilteredCrawler($xpath);
499+
$node = $this->getCrawlerNode($crawler);
500+
$tagName = $node->nodeName;
501501

502502
if ('a' === $tagName) {
503-
$this->client->click($node->link());
503+
$this->client->click($crawler->link());
504504
$this->forms = array();
505-
} elseif ($this->canSubmitForm($crawlerNode)) {
506-
$this->submit($node->form());
507-
} elseif ($this->canResetForm($crawlerNode)) {
508-
$this->resetForm($crawlerNode);
505+
} elseif ($this->canSubmitForm($node)) {
506+
$this->submit($crawler->form());
507+
} elseif ($this->canResetForm($node)) {
508+
$this->resetForm($node);
509509
} else {
510510
$message = sprintf('%%s supports clicking on links and submit or reset buttons only. But "%s" provided', $tagName);
511511

@@ -810,11 +810,11 @@ private function canSubmitForm(\DOMElement $node)
810810
{
811811
$type = $node->hasAttribute('type') ? $node->getAttribute('type') : null;
812812

813-
if ('input' == $node->nodeName && in_array($type, array('submit', 'image'))) {
813+
if ('input' === $node->nodeName && in_array($type, array('submit', 'image'), true)) {
814814
return true;
815815
}
816816

817-
return 'button' == $node->nodeName && (null === $type || 'submit' == $type);
817+
return 'button' === $node->nodeName && (null === $type || 'submit' === $type);
818818
}
819819

820820
/**
@@ -828,7 +828,7 @@ private function canResetForm(\DOMElement $node)
828828
{
829829
$type = $node->hasAttribute('type') ? $node->getAttribute('type') : null;
830830

831-
return in_array($node->nodeName, array('input', 'button')) && 'reset' == $type;
831+
return in_array($node->nodeName, array('input', 'button'), true) && 'reset' === $type;
832832
}
833833

834834
/**
@@ -881,10 +881,10 @@ private function mergeForms(Form $to, Form $from)
881881
$nodeReflection->setAccessible(true);
882882
$valueReflection->setAccessible(true);
883883

884-
if (!($field instanceof InputFormField && in_array(
885-
$nodeReflection->getValue($field)->getAttribute('type'),
886-
array('submit', 'button', 'image')
887-
))) {
884+
$isIgnoredField = $field instanceof InputFormField &&
885+
in_array($nodeReflection->getValue($field)->getAttribute('type'), array('submit', 'button', 'image'), true);
886+
887+
if (!$isIgnoredField) {
888888
$valueReflection->setValue($to[$name], $valueReflection->getValue($field));
889889
}
890890
}

0 commit comments

Comments
 (0)