From b6f5625e2adcf3ec3613ea4505d2521466d15ce0 Mon Sep 17 00:00:00 2001 From: Julien Mercier-Rojas Date: Tue, 6 Jul 2021 11:41:43 +0200 Subject: [PATCH 1/2] Upgrade to php8.0 --- .github/workflows/validate.yml | 34 +++++++++++++++++++++ README.md | 5 +++ composer.json | 5 +-- grumphp.yml | 3 ++ phpstan.neon | 4 +++ ruleset.xml | 15 +++++---- src/Domain/Entity/DomainEventAwareTrait.php | 2 +- src/Domain/Equality.php | 4 +-- src/Domain/Identity/Identity.php | 8 ++--- src/Domain/ValueObject/ValueObject.php | 8 ++--- 10 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/validate.yml create mode 100644 phpstan.neon diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..ae9268c --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,34 @@ +name: validate + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + global-qa-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: 8.0 + - name: Get composer cache directory + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-8.0-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-8.0 + - name: Install dependencies + run: composer install --no-interaction --prefer-dist --dev + - name: GrumPHP + run: ./vendor/bin/grumphp run + diff --git a/README.md b/README.md index 257e58b..5d639cf 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,11 @@ This contract includes some strong typings, object relation and psalm validation Require **`php >= 7.2.*`** and **`php >= 8.0`** +| Release name | Branch name | Php Version | +|--------------|-------------|-------------------------| +| 1.x | release/1.X | php >= 7.2 & php >= 8.0 | +| 2.x | master | php >= 8.0 | + ## Main contracts ### Core diff --git a/composer.json b/composer.json index 762d62e..71fde76 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^7.2 || ^8.0" + "php": "^8.0" }, "autoload": { "psr-4": { @@ -22,7 +22,8 @@ "vimeo/psalm": "^4.3", "squizlabs/php_codesniffer": "^3.5", "phpmd/phpmd": "^2.8", - "phpro/grumphp": "^0.19 || ^1.2.0" + "phpro/grumphp": "^0.19 || ^1.2.0", + "phpstan/phpstan": "^0.12.91" }, "suggest": { "vimeo/psalm": "Using psalm with this 'contract' will enable immutability and strong typing verification" diff --git a/grumphp.yml b/grumphp.yml index 92c1bf2..6835f25 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -13,3 +13,6 @@ grumphp: threads: 1 triggered_by: ['php'] show_info: true + phpstan: + configuration: phpstan.neon + use_grumphp_paths: true diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..c308dcf --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 8 + paths: + - src diff --git a/ruleset.xml b/ruleset.xml index e9e31e1..33cf3d1 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -7,18 +7,21 @@ xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd"> - My custom rule set that checks my code... + Jeckel-Lab/Contract PHPMD RuleSet - - - - - + + + + + id + + + diff --git a/src/Domain/Entity/DomainEventAwareTrait.php b/src/Domain/Entity/DomainEventAwareTrait.php index 619f628..dfddeaf 100644 --- a/src/Domain/Entity/DomainEventAwareTrait.php +++ b/src/Domain/Entity/DomainEventAwareTrait.php @@ -18,7 +18,7 @@ trait DomainEventAwareTrait { /** @var Event[] */ - private $events = []; + private array $events = []; /** * @return Event[] diff --git a/src/Domain/Equality.php b/src/Domain/Equality.php index 012e097..f2ed431 100644 --- a/src/Domain/Equality.php +++ b/src/Domain/Equality.php @@ -14,9 +14,9 @@ interface Equality { /** - * @param static $object + * @param mixed $object * @return bool * @psalm-mutation-free */ - public function equals($object): bool; + public function equals(mixed $object): bool; } diff --git a/src/Domain/Identity/Identity.php b/src/Domain/Identity/Identity.php index 76551e9..c3ccb82 100644 --- a/src/Domain/Identity/Identity.php +++ b/src/Domain/Identity/Identity.php @@ -9,6 +9,7 @@ use JeckelLab\Contract\Domain\Equality; use JeckelLab\Contract\Domain\Identity\Exception\InvalidIdException; +use Stringable; /** * Interface Identity @@ -16,7 +17,7 @@ * @psalm-immutable * @template T */ -interface Identity extends Equality +interface Identity extends Equality, Stringable { /** * IdAbstract constructor. @@ -24,9 +25,4 @@ interface Identity extends Equality * @throws InvalidIdException */ public function __construct($id); - - /** - * @return string - */ - public function __toString(): string; } diff --git a/src/Domain/ValueObject/ValueObject.php b/src/Domain/ValueObject/ValueObject.php index 7e8ca85..33e87db 100644 --- a/src/Domain/ValueObject/ValueObject.php +++ b/src/Domain/ValueObject/ValueObject.php @@ -7,14 +7,12 @@ namespace JeckelLab\Contract\Domain\ValueObject; +use Stringable; + /** * Interface ValueObject * @psalm-immutable */ -interface ValueObject +interface ValueObject extends Stringable { - /** - * @return string - */ - public function __toString(): string; } From 16de59be5b8ca6c102026addaf10a74b13670ba9 Mon Sep 17 00:00:00 2001 From: Julien Mercier-Rojas Date: Tue, 6 Jul 2021 11:44:22 +0200 Subject: [PATCH 2/2] Remove travis configuration --- .travis.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 937b297..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: php -php: - - '7.2' - - '7.3' - - '7.4' - - '8.0' - -before_script: - - travis_retry composer self-update - - travis_retry composer install --no-interaction --prefer-source --dev - -script: - - ./vendor/bin/phpmd src text ./ruleset.xml - - ./vendor/bin/phpcs - - ./vendor/bin/psalm