Skip to content

Commit 490cfb0

Browse files
authored
upgrade to PHP 8 (#17)
* add .uuid files to git ignore list * update composer dependencies to PHP ^8.1 and php-sap/interfaces ^4.1 * refactor API classes for restructured interfaces * add parameter and return types #16 * add phpstan.neon * switch to php-sap/interfaces:dev-main for development * simplify regex in ConfigCommon.php * fix typos in ConfigCommon.php * adapt API classes to new interfaces * fix inheritance loop in AbstractConfiguration::jsonDecode() * adapt Configuration and Function classes and tests * fix errors reported by phpstan * remove $allowedKeys in favor of method getAllowedKeys() * clarify types in AbstractFunction.php * refactor Config classes for new interface and use traits instead of inheritance * refactor JsonSerializable to new interfaces * remove constructors from Value and Members and from the MembersTrait * setMembers() now accepts objects and arrays of objects as parameter * replace AbstractFunction constructor with factory and adapt to new interfaces * update php-sap/interfaces * ignore PHPStan errors from get() methods * fix setMembers() parameter type hint * ignore PHPStan error that json_decode() returns mixed in JsonSerializable::jsonDecode() * refactor src and tests and adapt for phpstan * change to new github workflow * fix spacing for psr12
1 parent 1afaf25 commit 490cfb0

Some content is hidden

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

51 files changed

+2432
-2638
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ tests/ export-ignore
55
.gitignore export-ignore
66
.phpcs.xml export-ignore
77
composer.* export-ignore
8+
phpstan.neon export-ignore
89
phpunit.xml export-ignore
910
README.md export-ignore

.github/workflows/main.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Controls when the action will run.
2+
on:
3+
# Triggers the workflow on push or pull request events but only for the main branch
4+
push:
5+
pull_request:
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: "read"
12+
13+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
14+
jobs:
15+
# composer validation
16+
composer:
17+
name: "composer config validation"
18+
runs-on: "ubuntu-latest"
19+
steps:
20+
- uses: "actions/checkout@v3"
21+
- name: "Validate composer.json"
22+
run: "composer validate --strict"
23+
# PHP lint and PHPStan for different PHP versions
24+
php:
25+
runs-on: "ubuntu-latest"
26+
strategy:
27+
matrix:
28+
php-version:
29+
- "8.1"
30+
- "8.2"
31+
- "8.3"
32+
name: "PHP ${{ matrix.php-version }}"
33+
steps:
34+
- name: "git checkout"
35+
uses: "actions/checkout@v3"
36+
- name: "setup PHP"
37+
uses: "shivammathur/setup-php@v2"
38+
with:
39+
php-version: "${{ matrix.php-version }}"
40+
coverage: "xdebug"
41+
- name: "check PHP version"
42+
run: "php -v"
43+
- name: "lint PHP files"
44+
run: "php -l exceptions/ src/ tests/"
45+
- name: "install composer dependencies"
46+
run: "composer install --prefer-dist --no-progress"
47+
# PHPStan
48+
- name: "PHPStan static analysis"
49+
uses: "php-actions/phpstan@v3"
50+
with:
51+
php_version: "${{ matrix.php-version }}"
52+
configuration: "phpstan.neon"
53+
path: "exceptions/ src/ tests/"
54+
# run unit tests
55+
phpunit:
56+
runs-on: "ubuntu-latest"
57+
env:
58+
CC_TEST_REPORTER_ID: "b6d85f5dc7af90e89653c56b04866b27d98b35e84c2ff9a5d9499bbb53469cbf"
59+
name: "PHPUnit"
60+
steps:
61+
- name: "git checkout"
62+
uses: "actions/checkout@v3"
63+
- name: "setup PHP"
64+
uses: "shivammathur/setup-php@v2"
65+
with:
66+
php-version: "8.1"
67+
coverage: "xdebug"
68+
- name: "check PHP version"
69+
run: "php -v"
70+
- name: "install composer dependencies"
71+
run: "composer install --prefer-dist --no-progress"
72+
- name: "CodeClimate reporter setup"
73+
run: |
74+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
75+
chmod +x ./cc-test-reporter
76+
./cc-test-reporter before-build
77+
- name: "run PHPUnit"
78+
run: |
79+
php vendor/bin/phpunit --coverage-clover clover.xml --coverage-text
80+
./cc-test-reporter after-build -t clover --exit-code $?

.github/workflows/php.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
22
/.phpunit.result.cache
3+
.uuid

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
],
1818
"minimum-stability": "stable",
1919
"require": {
20-
"php": ">=7.4",
20+
"php": "^8.1",
2121
"ext-json": "*",
22-
"php-sap/interfaces": "^4.0"
22+
"php-sap/interfaces": "dev-main",
23+
"php-sap/datetime": "^1.5"
2324
},
2425
"autoload": {
2526
"psr-4": {

0 commit comments

Comments
 (0)