Skip to content

Commit 2eafffb

Browse files
authored
Merge pull request #257 from cryptounifier/php-80-test-passing
Support PHP 8.0
2 parents bd40f19 + cc7d01e commit 2eafffb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+87
-67
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: PHP
22

3-
on: ["push", "pull_request"]
3+
on: ["push", "pull_request", "workflow_dispatch"]
44

55
jobs:
66
build_and_test:
77
name: Build and test web3.php with ${{ matrix.php-version }}
88
strategy:
99
matrix:
10-
php-version: ["7.3", "7.4"]
10+
php-version: ["7.3", "7.4", "8.0"]
1111

1212
runs-on: ubuntu-latest
1313

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
],
1212
"require": {
1313
"guzzlehttp/guzzle": "^6.3|^7.0",
14-
"PHP": "^7.1",
14+
"PHP": "^7.2|^8.0",
1515
"kornrunner/keccak": "~1.0",
16-
"phpseclib/phpseclib": "~2.0.11",
16+
"phpseclib/phpseclib": "~2.0.30",
1717
"ext-mbstring": "*"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "~6.0"
20+
"phpunit/phpunit": "~8.0|~9.0"
2121
},
2222
"autoload": {
2323
"psr-4": {

docker/php/Dockerfile-80

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM php:8.0-alpine
2+
3+
MAINTAINER Peter Lai <alk03073135@gmail.com>
4+
5+
COPY composer-setup.php composer-setup.php
6+
# COPY php.ini-production $PHP_INI_DIR/php.ini
7+
8+
RUN apk update && \
9+
apk add git
10+
11+
# Install gmp
12+
Run apk add gmp-dev && \
13+
docker-php-ext-install gmp
14+
15+
# Install nodejs
16+
# Run apk add --update nodejs nodejs-npm
17+
18+
# Install composer
19+
RUN php composer-setup.php && \
20+
php composer-setup.php --install-dir=/usr/bin --filename=composer && \
21+
php -r "unlink('composer-setup.php');"
22+
23+
WORKDIR /app

phpunit.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false">
10+
stopOnFailure="false">
1211

1312
<testsuite name="Web3.php unit test">
1413
<directory suffix="Test.php">./test/unit</directory>

src/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public static function toBn($number)
529529
$number = str_replace('-', '', $number, $count);
530530
$negative1 = new BigNumber(-1);
531531
}
532-
if (self::isZeroPrefixed($number) || preg_match('/[a-f]+/', $number) === 1) {
532+
if (self::isZeroPrefixed($number) || preg_match('/^[0-9a-f]+$/i', $number) === 1) {
533533
$number = self::stripZero($number);
534534
$bn = new BigNumber($number, 16);
535535
} elseif (empty($number)) {

test/TestCase.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ class TestCase extends BaseTestCase
3737

3838
/**
3939
* setUp
40-
*
41-
* @return void
4240
*/
43-
public function setUp()
41+
public function setUp(): void
4442
{
4543
$web3 = new Web3($this->testHost);
4644
$this->web3 = $web3;
@@ -55,8 +53,6 @@ public function setUp()
5553

5654
/**
5755
* tearDown
58-
*
59-
* @return void
6056
*/
61-
public function tearDown() {}
62-
}
57+
public function tearDown(): void {}
58+
}

test/unit/AddressFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AddressFormatterTest extends TestCase
1919
*
2020
* @return void
2121
*/
22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
parent::setUp();
2525
$this->formatter = new AddressFormatter;

test/unit/AddressTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class AddressTypeTest extends TestCase
4747
*
4848
* @return void
4949
*/
50-
public function setUp()
50+
public function setUp(): void
5151
{
5252
parent::setUp();
5353
$this->solidityType = new Address;

test/unit/AddressValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AddressValidatorTest extends TestCase
1919
*
2020
* @return void
2121
*/
22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
parent::setUp();
2525
$this->validator = new AddressValidator;

test/unit/BigNumberFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class BigNumberFormatterTest extends TestCase
2020
*
2121
* @return void
2222
*/
23-
public function setUp()
23+
public function setUp(): void
2424
{
2525
parent::setUp();
2626
$this->formatter = new BigNumberFormatter;

0 commit comments

Comments
 (0)