Skip to content

Commit

Permalink
declare fork
Browse files Browse the repository at this point in the history
  • Loading branch information
kornrunner committed Feb 9, 2023
1 parent 5f62bc1 commit 39a0750
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 101 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service_name: travis-ci
coverage_clover: build/logs/clover.xml
json_path: coveralls-upload.json
47 changes: 0 additions & 47 deletions .github/workflows/php.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Static Analysis (informative)

on:
push:
branches:
- master

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
coverage: none

- run: composer install --no-progress --prefer-dist
- run: composer require phpstan/phpstan --no-progress --dev
- run: vendor/bin/phpstan analyse src/
continue-on-error: true # is only informative
86 changes: 86 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Tests

on: [push, pull_request]

jobs:

linux:
name: Test on Linux
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- run: php${{ matrix.php-version }} -v
- run: php${{ matrix.php-version }} -m
- run: composer -V
- run: composer install --no-progress
- run: php${{ matrix.php-version }} vendor/bin/phpunit

windows:
name: Test on Windows
defaults:
run:
shell: cmd
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']
arch: [x64]
ts: [nts]

steps:
- name: Setup PHP
id: setup-php
uses: cmb69/setup-php-sdk@v0.6
with:
version: ${{matrix.php-version}}
arch: ${{matrix.arch}}
ts: ${{matrix.ts}}
- uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.arch}}
toolset: ${{steps.setup-php.outputs.toolset}}

- name: Define Other Environment
shell: powershell
run: |
chcp 65001
echo "PHP_EXECUTABLE=${{steps.setup-php.outputs.prefix}}\php.exe" >> $env:GITHUB_ENV
- run: php -v
- run: echo extension=gmp>>C:\tools\php\php.ini
- run: php -m
- run: composer -V
- run: composer install --no-progress
- run: php vendor/bin/phpunit

code_coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
coverage: none

- run: composer install --no-progress
- run: mkdir -p build/logs
- run: phpdbg -qrr vendor/bin/phpunit
- run: wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
- env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: php php-coveralls.phar --verbose
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ composer.phar
/vendor/
.phpintel/
composer.lock
.phpunit.cache/
.phpunit.result.cache

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
Expand Down
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
# rlp

[![PHP](https://github.com/web3p/rlp/actions/workflows/php.yml/badge.svg)](https://github.com/web3p/rlp/actions/workflows/php.yml)
[![codecov](https://codecov.io/gh/web3p/rlp/branch/master/graph/badge.svg)](https://codecov.io/gh/web3p/rlp)
[![Licensed under the MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/web3p/rlp/blob/master/LICENSE)
# rlp [![Tests](https://github.com/kornrunner/rlp/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/kornrunner/rlp/actions/workflows/tests.yml) [![Coverage Status](https://coveralls.io/repos/github/kornrunner/rlp/badge.svg?branch=master)](https://coveralls.io/github/kornrunner/rlp?branch=master) [![Latest Stable Version](https://poser.pugx.org/kornrunner/rlp/v/stable)](https://packagist.org/packages/kornrunner/rlp)

Recursive Length Prefix Encoding in PHP.

# Install

Set minimum stability to dev
```
composer require web3p/rlp
composer require kornrunner/rlp
```

# Usage

RLP encode:

```php
use Web3p\RLP\RLP;
use kornrunner\RLP\RLP;

$rlp = new RLP;
// c483646f67
Expand All @@ -31,8 +27,8 @@ $encoded = $rlp->encode('dog');
RLP decode:

```php
use Web3p\RLP\RLP;
use Web3p\RLP\Types\Str;
use kornrunner\RLP\RLP;
use kornrunner\RLP\Types\Str;

$rlp = new RLP;
$encoded = $rlp->encode(['dog']);
Expand All @@ -52,7 +48,7 @@ echo Str::decodeHex($decoded[0]);

# API

### Web3p\RLP\RLP
### kornrunner\RLP\RLP

#### encode

Expand All @@ -69,10 +65,10 @@ Mixed inputs - array of string, integer or numeric string.
* Encode array of string.

```php
use Web3p\RLP\RLP;
use kornrunner\RLP\RLP;

$rlp = new RLP;
$encoded = $rlp->encode(['web3p', 'ethereum', 'solidity']);
$encoded = $rlp->encode(['kornrunner', 'ethereum', 'solidity']);
```

#### decode
Expand All @@ -90,14 +86,14 @@ String input - recursive length prefix encoded string.
* Decode recursive length prefix encoded string.

```php
use Web3p\RLP\RLP;
use Web3p\RLP\Types\Str;
use kornrunner\RLP\RLP;
use kornrunner\RLP\Types\Str;

$rlp = new RLP;
$encoded = $rlp->encode(['web3p', 'ethereum', 'solidity']);
$encoded = $rlp->encode(['kornrunner', 'ethereum', 'solidity']);
$decoded = $rlp->decode('0x' . $encoded);

// echo web3p
// echo kornrunner
echo hex2bin($decoded[0]);

// echo ethereum
Expand All @@ -113,4 +109,5 @@ echo Str::decodeHex($decoded[2]);
```

# License

MIT
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "web3p/rlp",
"name": "kornrunner/rlp",
"description": "Recursive Length Prefix Encoding in PHP.",
"type": "library",
"license": "MIT",
Expand All @@ -11,11 +11,11 @@
],
"minimum-stability": "dev",
"require-dev": {
"phpunit/phpunit": "~7|~8.0"
"phpunit/phpunit": "~7|~8.0|~9.0"
},
"autoload": {
"psr-4": {
"Web3p\\RLP\\": "src/"
"kornrunner\\RLP\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -24,7 +24,7 @@
}
},
"require": {
"PHP": "^7.1 | ^8.0",
"PHP": "^7.1 | ^8.0 | ^8.1 | ^8.2",
"ext-mbstring": "*"
}
}
21 changes: 0 additions & 21 deletions phpunit.xml

This file was deleted.

21 changes: 21 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Keccak Test Suite">
<directory>test</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
12 changes: 6 additions & 6 deletions src/RLP.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
* @license MIT
*/

namespace Web3p\RLP;
namespace kornrunner\RLP;

use InvalidArgumentException;
use RuntimeException;
use Web3p\RLP\Types\Str;
use Web3p\RLP\Types\Numeric;
use kornrunner\RLP\Types\Str;
use kornrunner\RLP\Types\Numeric;

/**
* It's a instance for ethereum recursive length encoding.
*
* RLP encode:
*
* ```php
* use Web3p\RLP\RLP;
* use kornrunner\RLP\RLP;
* $rlp = new RLP;
* // c483646f67
Expand All @@ -35,8 +35,8 @@
* RLP decode:
*
* ```php
* use Web3p\RLP\RLP;
* use Web3p\RLP\Types\Str;
* use kornrunner\RLP\RLP;
* use kornrunner\RLP\Types\Str;
*
* $rlp = new RLP;
* $encoded = $rlp->encode(['dog']);
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Numeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license MIT
*/

namespace Web3p\RLP\Types;
namespace kornrunner\RLP\Types;


/**
Expand Down
4 changes: 2 additions & 2 deletions src/Types/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license MIT
*/

namespace Web3p\RLP\Types;
namespace kornrunner\RLP\Types;

use InvalidArgumentException;

Expand Down Expand Up @@ -93,4 +93,4 @@ static function decodeHex(string $input)
}
return $output;
}
}
}
Loading

0 comments on commit 39a0750

Please sign in to comment.