Skip to content

Commit

Permalink
Merge branch 'release/v0.2.7' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Sep 26, 2023
2 parents 5a49e8d + 47ef8fe commit dfade24
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 124 deletions.
133 changes: 47 additions & 86 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
30 changes: 0 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
]
}
}
13 changes: 6 additions & 7 deletions src/Coercion.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ public static function toArrayOrNull(mixed $value): ?array
*
* @template TKey of int|string
* @template TValue
* @phpstan-param array<TKey, TValue>|iterable<TKey, TValue> $value
*
* @phpstan-return array<TKey, TValue>
* @param array<TKey, TValue>|iterable<TKey, TValue> $value
* @return array<TKey, TValue>
*/
public static function iterableToArray(iterable $value): array
{
Expand All @@ -299,8 +298,8 @@ public static function iterableToArray(iterable $value): array
* Coerce value to type
*
* @template T of object
* @phpstan-param class-string<T> $type
* @phpstan-return T
* @param class-string<T> $type
* @return T
*/
public static function toType(
mixed $value,
Expand All @@ -317,8 +316,8 @@ public static function toType(
* Coerce value to type or null
*
* @template T of object
* @phpstan-param class-string<T> $type
* @phpstan-return T|null
* @param class-string<T> $type
* @return T|null
*/
public static function toTypeOrNull(
mixed $value,
Expand Down

0 comments on commit dfade24

Please sign in to comment.