diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index 4bd4ff76ec..dda0c362f9 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -119,10 +119,10 @@ class ChoiceFormField extends FormField */ public function setValue($value) { - if ('checkbox' == $this->type && false === $value) { + if ('checkbox' === $this->type && false === $value) { // uncheck $this->value = null; - } elseif ('checkbox' == $this->type && true === $value) { + } elseif ('checkbox' === $this->type && true === $value) { // check $this->value = $this->options[0]['value']; } else { @@ -163,7 +163,7 @@ class ChoiceFormField extends FormField */ public function addChoice(\DOMNode $node) { - if (!$this->multiple && 'radio' != $this->type) { + if (!$this->multiple && 'radio' !== $this->type) { throw new \LogicException(sprintf('Unable to add a choice for "%s" as it is not multiple or is not a radio button.', $this->name)); } @@ -202,11 +202,11 @@ class ChoiceFormField extends FormField */ protected function initialize() { - if ('input' != $this->node->nodeName && 'select' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) { throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName)); } - if ('input' == $this->node->nodeName && 'checkbox' != strtolower($this->node->getAttribute('type')) && 'radio' != strtolower($this->node->getAttribute('type'))) { + 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'))); } @@ -271,7 +271,7 @@ class ChoiceFormField extends FormField } /** - * Checks whether given vale is in the existing options + * Checks whether given value is in the existing options * * @param string $optionValue * @param array $options diff --git a/src/Symfony/Component/DomCrawler/Field/FileFormField.php b/src/Symfony/Component/DomCrawler/Field/FileFormField.php index 160ddc6e0d..bbdf467994 100644 --- a/src/Symfony/Component/DomCrawler/Field/FileFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -99,11 +99,11 @@ class FileFormField extends FormField */ protected function initialize() { - if ('input' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName) { throw new \LogicException(sprintf('A FileFormField can only be created from an input tag (%s given).', $this->node->nodeName)); } - if ('file' != strtolower($this->node->getAttribute('type'))) { + 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'))); } diff --git a/src/Symfony/Component/DomCrawler/Field/InputFormField.php b/src/Symfony/Component/DomCrawler/Field/InputFormField.php index 00141d84c6..b9bd0a4829 100644 --- a/src/Symfony/Component/DomCrawler/Field/InputFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/InputFormField.php @@ -30,15 +30,15 @@ class InputFormField extends FormField */ protected function initialize() { - if ('input' != $this->node->nodeName && 'button' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) { throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); } - if ('checkbox' == strtolower($this->node->getAttribute('type'))) { + if ('checkbox' === strtolower($this->node->getAttribute('type'))) { throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); } - if ('file' == strtolower($this->node->getAttribute('type'))) { + if ('file' === strtolower($this->node->getAttribute('type'))) { throw new \LogicException('File inputs should be instances of FileFormField.'); } diff --git a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php index 242a9d3724..a14e70783b 100644 --- a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php @@ -27,7 +27,7 @@ class TextareaFormField extends FormField */ protected function initialize() { - if ('textarea' != $this->node->nodeName) { + if ('textarea' !== $this->node->nodeName) { throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName)); } diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index a19cc79da7..0f28d45d53 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -28,7 +28,7 @@ class Form extends Link implements \ArrayAccess private $button; /** - * @var Field\FormField[] + * @var FormFieldRegistry */ private $fields; @@ -352,7 +352,7 @@ class Form extends Link implements \ArrayAccess protected function setNode(\DOMNode $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')), array('submit', 'button', 'image')))) { if ($node->hasAttribute('form')) { // if the node has the HTML5-compliant 'form' attribute, use it $formId = $node->getAttribute('form'); @@ -369,8 +369,8 @@ class Form extends Link implements \ArrayAccess if (null === $node = $node->parentNode) { throw new \LogicException('The selected node does not have a form ancestor.'); } - } while ('form' != $node->nodeName); - } elseif ('form' != $node->nodeName) { + } while ('form' !== $node->nodeName); + } elseif ('form' !== $node->nodeName) { throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName)); } diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index f37e05025c..150f94dfc6 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -137,7 +137,7 @@ class FormFieldRegistry /** * Returns the list of field with their value. * - * @return array The list of fields as array((string) Fully qualified name => (mixed) value) + * @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value) */ public function all() { @@ -196,7 +196,7 @@ class FormFieldRegistry * * @param string $name The name of the field * - * @return array The list of segments + * @return string[] The list of segments * * @throws \InvalidArgumentException when the name is malformed */ diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php index d662f8937c..05d5e927a2 100644 --- a/src/Symfony/Component/DomCrawler/Link.php +++ b/src/Symfony/Component/DomCrawler/Link.php @@ -188,7 +188,7 @@ class Link */ protected function setNode(\DOMNode $node) { - if ('a' != $node->nodeName && 'area' != $node->nodeName) { + if ('a' !== $node->nodeName && 'area' !== $node->nodeName) { throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName)); } diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 1fbfbb983d..02e7fbba4b 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -793,7 +793,6 @@ class FormTest extends \PHPUnit_Framework_TestCase $dom = new \DOMDocument(); $dom->loadHTML(''.$form.''); - $nodes = $dom->getElementsByTagName('input'); $xPath = new \DOMXPath($dom); $nodes = $xPath->query('//input | //button'); @@ -856,5 +855,4 @@ class FormTest extends \PHPUnit_Framework_TestCase $form = new Form($nodes->item(0), 'http://example.com'); $this->assertEquals($form->getPhpValues(), array('example' => '')); } - }