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

PHP 8 Support #828

Merged
merged 2 commits into from Nov 16, 2020
Merged

PHP 8 Support #828

merged 2 commits into from Nov 16, 2020

Conversation

driesvints
Copy link
Contributor

@driesvints driesvints commented Oct 30, 2020

Working on providing full PHP 8 support for php-webdriver. We'll need this for Laravel Dusk.

Currently using this PR to run the builds.

phpunit.xml.dist Outdated Show resolved Hide resolved
@driesvints
Copy link
Contributor Author

Currently waiting on sminnee/phpunit-mock-objects#6 to be merged and tagged before continuing here.

@sminnee
Copy link

sminnee commented Nov 1, 2020

You may wish to run your php 8 build with --ignore-platform-reqs. Without dropping PHP 5.6 and 7.0 support, any upgrading to at least phpunit 7 || 8 || 9, you'll likely run into issues.

If you're looking to patch my phpunit forks, please test the new packages against phpunit/phpunit first, and confirm that the tests pass - this is what I got blocked on trying to upgrade some of the dependencies.

@driesvints
Copy link
Contributor Author

@sminnee I've added "sminnee/phpunit" which indeed works thanks.

I'm a bit stuck atm... For some bizar reason when I only run the build for PHP 8 it succeeds (see this build and my second to last commit) but when I re-enable all the other builds it fails and claims it cannot install PHP CS Fixer even though I've added --ignore-platform-req php (see this build and my last commit). Apparently for some reason it seems that parallel builds in Travis influence each other somehow? In any case the PHP 8 nightly build should properly install because of the --ignore-platform-req php flag.

@driesvints
Copy link
Contributor Author

Also the PHP Code Style Github Action fails atm but I suspect that has nothing to do with the current PR (since it's run on PHP 7.4). I believe when you trigger it on main it'll also fail. Probably something got changed on phpstan's side.

@driesvints
Copy link
Contributor Author

I think I'm a little closer at figuring it out. As you can see below there's two nightly builds, one that fails and one that passes. I'm sure that the one that passes has the --ignore-platform-req php and the one that fails doesn't.

There's two questions:

  • Why are there two builds?
  • How do we get the --ignore-platform-req php to apply on the one that fails?

Screenshot 2020-11-02 at 17 37 30

.travis.yml Outdated Show resolved Hide resolved
@driesvints
Copy link
Contributor Author

Okay this one is ready for review now. Please note that I had to disable code coverage for PHP 8 for now because of an issue with PHPUnit and xdebug. See https://travis-ci.com/github/php-webdriver/php-webdriver/builds/197177332

This was fixed in a newer version of PHPUnit later on but I guess sminnee/phpunit doesn't has that one yet (cc @sminnee). I'm however a bit too tired to figure out that specific one and don't believe it should be a blocker for this PR.

In general I want to suggest for this project to drop support for older PHP versions so you can remove the PHPUnit dependency overrides. As most of these PHP versions are EoL I don't think it makes sense in maintaining them anymore. However, I understand that this is a personal choice of the maintainer of course.

Anyway, would appreciate a review, merge and tag so we can finally patch Laravel Dusk. Let me know if anything else needs to be done. Thanks all! 🙂

@driesvints driesvints marked this pull request as ready for review November 2, 2020 16:55
.travis.yml Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@driesvints
Copy link
Contributor Author

For some bizar reason the PHP 5.6 til 7.2 builds are now failing after my last commit... https://github.com/php-webdriver/php-webdriver/pull/828/checks?check_run_id=1343276205

@williamdes

This comment has been minimized.

@williamdes
Copy link
Collaborator

Hi @OndraM !
This PR started with a PHP 8 support and I finished it with a phpunit 5.7->9 support.
Because only the CI runs phpunit tests on PHP 5 I did set a script block to reverse some method signatures like I do on Debian (#828 (comment)).

I upgraded things and did fix everything that was red.
Some fixes/hacks are needed and can not be removed. But we can merge this and remove those things when we drop php 5 support.

@driesvints
Copy link
Contributor Author

@williamdes fantastic work 🙌

.php_cs.dist Show resolved Hide resolved
@williamdes
Copy link
Collaborator

Hi @GrahamCampbell

Just delete this line.

I can not do that because phpcs will report me to use some phpunit asserts that are not right.
See: 26c6de1
Deprecated: sebastianbergmann/phpunit#3369

.travis.yml Outdated Show resolved Hide resolved
@OndraM
Copy link
Collaborator

OndraM commented Nov 16, 2020

LGTM, thanks everyone!

The final question is how to rebase & fixup those 25 commits to keep the changes contained. Any preferences @driesvints @williamdes?
I suggest keeping just two commits, one which adds Travis builds, second one with all the changes from @williamdes :).

@williamdes
Copy link
Collaborator

williamdes commented Nov 16, 2020

@OndraM all good to me. I'll leave it up to @williamdes to decide on that since he did the bulk of the work here

Done, I did a reset soft and created 2 commits from the changes.
And added Dries Vints <dries@vints.io> as a co author on 06ff635

WTF: phpstan broken ?? https://github.com/php-webdriver/php-webdriver/pull/828/checks?check_run_id=1406013380#step:6:37

@driesvints
Copy link
Contributor Author

@williamdes can you try to retrigger the static analysis github action? It might just be a hiccup.

@williamdes
Copy link
Collaborator

Hi @ondrejmirtes
This phpstan error seems to be recent, is it an internal bug ?
https://github.com/php-webdriver/php-webdriver/runs/1406254306?check_suite_focus=true#step:6:28

@ondrejmirtes
Copy link
Contributor

@williamdes phpstan/phpstan#3956

@OndraM
Copy link
Collaborator

OndraM commented Nov 16, 2020

So maybe we can temporarily add constrain to composer.json to avoid latest PHPStan version(s)?

@ondrejmirtes
Copy link
Contributor

It'd be easier to:

  1. Avoid using non-UTF-8 PHP code in your project. It's 2020 :)
  2. The root issue is reported here (Handling non-UTF-8 strings clue/reactphp-ndjson#21). I don't know what to do about it right now. I don't know anything about the encoding of the analysed codebse so I don't know what to convert it from to UTF-8.

@OndraM
Copy link
Collaborator

OndraM commented Nov 16, 2020

@ondrejmirtes AFAIK this whole codebase is UTF-8. Is there a way how to find out which file causes the trouble?

I also tried this and find no non-UTF-8 files... https://gist.github.com/rmetzler/2947828

@williamdes
Copy link
Collaborator

williamdes commented Nov 16, 2020

I tried on my local workstation:

composer analyse
# fails
vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi
# fails
vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi
# fails
vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi --debug -vvv
# SUCCESS
vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi
# SUCCESS, WTF
rm -rf /tmp/phpstan
vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi
# fails

@ondrejmirtes --debug -vvv was added in the latest release, and before this release the analysis was successing.
Is it by coincidence this new error ?

@ondrejmirtes
Copy link
Contributor

The reason why it fails are these two commits:

phpstan/phpstan-src@95101a0

So it's not a new bug, it just surfaces an error condition that was failing silently before, possibly causing error reports to be missed.

@driesvints
Copy link
Contributor Author

@OndraM @williamdes is there any way we can work around this for now so we can merge this PR? Afaik this has nothing to do with this PR and it'll probably also fail on the main branch?

@OndraM
Copy link
Collaborator

OndraM commented Nov 16, 2020

From what I found, the cause is in WebDriveKeys. However we need to declare WebDriver key codes there... Doing this is nothing invalid from PHP point of view.

@ondrejmirtes So this error is caused by clue/reactphp-ndjson#21 , which is used by PHPStan, and which causes non-unicode characters to break JSON parsing used internally in PHPStan?

@OndraM
Copy link
Collaborator

OndraM commented Nov 16, 2020

@OndraM @williamdes is there any way we can work around this for now so we can merge this PR? Afaik this has nothing to do with this PR and it'll probably also fail on the main branch?

Yes, will probably do this. I just wanted to know what is the root cause for this and whether it is related to this PR.

@OndraM
Copy link
Collaborator

OndraM commented Nov 16, 2020

Workaround for the PHPStan issue here: #830

phpstan.neon Outdated
@@ -7,8 +7,6 @@ parameters:
ignoreErrors:
# To be fixed:
- '#Call to an undefined method Facebook\\WebDriver\\WebDriver::getTouch\(\)#'
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::getCoordinates\(\)#'
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::equals\(\)#'
Copy link
Collaborator

Choose a reason for hiding this comment

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

And now those needs to be put back 🙃 .

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you !
Happy you did point that out because I was searching why the error was occurring ^^

@driesvints
Copy link
Contributor Author

@ondrejmirtes @OndraM @williamdes thanks all! 🙂

@OndraM OndraM merged commit 6583dd2 into php-webdriver:main Nov 16, 2020
@OndraM
Copy link
Collaborator

OndraM commented Nov 16, 2020

PHP 8 support is now merged to main branch. Nice job everyone!

I will get this released as 1.8.4 quite soon.

This will have to be 1.9.0, as we already have other new feature in main.

@driesvints driesvints deleted the php8 branch November 16, 2020 16:20
@viezel
Copy link

viezel commented Nov 16, 2020

@ondrejmirtes @OndraM @williamdes awesome work. Looking forward to that 1.9.0 tag!
PHP8 here we go! 🚀

@driesvints
Copy link
Contributor Author

driesvints commented Nov 19, 2020

Hey @OndraM. Is there anything blocking the 1.9.0 tag? We'd really like to patch Dusk soon since it's currently blocking a lot of other projects from shipping PHP 8 support. Let me know if there's anything I can do to help out.

@OndraM
Copy link
Collaborator

OndraM commented Nov 19, 2020

@driesvints Sorry for the delay, I'd like to finish one other PR (#556) to get it merged into the 1.9.0 release. Should be finished once CI builds are done, and the release will be just afterwards :)

@driesvints
Copy link
Contributor Author

@OndraM no sorry needed. Awesome, looking forward to it :)

@OndraM
Copy link
Collaborator

OndraM commented Nov 19, 2020

📢 1.9.0 with PHP 8 support was just released.

@driesvints
Copy link
Contributor Author

@OndraM amazing!

sed -i 's/function runBare(): void/function runBare()/g' tests/functional/WebDriverTestCase.php;

# Return back to original dir
cd - > /dev/null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@OndraM @williamdes would it be okay with you two if I used this script for algolia/algoliasearch-client-php#644 as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes you can copy it :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

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.

None yet

8 participants