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

Conversation

marinaglancy
Copy link
Contributor

@marinaglancy marinaglancy commented Oct 25, 2022

Elements such as "option", "select" and "textarea" do not have 'type' property and it causes a notice in PHP 8.1:

8192: strtolower(): Passing null to parameter #1 () of type string is deprecated in /var/www/html/vendor/oleg-andreyev/mink-phpwebdriver/src/WebDriver.php line 578

@andrewnicols
Copy link
Contributor

@oleg-andreyev, any chance we can land this. We're trying to get compatibility with PHP 8.1 ASAP and this is a blocker for us.

@oleg-andreyev
Copy link
Owner

@oleg-andreyev, any chance we can land this. We're trying to get compatibility with PHP 8.1 ASAP and this is a blocker for us.

One thing that bugs me, input has missing or unknown "type" it should fallback "text"

MDN:

If omitted (or an unknown value is specified), the input type text is used, creating a plaintext input field.

@@ -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') ?? '');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add fallback to "text" and please search for other places (line 650)

@oleg-andreyev
Copy link
Owner

also I've done some work on https://github.com/oleg-andreyev/MinkPhpWebDriver/releases/tag/v1.2.0

now PHP >= 7.4 and build is working.

@marinaglancy
Copy link
Contributor Author

marinaglancy commented Nov 7, 2022

FYI In minkphp/MinkSelenium2Driver it is changed to ?: '' in four different places but the other three are only engaged if type='input'
minkphp/MinkSelenium2Driver@96ba5d7

The value of the variable is never compared to 'text' so it will not make any difference to the logic. But I can do it if you want

option and select elements return null as their element type and it causes a notice in PHP 8.1:

8192: strtolower(): Passing null to parameter oleg-andreyev#1 () of type string is deprecated in /var/www/html/vendor/oleg-andreyev/mink-phpwebdriver/src/WebDriver.php line 578
@marinaglancy
Copy link
Contributor Author

hi @oleg-andreyev , thanks for reviewing it. Is there any chance to get it merged and tagged? TIA

@oleg-andreyev oleg-andreyev merged commit e265917 into oleg-andreyev:master Nov 21, 2022
@oleg-andreyev
Copy link
Owner

@stronk7
Copy link

stronk7 commented Nov 22, 2022

Hi @oleg-andreyev ,

any reason the new release is not showing @ packagist? https://packagist.org/packages/oleg-andreyev/mink-phpwebdriver

Was just trying to update our repos here to use it and composer cannot find it, so far.

Ciao :-)

Edited: Ah, maybe I need to patiently wait 24 hours or so? Sorry for the pressure, if that's the case, heh! I'm just used to see the new tags/releases happening almost immediately @ packagist.

@oleg-andreyev
Copy link
Owner

@stronk7 fixed.

It appears I made a typo in tag/release
image

tag is updated https://packagist.org/packages/oleg-andreyev/mink-phpwebdriver#v1.2.1

@stronk7
Copy link

stronk7 commented Nov 22, 2022

Aha, great! Heap thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants