From d63498ddff3c7ac1a1a1cb468b26a4f4a37493de Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Mon, 10 Nov 2025 15:07:53 +0000 Subject: [PATCH 01/23] Remove 5, add 8 --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4afc57a..808da77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,16 @@ before_script: - composer install php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - 7 - 7.1 - 7.2 - 7.3 + - 7.4 + - 8.0 + - 8.1 + - 8.2 + - 8.3 + - 8.4 - hhvm script: bin/phpunit From 824a268b84b4a1c2ea511370b58390e7c87e335b Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Mon, 10 Nov 2025 15:22:49 +0000 Subject: [PATCH 02/23] Testing actions. --- .github/workflows/php-ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/php-ci.yml diff --git a/.github/workflows/php-ci.yml b/.github/workflows/php-ci.yml new file mode 100644 index 0000000..aa7e6c5 --- /dev/null +++ b/.github/workflows/php-ci.yml @@ -0,0 +1,31 @@ +name: PHP CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v4 + with: + php-version: ${{ matrix.php-version }} + extensions: gmp # Add any other extensions you need + coverage: none + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist + + - name: Run PHPUnit + run: bin/phpunit From 3b8052947ff5f5bf83f4e0a6ff8ebaaf111be8f9 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Mon, 10 Nov 2025 15:26:22 +0000 Subject: [PATCH 03/23] Rename --- .github/workflows/{php-ci.yml => php.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{php-ci.yml => php.yml} (100%) diff --git a/.github/workflows/php-ci.yml b/.github/workflows/php.yml similarity index 100% rename from .github/workflows/php-ci.yml rename to .github/workflows/php.yml From 7ab31000e58d62db07362a99cb7275fdcc173c3e Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 09:42:52 +0000 Subject: [PATCH 04/23] Removed benchmarking. --- benchmarks/Base16Event.php | 24 ----------------------- benchmarks/Base58BCMathEvent.php | 33 -------------------------------- benchmarks/Base58GMPEvent.php | 33 -------------------------------- benchmarks/Base64Event.php | 24 ----------------------- composer.json | 6 ++---- 5 files changed, 2 insertions(+), 118 deletions(-) delete mode 100644 benchmarks/Base16Event.php delete mode 100644 benchmarks/Base58BCMathEvent.php delete mode 100644 benchmarks/Base58GMPEvent.php delete mode 100644 benchmarks/Base64Event.php diff --git a/benchmarks/Base16Event.php b/benchmarks/Base16Event.php deleted file mode 100644 index f3ec003..0000000 --- a/benchmarks/Base16Event.php +++ /dev/null @@ -1,24 +0,0 @@ -base58 = new Base58(null, new BCMathService()); - } - - /** - * @iterations 10000 - */ - public function encodeBase58() - { - $this->base58->encode('Hello World'); - } - - /** - * @iterations 10000 - */ - public function decodeBase58() - { - $this->base58->decode('JxF12TrwUP45BMd'); - } -} diff --git a/benchmarks/Base58GMPEvent.php b/benchmarks/Base58GMPEvent.php deleted file mode 100644 index d8a4d20..0000000 --- a/benchmarks/Base58GMPEvent.php +++ /dev/null @@ -1,33 +0,0 @@ -base58 = new Base58(null, new GMPService()); - } - - /** - * @iterations 10000 - */ - public function encodeBase58() - { - $this->base58->encode('Hello World'); - } - - /** - * @iterations 10000 - */ - public function decodeBase58() - { - $this->base58->decode('JxF12TrwUP45BMd'); - } -} diff --git a/benchmarks/Base64Event.php b/benchmarks/Base64Event.php deleted file mode 100644 index a558968..0000000 --- a/benchmarks/Base64Event.php +++ /dev/null @@ -1,24 +0,0 @@ - Date: Tue, 11 Nov 2025 09:44:15 +0000 Subject: [PATCH 05/23] Upgraded PHPUnit to v12 --- composer.json | 2 +- phpunit.xml | 44 ++++++----------- tests/Base58Test.php | 112 ++++++++++++++++--------------------------- 3 files changed, 55 insertions(+), 103 deletions(-) diff --git a/composer.json b/composer.json index 09f57b4..cff3ffa 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "stephenhill/base58", "description": "Base58 Encoding and Decoding Library for PHP", "require-dev": { - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "12.*" }, "license": "MIT", "authors": [ diff --git a/phpunit.xml b/phpunit.xml index 0636241..19f39ce 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,31 +1,15 @@ - - - - ./tests/ - - - - - - src - - vendor - - - - + + + + tests + + + \ No newline at end of file diff --git a/tests/Base58Test.php b/tests/Base58Test.php index bf135be..20cb2ea 100644 --- a/tests/Base58Test.php +++ b/tests/Base58Test.php @@ -3,58 +3,49 @@ use StephenHill\Base58; use StephenHill\BCMathService; use StephenHill\GMPService; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; -class Base58Tests extends PHPUnit_Framework_TestCase +class Base58Test extends TestCase { - /** - * @dataProvider encodingsProvider - */ - public function testEncode($string, $encoded, $instance) + #[DataProvider('encodingsProvider')] + public function testEncode(string $string, string $encoded, Base58 $instance): void { - $string = (string) $string; - $encoded = (string) $encoded; - $this->assertSame($encoded, $instance->encode($string)); } - /** - * @dataProvider encodingsProvider - */ - public function testDecode($string, $encoded, $instance) + #[DataProvider('encodingsProvider')] + public function testDecode(string $string, string $encoded, Base58 $instance): void { - $string = (string) $string; - $encoded = (string) $encoded; - $this->assertSame($string, $instance->decode($encoded)); } - public function encodingsProvider() + public static function encodingsProvider(): array { - $instances = array( + $instances = [ new Base58(null, new BCMathService()), - new Base58(null, new GMPService()) - ); - - $tests = array( - array('', ''), - array('1', 'r'), - array('a', '2g'), - array('bbb', 'a3gV'), - array('ccc', 'aPEr'), - array('hello!', 'tzCkV5Di'), - array('Hello World', 'JxF12TrwUP45BMd'), - array('this is a test', 'jo91waLQA1NNeBmZKUF'), - array('the quick brown fox', 'NK2qR8Vz63NeeAJp9XRifbwahu'), - array('THE QUICK BROWN FOX', 'GRvKwF9B69ssT67JgRWxPQTZ2X'), - array('simply a long string', '2cFupjhnEsSn59qHXstmK2ffpLv2'), - array("\x00\x61", '12g'), - array("\x00", '1'), - array("\x00\x00", '11'), - array('0248ac9d3652ccd8350412b83cb08509e7e4bd41', '3PtvAWwSMPe2DohNuCFYy76JhMV3rhxiSxQMbPBTtiPvYvneWu95XaY') - ); + new Base58(null, new GMPService()), + ]; - $return = array(); + $tests = [ + ['', ''], + ['1', 'r'], + ['a', '2g'], + ['bbb', 'a3gV'], + ['ccc', 'aPEr'], + ['hello!', 'tzCkV5Di'], + ['Hello World', 'JxF12TrwUP45BMd'], + ['this is a test', 'jo91waLQA1NNeBmZKUF'], + ['the quick brown fox', 'NK2qR8Vz63NeeAJp9XRifbwahu'], + ['THE QUICK BROWN FOX', 'GRvKwF9B69ssT67JgRWxPQTZ2X'], + ['simply a long string', '2cFupjhnEsSn59qHXstmK2ffpLv2'], + ["\x00\x61", '12g'], + ["\x00", '1'], + ["\x00\x00", '11'], + ['0248ac9d3652ccd8350412b83cb08509e7e4bd41', '3PtvAWwSMPe2DohNuCFYy76JhMV3rhxiSxQMbPBTtiPvYvneWu95XaY'], + ]; + $return = []; foreach ($instances as $instance) { foreach ($tests as $test) { $test[] = $instance; @@ -65,50 +56,27 @@ public function encodingsProvider() return $return; } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Argument $alphabet must be a string. - */ - public function testConstructorTypeException() + public function testConstructorTypeException(): void { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Argument $alphabet must be a string.'); + new Base58(intval(123)); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Argument $alphabet must contain 58 characters. - */ - public function testConstructorLengthException() + public function testConstructorLengthException(): void { - new Base58(''); - } + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Argument $alphabet must contain 58 characters.'); - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Argument $string must be a string. - */ - public function testEncodeTypeException() - { - $base58 = new Base58(); - $base58->encode(intval(123)); + new Base58(''); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Argument $base58 must be a string. - */ - public function testDecodeTypeException() + public function testInvalidBase58(): void { - $base58 = new Base58(); - $base58->decode(intval(123)); - } + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Argument $base58 contains invalid characters.'); - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Argument $base58 contains invalid characters. - */ - public function testInvalidBase58() - { $base58 = new Base58(); $base58->decode("This isn't valid base58"); } From 1453c6feabca2c12268f986b8910a180672c53ff Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 09:46:06 +0000 Subject: [PATCH 06/23] Add allowed branch during development. --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index aa7e6c5..876c207 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,7 +2,7 @@ name: PHP CI on: push: - branches: [main] + branches: [main, goodsprings] pull_request: branches: [main] From 510762890f8233f27df103a31bc033f2dd293f46 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 09:48:08 +0000 Subject: [PATCH 07/23] Fixing errors --- .github/workflows/php.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 876c207..6e95683 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,21 +11,19 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4] - + php-version: [8.3, 8.4] + steps: - name: Checkout repository uses: actions/checkout@v3 - name: Set up PHP - uses: shivammathur/setup-php@v4 + uses: shivammathur/setup-php@v3 with: php-version: ${{ matrix.php-version }} - extensions: gmp # Add any other extensions you need - coverage: none - name: Install Composer dependencies run: composer install --no-progress --prefer-dist - name: Run PHPUnit - run: bin/phpunit + run: bin/phpunit \ No newline at end of file From 39ff2f06adab01b9f998705548542f1e981c68a1 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 09:49:59 +0000 Subject: [PATCH 08/23] Drop to v2 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 6e95683..320db3b 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v3 - name: Set up PHP - uses: shivammathur/setup-php@v3 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} From be10fa5f05b02be707e28118068f14c8861df735 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 09:55:15 +0000 Subject: [PATCH 09/23] Preparing for 8.3+ --- src/BCMathService.php | 6 +++--- src/Base58.php | 13 ++++--------- src/GMPService.php | 6 +++--- src/ServiceInterface.php | 4 ++-- tests/Base58Test.php | 8 -------- 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/BCMathService.php b/src/BCMathService.php index 329e1ce..54566be 100644 --- a/src/BCMathService.php +++ b/src/BCMathService.php @@ -24,7 +24,7 @@ class BCMathService implements ServiceInterface * @param string $alphabet optional * @since v1.1.0 */ - public function __construct($alphabet = null) + public function __construct(?string $alphabet = null) { // Handle null alphabet if (is_null($alphabet) === true) { @@ -51,7 +51,7 @@ public function __construct($alphabet = null) * @since Release v1.1.0 * @return string The Base58 encoded string. */ - public function encode($string) + public function encode(string $string) : string { // Type validation if (is_string($string) === false) { @@ -113,7 +113,7 @@ public function encode($string) * @since Release v1.1.0 * @return string Returns the decoded string. */ - public function decode($base58) + public function decode(string $base58) : string { // Type Validation if (is_string($base58) === false) { diff --git a/src/Base58.php b/src/Base58.php index 75a2e0d..516e3c4 100644 --- a/src/Base58.php +++ b/src/Base58.php @@ -29,19 +29,14 @@ class Base58 * @since v1.1.0 Added the optional $service argument. */ public function __construct( - $alphabet = null, - ServiceInterface $service = null + ?string $alphabet = null, + ?ServiceInterface $service = null ) { // Handle null alphabet if (is_null($alphabet) === true) { $alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; } - // Type validation - if (is_string($alphabet) === false) { - throw new InvalidArgumentException('Argument $alphabet must be a string.'); - } - // The alphabet must contain 58 characters if (strlen($alphabet) !== 58) { throw new InvalidArgumentException('Argument $alphabet must contain 58 characters.'); @@ -71,7 +66,7 @@ public function __construct( * @since v1.0.0 * @return string The Base58 encoded string. */ - public function encode($string) + public function encode(string $string) : string { return $this->service->encode($string); } @@ -83,7 +78,7 @@ public function encode($string) * @since v1.0.0 * @return string Returns the decoded string. */ - public function decode($base58) + public function decode(string $base58) : string { return $this->service->decode($base58); } diff --git a/src/GMPService.php b/src/GMPService.php index 0dde305..9e82356 100644 --- a/src/GMPService.php +++ b/src/GMPService.php @@ -24,7 +24,7 @@ class GMPService implements ServiceInterface * @param string $alphabet optional * @since v1.1.0 */ - public function __construct($alphabet = null) + public function __construct(?string $alphabet = null) { // Handle null alphabet if (is_null($alphabet) === true) { @@ -51,7 +51,7 @@ public function __construct($alphabet = null) * @since Release v1.1.0 * @return string The Base58 encoded string. */ - public function encode($string) + public function encode(string $string) : string { // Type validation if (is_string($string) === false) { @@ -105,7 +105,7 @@ public function encode($string) * @since Release v1.1.0 * @return string Returns the decoded string. */ - public function decode($base58) + public function decode(string $base58) : string { // Type Validation if (is_string($base58) === false) { diff --git a/src/ServiceInterface.php b/src/ServiceInterface.php index 0fe3745..71ccf84 100644 --- a/src/ServiceInterface.php +++ b/src/ServiceInterface.php @@ -11,7 +11,7 @@ interface ServiceInterface * @since v1.1.0 * @return string The Base58 encoded string. */ - public function encode($string); + public function encode(string $string) : string; /** * Decode base58 into a PHP string. @@ -20,5 +20,5 @@ public function encode($string); * @since v1.1.0 * @return string Returns the decoded string. */ - public function decode($base58); + public function decode(string $base58) : string; } diff --git a/tests/Base58Test.php b/tests/Base58Test.php index 20cb2ea..7280ec3 100644 --- a/tests/Base58Test.php +++ b/tests/Base58Test.php @@ -56,14 +56,6 @@ public static function encodingsProvider(): array return $return; } - public function testConstructorTypeException(): void - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Argument $alphabet must be a string.'); - - new Base58(intval(123)); - } - public function testConstructorLengthException(): void { $this->expectException(\InvalidArgumentException::class); From b151c756a7acd1426b2817df906eaaf29cda6c65 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 10:00:49 +0000 Subject: [PATCH 10/23] =?UTF-8?q?Adding=20support=20for=20Ubuntu=2022.04?= =?UTF-8?q?=E2=80=AFLTS=20(PHP=20v8.1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/php.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 320db3b..3442e1f 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [8.3, 8.4] + php-version: [8.1, 8.2, 8.3, 8.4] steps: - name: Checkout repository diff --git a/composer.json b/composer.json index cff3ffa..0fb505f 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "stephenhill/base58", "description": "Base58 Encoding and Decoding Library for PHP", "require-dev": { - "phpunit/phpunit": "12.*" + "phpunit/phpunit": "11.*" }, "license": "MIT", "authors": [ From 37330c841797b28c611f31f5783491b2decfc080 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 10:02:46 +0000 Subject: [PATCH 11/23] It's version 10 I need to support PHP v8.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0fb505f..dd66e72 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "stephenhill/base58", "description": "Base58 Encoding and Decoding Library for PHP", "require-dev": { - "phpunit/phpunit": "11.*" + "phpunit/phpunit": "10.*" }, "license": "MIT", "authors": [ From 55dd2c80d25ca2a1993e89372c732a042fde0408 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 10:06:16 +0000 Subject: [PATCH 12/23] Preparing for v2 --- readme.md | 45 +++------------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/readme.md b/readme.md index 9723a91..11f79e6 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,8 @@ Each major version of this library will be supported for 5 years after it's initial release. Support will be provided for security and bug fixes. -Version 1 will therefore be supported until the 11th September 2019. +- Version 2 will be supported until the 1st Janurary 2031. +- Version 1 support expired on the 11th September 2019. ## Background @@ -26,7 +27,7 @@ So I decided to create a library with the following goals: This library has the following requirements: -- PHP => 5.3 +- PHP => 8.1 - BC Math Extension ## Installation @@ -87,46 +88,6 @@ This library is tested using PHPUnit. $ bin/phpunit ``` -## Benchmarking - -You can benchmark this library using [Athletic](https://github.com/polyfractal/athletic). -The benchmarking suite also benchmarks PHP's built-in Base64 and Base16 encoding for comparison. - -```bash -$ bin/athletic -p benchmarks -``` - -Example output. - -``` -StephenHill\Benchmarks\Base16Event - Method Name Iterations Average Time Ops/second - ------------ ------------ -------------- ------------- - encodeBase16: [10,000 ] [0.0000010839939] [922,514.40637] - decodeBase16: [10,000 ] [0.0000011516809] [868,296.03561] - - -StephenHill\Benchmarks\Base58BCMathEvent - Method Name Iterations Average Time Ops/second - ------------ ------------ -------------- ------------- - encodeBase58: [10,000 ] [0.0001500048161] [6,666.45263] - decodeBase58: [10,000 ] [0.0001741812706] [5,741.14540] - - -StephenHill\Benchmarks\Base58GMPEvent - Method Name Iterations Average Time Ops/second - ------------ ------------ -------------- ------------- - encodeBase58: [10,000 ] [0.0001168665648] [8,556.76730] - decodeBase58: [10,000 ] [0.0001385705233] [7,216.54199] - - -StephenHill\Benchmarks\Base64Event - Method Name Iterations Average Time Ops/second - ------------ ------------ -------------- ------------- - encodeBase64: [10,000 ] [0.0000009050369] [1,104,927.29189] - decodeBase64: [10,000 ] [0.0000009787321] [1,021,730.04312] -``` - ## Contributing I welcome everyone to contribute to this library. Please see the Contributing document for details. From 598634b43ce043a0e93e563535330a7fef4084bd Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 10:08:27 +0000 Subject: [PATCH 13/23] Removed broken badges --- readme.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/readme.md b/readme.md index 11f79e6..1b4d0b5 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,7 @@ # Base58 Encoding and Decoding Library for PHP -[![Build Status](https://travis-ci.org/stephen-hill/base58php.png)](https://travis-ci.org/stephen-hill/base58php) [![Packagist Release](http://img.shields.io/packagist/v/stephenhill/base58.svg)](https://packagist.org/packages/stephenhill/base58) [![MIT License](http://img.shields.io/packagist/l/stephenhill/base58.svg)](https://github.com/stephen-hill/base58php/blob/master/license) -[![Flattr this](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=stephen-hill&url=https%3A%2F%2Fgithub.com%2Fstephen-hill%2Fbase58php) ## Long Term Support From a3d936e40ee8a2769bb5b7b6ae9fbc897f0a58f1 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 10:09:28 +0000 Subject: [PATCH 14/23] Corrected instructions --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 1b4d0b5..fd983b0 100644 --- a/readme.md +++ b/readme.md @@ -35,7 +35,7 @@ I recommend you install this library via Composer. ```json { "require": { - "stephenhill/base58": "~1.0" + "stephenhill/base58": "~2.0" } } ``` From 7f0c1ecf2c01fccb47ce9b8164d30a34a403a8c0 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 10:13:19 +0000 Subject: [PATCH 15/23] Added credits --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index fd983b0..4d379c3 100644 --- a/readme.md +++ b/readme.md @@ -102,3 +102,5 @@ Some of the unit tests were based on the following: - https://code.google.com/p/bitcoinj/source/browse/core/src/test/java/com/google/bitcoin/core/Base58Test.java - https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/fixtures/base58.json + +In no particular order, I would like to thank the following for pushing me to release a PHP 8 compatible version: @git-marijus, @VandalorumRex, @bacheson, @kalifg From 89858901f41024f1dbcb2342573755affe8cb9cb Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 12:46:40 +0000 Subject: [PATCH 16/23] Remove is_string checks. No longer required. --- src/BCMathService.php | 15 --------------- src/GMPService.php | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/src/BCMathService.php b/src/BCMathService.php index 54566be..d424335 100644 --- a/src/BCMathService.php +++ b/src/BCMathService.php @@ -31,11 +31,6 @@ public function __construct(?string $alphabet = null) $alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; } - // Type validation - if (is_string($alphabet) === false) { - throw new InvalidArgumentException('Argument $alphabet must be a string.'); - } - // The alphabet must contain 58 characters if (strlen($alphabet) !== 58) { throw new InvalidArgumentException('Argument $alphabet must contain 58 characters.'); @@ -53,11 +48,6 @@ public function __construct(?string $alphabet = null) */ public function encode(string $string) : string { - // Type validation - if (is_string($string) === false) { - throw new InvalidArgumentException('Argument $string must be a string.'); - } - // If the string is empty, then the encoded string is obviously empty if (strlen($string) === 0) { return ''; @@ -115,11 +105,6 @@ public function encode(string $string) : string */ public function decode(string $base58) : string { - // Type Validation - if (is_string($base58) === false) { - throw new InvalidArgumentException('Argument $base58 must be a string.'); - } - // If the string is empty, then the decoded string is obviously empty if (strlen($base58) === 0) { return ''; diff --git a/src/GMPService.php b/src/GMPService.php index 9e82356..60a8d19 100644 --- a/src/GMPService.php +++ b/src/GMPService.php @@ -31,11 +31,6 @@ public function __construct(?string $alphabet = null) $alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; } - // Type validation - if (is_string($alphabet) === false) { - throw new InvalidArgumentException('Argument $alphabet must be a string.'); - } - // The alphabet must contain 58 characters if (strlen($alphabet) !== 58) { throw new InvalidArgumentException('Argument $alphabet must contain 58 characters.'); @@ -53,11 +48,6 @@ public function __construct(?string $alphabet = null) */ public function encode(string $string) : string { - // Type validation - if (is_string($string) === false) { - throw new InvalidArgumentException('Argument $string must be a string.'); - } - // If the string is empty, then the encoded string is obviously empty if (strlen($string) === 0) { return ''; @@ -107,11 +97,6 @@ public function encode(string $string) : string */ public function decode(string $base58) : string { - // Type Validation - if (is_string($base58) === false) { - throw new InvalidArgumentException('Argument $base58 must be a string.'); - } - // If the string is empty, then the decoded string is obviously empty if (strlen($base58) === 0) { return ''; From d6c6222a36ef6aa34850d58cfe07a3a09af0db97 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 12:53:44 +0000 Subject: [PATCH 17/23] Added code coverage --- .github/workflows/php.yml | 2 +- .gitignore | 1 + phpunit.xml | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 3442e1f..65c2422 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -26,4 +26,4 @@ jobs: run: composer install --no-progress --prefer-dist - name: Run PHPUnit - run: bin/phpunit \ No newline at end of file + run: bin/phpunit --no-coverage \ No newline at end of file diff --git a/.gitignore b/.gitignore index b2df07b..955fe35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor/ +/coverage/ /bin/ composer.lock diff --git a/phpunit.xml b/phpunit.xml index 19f39ce..08c2af7 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,9 +7,22 @@ displayDetailsOnAllIssues="true" failOnAllIssues="true" colors="true"> + tests + + + + src + + + + + + + + \ No newline at end of file From 457687b8d63903a5ddda94e8ef1262402061aac8 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 12:54:06 +0000 Subject: [PATCH 18/23] Removed defunct travis-ci. --- .travis.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 808da77..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php - -before_script: - - composer install - -php: - - 7 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 - - 8.1 - - 8.2 - - 8.3 - - 8.4 - - hhvm - -script: bin/phpunit From 3f334ceb8df71fe41cfb4d67155e4fe814923843 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 13:00:00 +0000 Subject: [PATCH 19/23] Improve composer file. --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index dd66e72..bab06e8 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,13 @@ { "name": "stephenhill/base58", "description": "Base58 Encoding and Decoding Library for PHP", + "require": { + "php": ">=8.1" + }, + "suggest": { + "ext-bcmath": "Required for BC Math support", + "ext-gmp": "Required for GMP support" + }, "require-dev": { "phpunit/phpunit": "10.*" }, From 9ee6ad237792f97a7a916bb97553bcf2692c9c50 Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 13:01:14 +0000 Subject: [PATCH 20/23] Added PHP 8.5 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 65c2422..d54be5e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [8.1, 8.2, 8.3, 8.4] + php-version: [8.1, 8.2, 8.3, 8.4, 8.5] steps: - name: Checkout repository From 89c11b563f7d6c686675f018a703de82b2b74b7c Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 13:03:22 +0000 Subject: [PATCH 21/23] Rename action. --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index d54be5e..a8588b1 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,4 +1,4 @@ -name: PHP CI +name: Base58 on: push: From 962a8d4b2b7f9dbc9b336a933309eb625634ec8d Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 13:04:52 +0000 Subject: [PATCH 22/23] Added action status badge. --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 4d379c3..cac4402 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,7 @@ [![Packagist Release](http://img.shields.io/packagist/v/stephenhill/base58.svg)](https://packagist.org/packages/stephenhill/base58) [![MIT License](http://img.shields.io/packagist/l/stephenhill/base58.svg)](https://github.com/stephen-hill/base58php/blob/master/license) +[![Action Status](https://github.com/stephen-hill/base58php/actions/workflows/php.yml/badge.svg)](https://github.com/stephen-hill/base58php/actions/workflows/php.yml) ## Long Term Support From ec00437bb9bc8166c7160f6761e87d8c5bb83c4f Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Tue, 11 Nov 2025 13:06:53 +0000 Subject: [PATCH 23/23] Note in readme that you can use GMP --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index cac4402..94b1846 100644 --- a/readme.md +++ b/readme.md @@ -27,7 +27,7 @@ So I decided to create a library with the following goals: This library has the following requirements: - PHP => 8.1 -- BC Math Extension +- GMP or BC Math Extension ## Installation