Skip to content

Support PHP 8.0#257

Merged
sc0Vu merged 8 commits into
web3p:masterfrom
miguilimzero:php-80-test-passing
Mar 7, 2022
Merged

Support PHP 8.0#257
sc0Vu merged 8 commits into
web3p:masterfrom
miguilimzero:php-80-test-passing

Conversation

@miguilimzero
Copy link
Copy Markdown
Contributor

This pull request add support for PHP 8.0 and bumps minimum version for package to 7.2 (instead of 7.1).

  • Bumps PHPUnit to ~8.0|~9.0.
  • Update all tests to be compatible with the new PHPUnit version.
  • Fix preg_match expression to detect hexadecimal strings correctly (src/Utils.php).
  • Update the test to the expected behavior, that its thrown an exception instead of returning 0x0. (test/unit/OptionalQuantityFormatterTest.php).

The wrong preg_match with this test that broke the tests to PHP 8.0. The phpseclib returns empty when sending an invalid hexadecimal string using PHP 7 (making the old test pass), but for PHP 8 it throws an exception (since the correct behavior is to send only hexadecimal strings).

@miguilimzero miguilimzero mentioned this pull request Feb 26, 2022
1 task
Copy link
Copy Markdown
Member

@sc0Vu sc0Vu left a comment

Choose a reason for hiding this comment

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

LGTM, I'll merge once ci test passed.

@sc0Vu
Copy link
Copy Markdown
Member

sc0Vu commented Mar 7, 2022

Thanks, it works on php8.0.

@sc0Vu sc0Vu merged commit 2eafffb into web3p:master Mar 7, 2022
@miguilimzero
Copy link
Copy Markdown
Contributor Author

@sc0Vu The tests were supposed to be passing. But in the "Cache composer packages" step it is fetching a cache of an incorrect composer.lock file.

The cache key is not taking into account the version of PHP being run in the test. I will add a commit that fixes this.

Explanation:
For PHP 7.x the guzzlehttp/guzzle requires symfony/deprecation-contracts in version ^2.2.

For PHP 8.x the guzzlehttp/guzzle requires symfony/deprecation-contracts in version ^3.0.

The test was getting a cached version of composer.lock that was generated by PHP 8, that locked symfony/deprecation-contracts to version ^3.0, which consequently doesn't work in PHP 7.x.

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.

2 participants