Skip to content

Commit d2cf1cf

Browse files
authored
Update various files to prefer PHP 8.1 and PHPUnit 10.5 or 11.0, remo… (#25)
Signed-off-by: Marcel Strahl <info@marcel-strahl.de>
1 parent 41ca2d6 commit d2cf1cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+772
-687
lines changed

.github/workflows/ci.yml

+51-47
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,18 @@
11
name: "CI Tests"
22

33
on:
4-
pull_request:
5-
push:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
68

79
jobs:
8-
php80:
9-
name: PHP 8.0
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: "Checkout"
13-
uses: "actions/checkout@v3"
14-
with:
15-
fetch-depth: 2
16-
17-
- name: "Install PHP 8.0"
18-
uses: "shivammathur/setup-php@v2"
19-
with:
20-
php-version: "8.0"
21-
22-
- name: "Cache composer packages"
23-
uses: "actions/cache@v3"
24-
with:
25-
path: "~/.composer/cache"
26-
key: "php-composer-locked-${{ hashFiles('composer.lock') }}"
27-
restore-keys: "php-composer-locked-"
28-
29-
- name: "Install dependencies with composer"
30-
run: "composer install --no-interaction"
31-
32-
- name: "Run PHPUnit Tests"
33-
run: "composer test"
34-
35-
- name: "Run PHP CS Check"
36-
run: "composer cs-check"
37-
38-
- name: "Run PHPStan"
39-
run: "composer analyze"
40-
41-
- name: "Run Psalm"
42-
run: "composer psalm"
43-
4410
php81:
4511
name: PHP 8.1
4612
runs-on: ubuntu-latest
4713
steps:
4814
- name: "Checkout"
49-
uses: "actions/checkout@v3"
15+
uses: "actions/checkout@v4"
5016
with:
5117
fetch-depth: 2
5218

@@ -56,7 +22,7 @@ jobs:
5622
php-version: "8.1"
5723

5824
- name: "Cache composer packages"
59-
uses: "actions/cache@v3"
25+
uses: "actions/cache@v4"
6026
with:
6127
path: "~/.composer/cache"
6228
key: "php-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -71,18 +37,18 @@ jobs:
7137
- name: "Run PHP CS Check"
7238
run: "composer cs-check"
7339

74-
- name: "Run PHPStan"
75-
run: "composer analyze"
76-
7740
- name: "Run Psalm"
7841
run: "composer psalm"
7942

43+
- name: "Run infection"
44+
run: "composer infection-ci"
45+
8046
php82:
8147
name: PHP 8.2
8248
runs-on: ubuntu-latest
8349
steps:
8450
- name: "Checkout"
85-
uses: "actions/checkout@v3"
51+
uses: "actions/checkout@v4"
8652
with:
8753
fetch-depth: 2
8854

@@ -92,7 +58,7 @@ jobs:
9258
php-version: "8.2"
9359

9460
- name: "Cache composer packages"
95-
uses: "actions/cache@v3"
61+
uses: "actions/cache@v4"
9662
with:
9763
path: "~/.composer/cache"
9864
key: "php-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -107,8 +73,46 @@ jobs:
10773
- name: "Run PHP CS Check"
10874
run: "PHP_CS_FIXER_IGNORE_ENV=1 composer cs-check"
10975

110-
- name: "Run PHPStan"
111-
run: "composer analyze"
76+
- name: "Run Psalm"
77+
run: "composer psalm"
78+
79+
- name: "Run infection"
80+
run: "composer infection-ci"
81+
82+
php83:
83+
name: PHP 8.3
84+
runs-on: ubuntu-latest
85+
steps:
86+
- name: "Checkout"
87+
uses: "actions/checkout@v4"
88+
with:
89+
fetch-depth: 2
90+
91+
- name: "Install PHP 8.3"
92+
uses: "shivammathur/setup-php@v2"
93+
with:
94+
php-version: "8.3"
95+
96+
- name: "Cache composer packages"
97+
uses: "actions/cache@v4"
98+
with:
99+
path: "~/.composer/cache"
100+
key: "php-composer-locked-${{ hashFiles('composer.lock') }}"
101+
restore-keys: "php-composer-locked-"
102+
103+
- name: "Install dependencies with composer"
104+
run: "composer install --no-interaction"
105+
106+
- name: "Run PHPUnit Tests"
107+
run: "composer test"
108+
109+
- name: "Run PHP CS Check"
110+
run: "PHP_CS_FIXER_IGNORE_ENV=1 composer cs-check"
112111

113112
- name: "Run Psalm"
114113
run: "composer psalm"
114+
115+
- name: "Run infection"
116+
env:
117+
INFECTION_BADGE_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
118+
run: "composer infection-ci"

.php-cs-fixer.dist.php

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/*
3+
* This document has been generated with
4+
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.8.0|configurator
5+
* you can change this configuration by importing this file.
6+
*/
7+
$config = new PhpCsFixer\Config();
8+
return $config
9+
->setRiskyAllowed(true)
10+
->setRules([
11+
'@PSR2' => true,
12+
'array_indentation' => true,
13+
'array_syntax' => ['syntax'=>'short'],
14+
'blank_line_before_statement' => true,
15+
'single_space_around_construct' => false,
16+
'cast_spaces' => true,
17+
'concat_space' => ['spacing'=>'one'],
18+
'declare_equal_normalize' => true,
19+
'dir_constant' => true,
20+
'type_declaration_spaces' => true,
21+
'include' => true,
22+
'linebreak_after_opening_tag' => true,
23+
'lowercase_cast' => true,
24+
'lowercase_static_reference' => true,
25+
'magic_constant_casing' => true,
26+
'modernize_types_casting' => true,
27+
'native_function_casing' => true,
28+
'new_with_parentheses' => true,
29+
'no_alternative_syntax' => true,
30+
'no_closing_tag' => true,
31+
'no_empty_comment' => true,
32+
'no_empty_statement' => true,
33+
'no_extra_blank_lines' => true,
34+
'no_leading_import_slash' => true,
35+
'no_leading_namespace_whitespace' => true,
36+
'no_multiline_whitespace_around_double_arrow' => true,
37+
'no_null_property_initialization' => true,
38+
'no_short_bool_cast' => true,
39+
'no_singleline_whitespace_before_semicolons' => true,
40+
'no_spaces_around_offset' => true,
41+
'no_superfluous_elseif' => true,
42+
'no_trailing_comma_in_singleline' => true,
43+
'no_unneeded_control_parentheses' => true,
44+
'no_unneeded_braces' => true,
45+
'no_unneeded_final_method' => true,
46+
'no_unused_imports' => true,
47+
'no_useless_else' => true,
48+
'no_whitespace_before_comma_in_array' => true,
49+
'no_whitespace_in_blank_line' => true,
50+
'normalize_index_brace' => true,
51+
'object_operator_without_whitespace' => true,
52+
'ordered_imports' => true,
53+
'phpdoc_annotation_without_dot' => true,
54+
'phpdoc_indent' => true,
55+
'phpdoc_no_access' => true,
56+
'return_type_declaration' => true,
57+
'short_scalar_cast' => true,
58+
'simplified_null_return' => true,
59+
'blank_lines_before_namespace' => true,
60+
'single_quote' => true,
61+
'standardize_not_equals' => true,
62+
'strict_comparison' => true,
63+
'ternary_operator_spaces' => true,
64+
'ternary_to_null_coalescing' => true,
65+
'trim_array_spaces' => true,
66+
'unary_operator_spaces' => true,
67+
'visibility_required' => true,
68+
'whitespace_after_comma_in_array' => true,
69+
])
70+
->setFinder(PhpCsFixer\Finder::create()
71+
->exclude(['vendor', 'tests/Http/Responses/metadata'])
72+
->in(__DIR__)
73+
)
74+
;

.php-cs-fixer.php

-78
This file was deleted.

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ This Changelog refers to all changes since v5.0.0
1010
* Vat and Price entity now has a private constructor and is initialized by a new `static` create method.
1111
* The `ConverterFactory` class uses `match` instead of `switch`.
1212
* Fixed unwanted forced order in the VAT calculation (for more details see [Upgrade to 5.0 Guide](UPGRADE-5.0.md))
13+
14+
# v5.x.x
15+
+ Upgrade of dependencies, removal of PHPStan as I focused more on Psalm.
16+
+ All test classes are now final and use attributes instead of annotations.
17+
+ Using InfectionPHP to check the effectiveness of the test set.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Marcel Strahl
3+
Copyright (c) 2018-2024 Marcel Strahl
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

+14-10
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^8.0",
15+
"php": ">=8.1",
1616
"ext-bcmath": "*"
1717
},
1818
"require-dev": {
19-
"friendsofphp/php-cs-fixer": "^3.13",
20-
"phpstan/phpstan": "^1.9",
21-
"phpstan/phpstan-phpunit": "^1.3",
22-
"phpstan/phpstan-webmozart-assert": "^1.2",
23-
"phpunit/phpunit": "^9.5",
19+
"friendsofphp/php-cs-fixer": "^3.51",
20+
"infection/infection": "^0.27.10",
21+
"phpstan/extension-installer": "*",
22+
"phpunit/phpunit": "^10.5 | ^11.0",
2423
"psalm/plugin-phpunit": "^0.18",
25-
"squizlabs/php_codesniffer": "^3.7",
24+
"squizlabs/php_codesniffer": "^3.9",
2625
"vimeo/psalm": "^5.4"
2726
},
2827
"autoload": {
@@ -32,16 +31,21 @@
3231
}
3332
},
3433
"config": {
35-
"sort-packages": true
34+
"sort-packages": true,
35+
"allow-plugins": {
36+
"infection/extension-installer": true,
37+
"phpstan/extension-installer": true
38+
}
3639
},
3740
"prefer-stable": true,
3841
"scripts": {
3942
"phpcs": "phpcs --standard=phpcs.xml.dist",
4043
"cs-check": "php-cs-fixer -v --dry-run --using-cache=no fix",
4144
"cs-fix": "php-cs-fixer --using-cache=no fix",
42-
"test": "export XDEBUG_MODE=coverage && vendor/bin/phpunit --configuration phpunit.xml",
45+
"test": "export XDEBUG_MODE=coverage && phpunit -c phpunit.xml --coverage-xml build/logs --coverage-clover build/logs/clover.xml --coverage-html build/logs/clover.html --log-junit build/logs/junit.xml",
4346
"psalm": "vendor/bin/psalm --no-cache",
44-
"analyze": "vendor/bin/phpstan analyse --xdebug --configuration phpstan.neon.dist",
47+
"infection": "infection --threads=4",
48+
"infection-ci": "infection --coverage=build/logs --threads=4",
4549
"check": [
4650
"@phpcs",
4751
"@cs-check",

docs/price-formatter.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ In order to enter a value from a price object into the price formatter, the Cent
3232
```php
3333
<?php
3434

35-
use MarcelStrahl\PriceCalculator\Helpers\View\PriceFormatter;
36-
use MarcelStrahl\PriceCalculator\Facade\UnitConverter;
37-
use MarcelStrahl\PriceCalculator\Factory\ConverterFactoryInterface;
38-
use MarcelStrahl\PriceCalculator\Helpers\Entity\Price;
39-
use function var_dump;
35+
use MarcelStrahl\PriceCalculator\Contracts\Factory\ConverterFactoryInterface;use MarcelStrahl\PriceCalculator\Facade\UnitConverter;use MarcelStrahl\PriceCalculator\Helpers\Entity\Price;use MarcelStrahl\PriceCalculator\Helpers\View\PriceFormatter;
4036

4137
$calculatedResultInCent = Price::create(1010);
4238

0 commit comments

Comments
 (0)