diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index 1a42dfc..acc29c6 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -8,104 +8,76 @@ on: - "develop" pull_request: null -jobs: - byte_level: - name: "0️⃣ Byte-level" - runs-on: "ubuntu-latest" - steps: - - name: "Checkout code" - uses: "actions/checkout@v3" - - - name: "Check file permissions" - run: | - test "$(find . -type f -not -path './.git/*' -executable)" = "" +env: + PHP_EXTENSIONS: "intl" - - name: "Find non-printable ASCII characters" - run: | - ! LC_ALL=C.UTF-8 find . -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^ -~]" | grep -v '// @ignore-non-ascii$' - - syntax_errors: - name: "1️⃣ Syntax errors" +jobs: + file_consistency: + name: "1️⃣ File consistency" runs-on: "ubuntu-latest" steps: - name: "Set up PHP" uses: "shivammathur/setup-php@v2" with: php-version: "8.0" - extensions: "intl" + extensions: "${{ env.PHP_EXTENSIONS }}" ini-values: "post_max_size=256M" - name: "Checkout code" uses: "actions/checkout@v3" + - name: Install Effigy + run: | + composer global config --no-plugins allow-plugins.phpstan/extension-installer true + composer global require decodelabs/effigy + - name: "Install dependencies" uses: "ramsey/composer-install@v2" with: dependency-versions: "highest" + - name: "Check file permissions" + run: | + composer global exec effigy check-executable-permissions + + - name: "Check exported files" + run: | + composer global exec effigy check-git-exports + + - name: "Find non-printable ASCII characters" + run: | + composer global exec effigy check-non-ascii + - name: "Check source code for syntax errors" - run: "composer exec -- parallel-lint src/ ecs.php" - # @TODO Check template files for syntax errors + run: | + composer global exec effigy lint - unit_tests: - name: "2️⃣ Unit and functional tests" + static_analysis: + name: "3️⃣ Static Analysis" needs: - - "byte_level" - - "syntax_errors" + - "file_consistency" + runs-on: "ubuntu-latest" strategy: matrix: php-version: - "8.0" - "8.1" - dependencies: - - "lowest" - - "highest" - runs-on: "ubuntu-latest" + - "8.2" steps: - name: "Set up PHP" uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php-version }}" - extensions: "intl" + extensions: "${{ env.PHP_EXTENSIONS }}" ini-values: "post_max_size=256M" - name: "Checkout code" uses: "actions/checkout@v3" - - name: "Install dependencies" - uses: "ramsey/composer-install@v2" - with: - dependency-versions: "${{ matrix.dependencies }}" - - - name: "Execute unit tests" -# run: "composer run-script --no-interaction phpunit -- --verbose" - run: "echo 'Tom has the key.'" - # @TODO Functional tests - -# - name: Send coverage to Coveralls -# if: "matrix.php-version == '8.1' && matrix.dependencies == 'highest'" -# env: -# COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" -# run: | -# wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.2/php-coveralls.phar" -# php ./php-coveralls.phar -v - - static_analysis: - name: "3️⃣ Static Analysis" - needs: - - "byte_level" - - "syntax_errors" - runs-on: "ubuntu-latest" - steps: - - name: "Set up PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.0" - extensions: "intl" - ini-values: "post_max_size=256M" - - - name: "Checkout code" - uses: "actions/checkout@v3" + - name: Install Effigy + run: | + composer global config --no-plugins allow-plugins.phpstan/extension-installer true + composer global require decodelabs/effigy - name: "Validate Composer configuration" run: "composer validate --strict" @@ -116,21 +88,21 @@ jobs: dependency-versions: "highest" - name: "Execute static analysis" - run: "composer run-script --no-interaction analyze" - # @TODO Magic Number Detector, Copy-Paste Detector + run: | + composer global exec effigy analyze -- --headless + coding_standards: name: "4️⃣ Coding Standards" needs: - - "byte_level" - - "syntax_errors" + - "file_consistency" runs-on: "ubuntu-latest" steps: - name: "Set up PHP" uses: "shivammathur/setup-php@v2" with: php-version: "8.0" - extensions: "intl" + extensions: "${{ env.PHP_EXTENSIONS }}" ini-values: "post_max_size=256M" - name: "Checkout code" @@ -142,28 +114,17 @@ jobs: - name: "Check adherence to EditorConfig" uses: "greut/eclint-action@v0" + - name: Install Effigy + run: | + composer global config --no-plugins allow-plugins.phpstan/extension-installer true + composer global require decodelabs/effigy + - name: "Install dependencies" uses: "ramsey/composer-install@v2" with: dependency-versions: "highest" - name: "Check coding style" - run: "composer run-script --no-interaction ecs" - - exported_files: - name: "5️⃣ Exported files" - needs: - - "byte_level" - - "syntax_errors" - runs-on: "ubuntu-latest" - steps: - - name: "Checkout code" - uses: "actions/checkout@v3" - - - name: "Check exported files" run: | - EXPECTED="LICENSE,README.md,composer.json" - CURRENT="$(git archive HEAD | tar --list --exclude="src" --exclude="src/*" | paste -s -d ",")" - echo "CURRENT =${CURRENT}" - echo "EXPECTED=${EXPECTED}" - test "${CURRENT}" = "${EXPECTED}" + composer global exec effigy format -- --headless + diff --git a/CHANGELOG.md b/CHANGELOG.md index 6893b2e..f2f87bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v0.2.7 (2023-09-26) +* Converted phpstan doc comments to generic +* Fixed PHP8.1 testing +* Migrated to use effigy in CI workflow + ## v0.2.6 (2022-10-17) * Added toDateInterval() * Fixed DateTimeInterface handling diff --git a/README.md b/README.md index a9489b5..dceb345 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/coercion?style=flat)](https://packagist.org/packages/decodelabs/coercion) [![Latest Version](https://img.shields.io/packagist/v/decodelabs/coercion.svg?style=flat)](https://packagist.org/packages/decodelabs/coercion) [![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/coercion.svg?style=flat)](https://packagist.org/packages/decodelabs/coercion) -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/decodelabs/coercion/Integrate)](https://github.com/decodelabs/coercion/actions/workflows/integrate.yml) +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/coercion/integrate.yml?branch=develop)](https://github.com/decodelabs/coercion/actions/workflows/integrate.yml) [![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true&style=flat)](https://github.com/phpstan/phpstan) [![License](https://img.shields.io/packagist/l/decodelabs/coercion?style=flat)](https://packagist.org/packages/decodelabs/coercion) diff --git a/composer.json b/composer.json index e916d69..b55a0f1 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,6 @@ "decodelabs/exceptional": "^0.4" }, "require-dev": { - "phpunit/phpunit": "^9", - "phpstan/phpstan": "^1", - "phpstan/extension-installer": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "symplify/easy-coding-standard": "^11", - "decodelabs/phpstan-decodelabs": "^0.6" }, "autoload": { @@ -31,29 +25,5 @@ "branch-alias": { "dev-develop": "0.2.x-dev" } - }, - "config": { - "allow-plugins": { - "phpstan/extension-installer": true - } - }, - "scripts": { - "analyze": "phpstan analyze --no-progress", - "clear-phpstan": "phpstan clear-result-cache", - "ecs": "ecs check --no-progress-bar", - "ecs-fix": "ecs check --no-progress-bar --fix", - "lint": "parallel-lint src/ ecs.php", - "eclint": "eclint check src/ ecs.php", - "eclint-fix": "eclint fix src/ ecs.php", - "non-ascii": "! LC_ALL=C.UTF-8 find src/ -type f -name \"*.php\" -print0 | xargs -0 -- grep -PHn \"[^ -~]\" | grep -v '// @ignore-non-ascii$'", - "prep": [ - "@composer update", - "@clear-phpstan", - "@analyze", - "@ecs-fix", - "@lint", - "@eclint", - "@non-ascii" - ] } } diff --git a/src/Coercion.php b/src/Coercion.php index 0ad587f..f795175 100644 --- a/src/Coercion.php +++ b/src/Coercion.php @@ -280,9 +280,8 @@ public static function toArrayOrNull(mixed $value): ?array * * @template TKey of int|string * @template TValue - * @phpstan-param array|iterable $value - * - * @phpstan-return array + * @param array|iterable $value + * @return array */ public static function iterableToArray(iterable $value): array { @@ -299,8 +298,8 @@ public static function iterableToArray(iterable $value): array * Coerce value to type * * @template T of object - * @phpstan-param class-string $type - * @phpstan-return T + * @param class-string $type + * @return T */ public static function toType( mixed $value, @@ -317,8 +316,8 @@ public static function toType( * Coerce value to type or null * * @template T of object - * @phpstan-param class-string $type - * @phpstan-return T|null + * @param class-string $type + * @return T|null */ public static function toTypeOrNull( mixed $value,