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

Support PHP 8.0; Drop 5.6, 7.0 & 7.1 #96

Merged
merged 2 commits into from
Mar 9, 2021
Merged

Support PHP 8.0; Drop 5.6, 7.0 & 7.1 #96

merged 2 commits into from
Mar 9, 2021

Conversation

jdavid
Copy link
Contributor

@jdavid jdavid commented Mar 5, 2021

Add support for PHP 8.0

@jdavid jdavid force-pushed the php8 branch 2 times, most recently from 42eb3ce to 6886b36 Compare March 5, 2021 16:50
Fixes #88

To support PHP 8.0 we have to update PHPUnit: only versions 8 and 9
support PHP 8.0, see https://phpunit.de/supported-versions.html

Then we have to update the test suite as required by breaking changes in
PHPUnit 8.  And this makes the test suite to stop working with older
versions of PHP: 5.6, 7.0 and 7.1, so we drop support for these.

Anyway these old versions of PHP reached EOL a while ago, see
https://en.wikipedia.org/wiki/PHP#Release_history
@jdavid jdavid marked this pull request as ready for review March 5, 2021 18:24
@jdavid jdavid changed the title Support PHP 8.0 (draft) Support PHP 8.0; Drop 5.6, 7.0 & 7.1 Mar 5, 2021
@QuintinWillison
Copy link
Contributor

Added @kavalerov as a reviewer as he may have opinions on dropped runtime support.

@kavalerov
Copy link

I haven't tested the SDK itself, but change in supported versions looks right to me, yes.

@owenpearson
Copy link
Member

For visibility - the change in supported versions here is in line with current PHP support

@jdavid
Copy link
Contributor Author

jdavid commented Mar 9, 2021

To get the test suite working with PHP 8.0 we have to upgrade PHPUnit. Only versions 8 and 9 support PHP 8.0, see https://phpunit.de/supported-versions.html

Note that there are no changes to the src folder. So this version could work with PHP 5.6, 7.0 and 7.1, but the tests won't pass.

Breaking changes in PHPUnit require to update the test suite. So the tests either pass with PHP 8.0 or with the older versions, but not both.

PHP 5.6 error, see https://github.com/ably/ably-php/runs/2041202213?check_suite_focus=true

PHP Parse error:  syntax error, unexpected ':', expecting ';' or '{' in ...

PHP 7.0 error, see https://github.com/ably/ably-php/runs/2041202230?check_suite_focus=true

PHP Fatal error:  Uncaught TypeError: Return value of DebugTestListener::startTestSuite() must be an instance of void, none returned in ...

PHP 7.1 error, see https://github.com/ably/ably-php/runs/2041202249?check_suite_focus=true

PHP Fatal error:  Declaration of DebugTestListener::endTest(PHPUnit\Framework\Test $test, $time): void must be compatible with PHPUnit\Framework\TestListener::endTest(PHPUnit\Framework\Test $test, float $time): void in ...

While the commit is large, there are only a few changes that repeat through the test suite:

  • Update phpunit.xml to use whitelist instead of blacklist
  • Update DebugTestListener.php to use TestListenerDefaultImplementation instead of PHPUnit_Framework_BaseTestListener
  • Replace \PHPUnit_Framework_TestCase by \PHPUnit\_Framework\_TestCase
  • Add : void to TestCase functions. This is the change that produces the syntax error in PHP 5.6
  • Replace assertContains by assertStringContainsString
  • Replace assertInternalType by assertIsString
  • Use $this->expectException(..) instead of @expectedException ...
  • Use assertions instead of fail(...)
  • Fix testIdempotentLibraryGenerated, which worked before only by accident

Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

Copy link
Contributor

@QuintinWillison QuintinWillison left a comment

Choose a reason for hiding this comment

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

Thanks, @jdavid - I've asked @owenpearson to take a look at the phpunit.xml file as there are alternative element names we can use which avoid non-inclusive terminology. He will follow on with a commit to address this.

Clearly this got overlooked when we renamed the default branch, despite being one of the terms we identified at the time.

@owenpearson owenpearson merged commit dc73009 into main Mar 9, 2021
@owenpearson owenpearson deleted the php8 branch March 9, 2021 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants