Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump PHP to 8.3 + CS #14

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,35 @@ name: build
jobs:
phpunit:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ 'ubuntu-latest', 'windows-latest' ]
php: [ '8.2' ]
php: [ '8.3', '8.4' ]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
env:
update: true
with:
ini-values: date.timezone='UTC'
php-version: ${{ matrix.php }}
tools: composer:v2
ini-values: date.timezone='UTC'
coverage: xdebug

- name: Determine composer cache directory on Linux
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Determine composer cache directory on Windows
if: matrix.os == 'windows-latest'
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Run tests with PHPUnit
run: vendor/bin/phpunit --colors=always --coverage-clover=coverage.xml

- name: Cache dependencies installed with composer
uses: actions/cache@v3
- name: Upload coverage to Coveralls
if: matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@v2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-

- name: Update composer
run: composer self-update

- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with PHPUnit
run: vendor/bin/phpunit --configuration phpunit.xml.dist
file: ./coverage.xml
28 changes: 8 additions & 20 deletions .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,26 @@ name: Composer require checker
jobs:
composer-require-checker:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ 'ubuntu-latest' ]
php: [ '8.2' ]
php: [ '8.3', '8.4' ]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
ini-values: date.timezone='UTC'
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Determine composer cache directory on Linux
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-

- name: Update composer
run: composer self-update
coverage: none

- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Check dependencies
run: vendor/bin/composer-require-checker
38 changes: 38 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: cs fixer

on: [ pull_request_target ]

jobs:
php-cs-fixer:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:v2
coverage: none

- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"

- name: Run PHP CS Fixer
run: composer php-cs-fixer

- name: Run Rector
run: composer rector

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Apply PHP CS Fixer and Rector changes (CI)"
file_pattern: '*.php'
disable_globbing: true
36 changes: 11 additions & 25 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,29 @@ name: mutation test
jobs:
roave-infection:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ 'ubuntu-latest' ]
php: [ '8.2' ]
php: [ '8.4' ]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
ini-values: date.timezone='UTC'
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Determine composer cache directory on Linux
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-

- name: Update composer
run: composer self-update
php-version: "${{ matrix.php }}"
ini-values: memory_limit=-1
coverage: xdebug

- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Run roave infection
run: |
vendor/bin/roave-infection-static-analysis-plugin -j2 --min-msi=100 --min-covered-msi=100 --ignore-msi-with-no-mutations --only-covered
- name: Run infection
run: vendor/bin/infection --threads=2 --ignore-msi-with-no-mutations --only-covered
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
29 changes: 9 additions & 20 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,27 @@ name: static analysis
jobs:
psalm:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ 'ubuntu-latest' ]
php: [ '8.2' ]
php: [ '8.3', '8.4' ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
ini-values: date.timezone='UTC'
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Determine composer cache directory on Linux
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-

- name: Update composer
run: composer self-update
php-version: "${{ matrix.php }}"
ini-values: memory_limit=-1
coverage: xdebug

- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Static analysis
run: vendor/bin/psalm --config=psalm.xml --shepherd --stats --output-format=github --php-version=${{ matrix.php }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# PHPUnit
.phpunit.cache

# PHP CS Fixer
/.php-cs-fixer.cache
20 changes: 20 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$finder = (new Finder())->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return (new Config())
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@PER-CS2.0' => true,
'no_unused_imports' => true,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Latest Stable Version](https://poser.pugx.org/php-finance/double-entry/v)](https://packagist.org/packages/php-finance/double-entry)
[![Total Downloads](https://poser.pugx.org/php-finance/double-entry/downloads)](https://packagist.org/packages/php-finance/double-entry)
[![Build status](https://github.com/php-finance/double-entry/actions/workflows/build.yml/badge.svg)](https://github.com/php-finance/double-entry/actions/workflows/build.yml)
[![Coverage Status](https://coveralls.io/repos/github/php-finance/double-entry/badge.svg)](https://coveralls.io/github/php-finance/double-entry)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fphp-finance%2Fdouble-entry%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/php-finance/double-entry/master)
[![type-coverage](https://shepherd.dev/github/php-finance/double-entry/coverage.svg)](https://shepherd.dev/github/php-finance/double-entry)
[![static analysis](https://github.com/php-finance/double-entry/workflows/static%20analysis/badge.svg)](https://github.com/php-finance/double-entry/actions?query=workflow%3A%22static+analysis%22)
Expand Down
20 changes: 14 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,28 @@
},
"minimum-stability": "stable",
"require": {
"php": "^8.2",
"php": "~8.3.0 || ~8.4.0",
"ext-mbstring": "*",
"brick/money": "^0.8.0"
"brick/money": "^0.10.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.6",
"phpunit/phpunit": "^10.2",
"roave/infection-static-analysis-plugin": "^1.32",
"vimeo/psalm": "^5.13"
"friendsofphp/php-cs-fixer": "^3.69",
"infection/infection": "^0.29.12",
"maglnet/composer-require-checker": "^4.16.1",
"phpunit/phpunit": "^12.0.3",
"rector/rector": "^2.0",
"vimeo/psalm": "^6.8"
},
"config": {
"sort-packages": true,
"bump-after-update": "dev",
"allow-plugins": {
"infection/extension-installer": false
}
},
"scripts": {
"php-cs-fixer": "php-cs-fixer fix",
"infection": "infection --ignore-msi-with-no-mutations --only-covered",
"rector": "rector"
}
}
3 changes: 2 additions & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"PhpFinance\\DoubleEntry\\Domain\\Transaction\\Transaction::getDate"
]
}
}
},
"minCoveredMsi": 100
}
32 changes: 19 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
colors="true"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
colors="true"
displayDetailsOnPhpunitDeprecations="true"
>
<php>
<ini name="error_reporting" value="-1" />
</php>

<testsuites>
<testsuite name="default">
<testsuite name="PHP Finance Double Entry tests">
<directory>tests</directory>
</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<source restrictNotices="true" restrictWarnings="true" ignoreIndirectDeprecations="true">
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
5 changes: 1 addition & 4 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
<directory name="src" />
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
Expand Down
Loading