diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6d03527 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,98 @@ +name: CI + +on: [push] + +jobs: + old: + name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-16.04'] + php-versions: ['7.0'] + phpunit-versions: ['6.5.14'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl + ini-values: post_max_size=256M, max_execution_time=180 + tools: psalm, phpunit:${{ matrix.phpunit-versions }} + + - name: Install dependencies + run: composer self-update --1; composer install + + - name: PHPUnit tests + uses: php-actions/phpunit@v2 + with: + memory_limit: 256M + + moderate: + name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-latest'] + php-versions: ['7.1', '7.2', '7.3'] + phpunit-versions: ['latest'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl, sodium + ini-values: post_max_size=256M, max_execution_time=180 + tools: psalm, phpunit:${{ matrix.phpunit-versions }} + + - name: Install dependencies + run: composer install + + - name: Modernize dependencies + run: composer require --dev "phpunit/phpunit:>=4" + + - name: PHPUnit tests + uses: php-actions/phpunit@v2 + timeout-minutes: 30 + with: + memory_limit: 256M + + - name: Static Analysis + run: vendor/bin/psalm + + modern: + name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-latest'] + php-versions: ['7.4', '8.0'] + phpunit-versions: ['latest'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl, sodium + ini-values: post_max_size=256M, max_execution_time=180 + tools: psalm, phpunit:${{ matrix.phpunit-versions }} + + - name: Install dependencies + run: composer install + - name: PHPUnit tests + uses: php-actions/phpunit@v2 + timeout-minutes: 30 + with: + memory_limit: 256M + + - name: Static Analysis + run: vendor/bin/psalm diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a332c4f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: php -dist: trusty - -matrix: - fast_finish: true - include: - - php: "7.0" - - php: "7.1" - - php: "7.2" - - php: "7.3" - - php: "nightly" - - php: "master" - allow_failures: - - php: "nightly" - - php: "master" - -install: - - composer update - -script: - - vendor/bin/phpunit - - vendor/bin/psalm diff --git a/README.md b/README.md index 9b1f394..3cb8aaa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ionizer -[![Build Status](https://travis-ci.org/paragonie/ionizer.svg?branch=master)](https://travis-ci.org/paragonie/ionizer) +[![Build Status](https://github.com/paragonie/ionizer/actions/workflows/ci.yml/badge.svg)](https://github.com/ionizer/actions) [![Latest Stable Version](https://poser.pugx.org/paragonie/ionizer/v/stable)](https://packagist.org/packages/paragonie/ionizer) [![Latest Unstable Version](https://poser.pugx.org/paragonie/ionizer/v/unstable)](https://packagist.org/packages/paragonie/ionizer) [![License](https://poser.pugx.org/paragonie/ionizer/license)](https://packagist.org/packages/paragonie/ionizer) @@ -29,7 +29,7 @@ composer require paragonie/ionizer use ParagonIE\Ionizer\GeneralFilterContainer; use ParagonIE\Ionizer\Filter\{ StringFilter, - WhiteList + AllowList }; // Define properties to filter: @@ -41,7 +41,7 @@ $ic->addFilter( ->addFilter('passphrase', new StringFilter()) ->addFilter( 'domain', - new WhiteList('US-1', 'US-2', 'EU-1', 'EU-2') + new AllowList('US-1', 'US-2', 'EU-1', 'EU-2') ); // Invoke the filter container on the array to get the filtered result: diff --git a/composer.json b/composer.json index 5fd8bb7..48d773e 100644 --- a/composer.json +++ b/composer.json @@ -19,12 +19,12 @@ }, "license": "ISC", "require": { - "php": "^7", + "php": "^7|^8", "paragonie/constant_time_encoding": "^2.1" }, "require-dev": { - "phpunit/phpunit": "^6.5", - "vimeo/psalm": "^0|^1|^2" + "phpunit/phpunit": "^6.5|^7|^8|^9", + "vimeo/psalm": "^1|^2|^3|^4" }, "support": { "email": "security@paragonie.com", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2af728d..8808ccc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,16 +10,10 @@ processIsolation="false" stopOnError="false" stopOnFailure="false" - syntaxCheck="true" > ./tests - - - ./src - - \ No newline at end of file diff --git a/psalm.xml b/psalm.xml index fc48429..b07a876 100644 --- a/psalm.xml +++ b/psalm.xml @@ -6,9 +6,16 @@ > + + + + + + + diff --git a/src/Filter/WhiteList.php b/src/Filter/AllowList.php similarity index 94% rename from src/Filter/WhiteList.php rename to src/Filter/AllowList.php index d9e8d85..803ca5d 100644 --- a/src/Filter/WhiteList.php +++ b/src/Filter/AllowList.php @@ -6,10 +6,10 @@ use ParagonIE\Ionizer\InvalidDataException; /** - * Class WhiteList + * Class AllowList * @package ParagonIE\Ionizer\Filter */ -class WhiteList extends InputFilter +class AllowList extends InputFilter { /** * @var array @@ -17,8 +17,8 @@ class WhiteList extends InputFilter protected $allowedValues = []; /** - * WhiteList constructor. - * @param mixed ...$values + * AllowList constructor. + * @param scalar ...$values */ public function __construct(...$values) { @@ -26,7 +26,7 @@ public function __construct(...$values) } /** - * @param array values + * @param array $values * @return self */ protected function addToWhiteList(...$values) diff --git a/src/InputFilterContainer.php b/src/InputFilterContainer.php index cb3699b..332ae54 100644 --- a/src/InputFilterContainer.php +++ b/src/InputFilterContainer.php @@ -57,6 +57,8 @@ public function addFilter( * @return mixed * @throws \Error * @throws InvalidDataException + * + * @psalm-suppress UnusedVariable */ public function filterValue(string $key, $multiDimensional) { @@ -111,7 +113,7 @@ public function filterValue(string $key, $multiDimensional) */ public function getUnfilteredValue(string $key, array $multiDimensional = []) { - /** @var array $pieces */ + /** @var array $pieces */ $pieces = Util::chunk($key, (string) static::SEPARATOR); /** @var string|array $value */ diff --git a/tests/WhiteListTest.php b/tests/AllowListTest.php similarity index 86% rename from tests/WhiteListTest.php rename to tests/AllowListTest.php index eac11a9..a352dda 100644 --- a/tests/WhiteListTest.php +++ b/tests/AllowListTest.php @@ -1,18 +1,17 @@ addFilter( 'test1', - (new WhiteList( + (new AllowList( 'abc', 'def', 'ghi' diff --git a/tests/ArrayFilterTest.php b/tests/ArrayFilterTest.php index 568191d..2e95fad 100644 --- a/tests/ArrayFilterTest.php +++ b/tests/ArrayFilterTest.php @@ -23,9 +23,9 @@ class ArrayFilterTest extends TestCase { /** - * + * @before */ - public function setUp() + public function before() { if (!\class_exists('GenericFilterContainer')) { require_once __DIR__ . '/Errata/GenericFilterContainer.php';