diff --git a/.gitattributes b/.gitattributes index 798103b..ba9bf4c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ /.docker export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.travis.yml export-ignore +/.phpstan.neon export-ignore /docker-compose.yml export-ignore /docs export-ignore /phpunit.xml export-ignore diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index b3d7d92..a9c324d 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -7,48 +7,30 @@ on: jobs: tests: - name: Run with PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }} + name: Run PHPStan with PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: operating-system: ['ubuntu-latest'] - php-versions: ['7.4', '8.0', '8.1'] + php: ['8.2'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 2 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - - name: Setup PHP, with composer and extensions + - name: Setup PHP with composer and extensions uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: - php-version: ${{ matrix.php-versions }} - tools: phpunit - extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite + php-version: ${{ matrix.php }} coverage: xdebug - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - # Use composer.json for key, if composer.lock is not committed. - # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + tools: none - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + uses: "ramsey/composer-install@v2" - name: Run PHPStan - run: vendor/bin/phpstan.phar analyze src --level 8 - - - run: echo "🍏 This job's status is ${{ job.status }}." + run: composer run phpstan diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c073eb3..ed8c22b 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -7,48 +7,37 @@ on: jobs: tests: - name: Tests (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) + name: Tests (PHP ${{ matrix.php }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: operating-system: ['ubuntu-latest'] - php-versions: ['7.4', '8.0', '8.1'] + php: ['7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 2 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - - name: Setup PHP, with composer and extensions + - name: Setup PHP with composer and extensions uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: - php-version: ${{ matrix.php-versions }} - tools: phpunit - extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite + php-version: ${{ matrix.php }} coverage: xdebug + tools: none - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: "Install Composer dependencies" + if: ${{ matrix.php < '8.3' }} + uses: "ramsey/composer-install@v2" - - name: Cache composer dependencies - uses: actions/cache@v2 + - name: "Install Composer dependencies (PHP 8.3)" + if: ${{ matrix.php >= '8.3' }} + uses: "ramsey/composer-install@v2" with: - path: ${{ steps.composer-cache.outputs.dir }} - # Use composer.json for key, if composer.lock is not committed. - # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + composer-options: --ignore-platform-reqs - name: Run tests - run: vendor/bin/phpunit --coverage-text - - - run: echo "🍏 This job's status is ${{ job.status }}." + run: composer run phpunit -- --coverage-text diff --git a/.phpstan.neon b/.phpstan.neon new file mode 100644 index 0000000..cdc94e3 --- /dev/null +++ b/.phpstan.neon @@ -0,0 +1,29 @@ +parameters: + level: 8 + + paths: + - src/ + + scanDirectories: + - vendor + + ignoreErrors: + - + message: "#^Class Art4\\\\JsonApiClient\\\\Helper\\\\AccessKey extends generic class SplStack but does not specify its types\\: TValue$#" + count: 1 + path: src/Helper/AccessKey.php + + - + message: "#^Property Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:\\$data is never read, only written\\.$#" + count: 1 + path: src/V1/ResourceNull.php + + - + message: "#^Property Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:\\$manager is never read, only written\\.$#" + count: 1 + path: src/V1/ResourceNull.php + + - + message: "#^Property Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:\\$parent is never read, only written\\.$#" + count: 1 + path: src/V1/ResourceNull.php diff --git a/CHANGELOG.md b/CHANGELOG.md index a3fbab3..fae9c7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased](https://github.com/Art4/json-api-client/compare/1.1.0...v1.x) +### Added + +- Add support for PHP 8.2 + ## [1.1.0 - 2021-10-05](https://github.com/Art4/json-api-client/compare/1.0.0...1.1.0) ### Added - Added type hints for parameters and return types in internal and final classes - New tests for improving backward compatibility in interfaces -- Support for PHP 8.1 is added in CI tests +- Add support for PHP 8.1 ### Changed @@ -21,7 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Deprecated -- `\Art4\JsonApiClient\Accessable::has()` will add `bool` as a native return type declaration in v2.0, do the same in your implementation now to avoid errors. +- `\Art4\JsonApiClient\Accessable::has()` will add `bool` as a native return type declaration in v2.0, do the same in your implementation now to avoid errors. - `\Art4\JsonApiClient\Accessable::getKeys()` will add `array` as a native return type declaration in v2.0, do the same in your implementation now to avoid errors. - `\Art4\JsonApiClient\Exception\Exception` will extend `\Throwable` in v2.0, do the same in your implementation now to avoid errors. - `\Art4\JsonApiClient\Factory::make()` methods first parameter signature will be `string` in v2.0. diff --git a/composer.json b/composer.json index cbf9232..ae83a95 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,11 @@ } ], "require": { - "php": "^7.4 || ^8.0" + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", - "phpstan/phpstan": "^0.12.99", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9" }, "autoload": { @@ -30,10 +30,11 @@ "Art4\\JsonApiClient\\Tests\\": "tests" } }, + "scripts": { + "phpstan": "phpstan analyze --memory-limit 512M --configuration .phpstan.neon", + "phpunit": "phpunit" + }, "config": { - "//platform": { - "php": "7.4" - }, "sort-packages": true } } diff --git a/src/V1/Factory.php b/src/V1/Factory.php index 311e394..1aa780d 100644 --- a/src/V1/Factory.php +++ b/src/V1/Factory.php @@ -54,7 +54,7 @@ final class Factory implements FactoryInterface ]; /** - * @param array $overload specs to be overloaded with custom classes + * @param array $overload specs to be overloaded with custom classes */ public function __construct(array $overload = []) { diff --git a/tests/Fixtures/TestCase.php b/tests/Fixtures/TestCase.php index 6075d6a..e549ab1 100644 --- a/tests/Fixtures/TestCase.php +++ b/tests/Fixtures/TestCase.php @@ -19,6 +19,7 @@ namespace Art4\JsonApiClient\Tests\Fixtures; +#[\AllowDynamicProperties] class TestCase extends \PHPUnit\Framework\TestCase { /**