From 7660524d22597c6476ed5f5671f75fd4bae2586a Mon Sep 17 00:00:00 2001 From: Mark Walet Date: Thu, 30 Dec 2021 14:18:48 +0100 Subject: [PATCH] PHP 8.1 support (#31) * Add PHP 8.1 support * Add PHP 8.0 support * Remove PHP 7.2 support * Remove PHP 7.3 support --- .github/workflows/coverage.yml | 8 ++++---- .github/workflows/tests.yml | 27 ++++++++++++--------------- .styleci.yml | 4 ++++ CHANGELOG.md | 9 +++++++++ composer.json | 10 ++++------ phpunit.xml | 26 ++++++++++++-------------- src/Change.php | 12 ++++-------- src/ChangelogFormatterFactory.php | 8 ++------ src/Concerns/CanSortReleases.php | 6 +++++- src/Feature.php | 6 ++---- src/Release.php | 12 ++++-------- 11 files changed, 62 insertions(+), 66 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 30a449d..0750209 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -3,7 +3,7 @@ name: coverage on: [push, pull_request] jobs: - tests: + coverage: runs-on: ubuntu-latest name: Coverage @@ -16,13 +16,13 @@ jobs: uses: actions/cache@v1 with: path: ~/.composer/cache/files - key: dependencies-php-7.4-illuminate-8.*-composer-${{ hashFiles('composer.json') }} + key: dependencies-php-8.1-illuminate-8.*-composer-${{ hashFiles('composer.json') }} - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd + php-version: 8.1 + extensions: dom, libxml, mbstring, zip, pcntl coverage: xdebug - name: Install dependencies diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2ed8287..efefb5c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,30 +13,30 @@ jobs: strategy: fail-fast: true matrix: - php: [ 7.2, 7.3, 7.4 ] - illuminate: [ 6.*, 7.*, 8.* ] + php: [ 7.4, 8.0, 8.1 ] + illuminate: [6.*, 7.*, ~8.74] stability: [ prefer-lowest, prefer-stable ] include: - illuminate: 6.* testbench: 4.* - illuminate: 7.* testbench: 5.* - - illuminate: 8.* + - illuminate: ~8.74 testbench: 6.* exclude: - - php: 7.4 + - php: 8.1 + illuminate: 7.* + - php: 8.1 illuminate: 6.* - - php: 7.2 - illuminate: 8.* name: P${{ matrix.php }} - I${{ matrix.illuminate }} - ${{ matrix.stability }} steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Cache dependencies - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ~/.composer/cache/files key: dependencies-php-${{ matrix.php }}-illuminate-${{ matrix.illuminate }}-composer-${{ hashFiles('composer.json') }} @@ -45,17 +45,14 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd + extensions: dom, libxml, mbstring, zip, pcntl coverage: none - name: Install dependencies run: | - composer require "illuminate/console:${{ matrix.illuminate }}" --no-interaction --no-update - composer require "illuminate/contracts:${{ matrix.illuminate }}" --no-interaction --no-update - composer require "illuminate/support:${{ matrix.illuminate }}" --no-interaction --no-update - composer require "illuminate/filesystem:${{ matrix.illuminate }}" --no-interaction --no-update - composer require "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-suggest + composer require "laravel/framework:${{ matrix.illuminate }}" --no-interaction --no-update + composer require "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --dev + composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests run: vendor/bin/phpunit --verbose diff --git a/.styleci.yml b/.styleci.yml index 0285f17..5308528 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1 +1,5 @@ preset: laravel + +disabled: + - laravel_phpdoc_alignment + - laravel_phpdoc_separation \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd9db4..66e430a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Release Notes + ## [Unreleased](https://github.com/markwalet/laravel-changelog/compare/v1.4.1...master) +## Added +- Added PHP 8.0 support +- Added PHP 8.1 support + +## Removed +- Removed PHP 7.2 support +- Removed PHP 7.3 support + ### Fixed - Fixed recursive folder creation ([#26](https://github.com/markwalet/laravel-changelog/issues/26)) diff --git a/composer.json b/composer.json index 32c1a96..e92f113 100644 --- a/composer.json +++ b/composer.json @@ -10,17 +10,15 @@ } ], "require": { - "php": ">=7.1.3", - "illuminate/console": "6.*|7.*|8.*", - "illuminate/contracts": "6.*|7.*|8.*", - "illuminate/support": "6.*|7.*|8.*", - "illuminate/filesystem": "6.*|7.*|8.*", + "php": "~7.4|8.*", + "laravel/framework": "6.*|7.*|~8.74", "markwalet/laravel-git-state": "~1.0", "ext-simplexml": "*", "ext-dom": "*" }, "require-dev": { - "phpunit/phpunit": "~7.0|~8.0", + "phpunit/phpunit": "~9.3", + "mockery/mockery": "~1.4", "orchestra/testbench": "4.*|5.*|6.*" }, "autoload": { diff --git a/phpunit.xml b/phpunit.xml index dd99e80..0ab969b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,20 @@ - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + ./src + + + ./src/Exceptions/* + + - ./tests/ + ./tests/ - - - ./src - - ./src/Exceptions/* - - - diff --git a/src/Change.php b/src/Change.php index e53f089..aaf1d14 100644 --- a/src/Change.php +++ b/src/Change.php @@ -4,15 +4,11 @@ class Change { - /** - * @var string - */ - private $type; + /** @var string */ + private string $type; - /** - * @var string - */ - private $message; + /** @var string */ + private string $message; /** * Change constructor. diff --git a/src/ChangelogFormatterFactory.php b/src/ChangelogFormatterFactory.php index 6230a6e..5f94e8a 100644 --- a/src/ChangelogFormatterFactory.php +++ b/src/ChangelogFormatterFactory.php @@ -10,12 +10,8 @@ class ChangelogFormatterFactory { - /** - * The application instance. - * - * @var Application - */ - protected $app; + /** @var Application */ + protected Application $app; /** * ChangelogFormatterFactory constructor. diff --git a/src/Concerns/CanSortReleases.php b/src/Concerns/CanSortReleases.php index a48f365..db6b9a6 100644 --- a/src/Concerns/CanSortReleases.php +++ b/src/Concerns/CanSortReleases.php @@ -23,7 +23,11 @@ public function sortVersions(array $versions): array return 1; } - return version_compare($first, $second, '<='); + if (strtolower($first[0]) === 'v' && strtolower($second[0]) === 'v') { + return version_compare($second, $first); + } + + return strcmp($second, $first); }); } diff --git a/src/Feature.php b/src/Feature.php index f6bb342..a29dcf9 100644 --- a/src/Feature.php +++ b/src/Feature.php @@ -6,10 +6,8 @@ class Feature { - /** - * @var Change[]|array - */ - private $changes; + /** @var Change[]|array */ + private array $changes; /** * Feature constructor. diff --git a/src/Release.php b/src/Release.php index f83576e..86c3944 100644 --- a/src/Release.php +++ b/src/Release.php @@ -4,15 +4,11 @@ class Release { - /** - * @var Change[]|array - */ - private $changes; + /** @var Change[]|array */ + private array $changes; - /** - * @var string - */ - private $version; + /** @var string */ + private string $version; /** * Change constructor.