Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not call strtolower on null (PHP 8.1 warning) #76

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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