Skip to content

Commit

Permalink
Do not call strtolower on null (PHP 8.1 warning) (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy authored Nov 21, 2022
1 parent c64d82e commit e265917
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public function getValue($xpath)
{
$element = $this->findElement($xpath);
$elementName = strtolower($element->getTagName());
$elementType = strtolower($element->getAttribute('type'));
$elementType = strtolower($element->getAttribute('type') ?: 'text');

// Getting the value of a checkbox returns its value if selected.
if ('input' === $elementName && 'checkbox' === $elementType) {
Expand Down Expand Up @@ -647,7 +647,7 @@ public function setValue($xpath, $value)
}

if ('input' === $elementName) {
$elementType = strtolower($element->getAttribute('type'));
$elementType = strtolower($element->getAttribute('type') ?: 'text');

if (in_array($elementType, array('submit', 'image', 'button', 'reset'))) {
throw new DriverException(sprintf('Impossible to set value an element with XPath "%s" as it is not a select, textarea or textbox', $xpath));
Expand Down Expand Up @@ -756,7 +756,7 @@ public function selectOption($xpath, $value, $multiple = false)
$element = $this->findElement($xpath);
$tagName = strtolower($element->getTagName());

if ('input' === $tagName && 'radio' === strtolower($element->getAttribute('type'))) {
if ('input' === $tagName && 'radio' === strtolower($element->getAttribute('type') ?: '')) {
$element = new WebDriverRadios($element);
$element->selectByValue($value);
return;
Expand Down Expand Up @@ -1146,7 +1146,7 @@ private function findElement($xpath)
*/
private function ensureInputType(WebDriverElement $element, $xpath, $type, $action)
{
if ('input' !== strtolower($element->getTagName()) || $type !== strtolower($element->getAttribute('type'))) {
if ('input' !== strtolower($element->getTagName()) || $type !== strtolower($element->getAttribute('type') ?: 'text')) {
$message = 'Impossible to %s the element with XPath "%s" as it is not a %s input';

throw new DriverException(sprintf($message, $action, $xpath, $type));
Expand Down

0 comments on commit e265917

Please sign in to comment.