Skip to content

Commit

Permalink
PHP 8.2 support
Browse files Browse the repository at this point in the history
* Check PHP 8.2 compatibility
* Add psalm to static analysis
  • Loading branch information
szhajdu authored Mar 18, 2023
1 parent 0648f3d commit 57949f6
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 23 deletions.
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Exclude files that don't need to be present in packages (so they're not downloaded by Composer)
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
.php-cs-fixer.dist.php export-ignore
codeception.yml export-ignore
/Makefile export-ignore
/phpstan.neon.dist export-ignore
/psalm.xml export-ignore
/test/ export-ignore
/vendor-bin/ export-ignore
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
max-parallel: 10
matrix:
php: [ '8.0', '8.1' ]
php: [ '8.0', '8.1', '8.2' ]

steps:
- name: Set up PHP
Expand All @@ -20,10 +20,10 @@ jobs:
tools: composer:v2

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Download dependencies
run: composer update --no-interaction --prefer-dist

- name: Run tests
run: make test
run: make tests
61 changes: 51 additions & 10 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,65 @@ jobs:

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

- name: PHPStan
uses: docker://oskarstark/phpstan-ga:1.4.6
env:
REQUIRE_DEV: true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
args: analyze --no-progress
php-version: '8.0'
coverage: none

- name: Download dependencies
run: composer install --no-interaction --no-progress

- name: Download PHPStan
run: composer bin phpstan install --no-interaction --no-progress

- name: Execute PHPStan
run: vendor/bin/phpstan analyze --no-progress

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none

- name: Download dependencies
run: composer install --no-interaction --no-progress

- name: Download PHP CS Fixer
run: composer bin php-cs-fixer install --no-interaction --no-progress

- name: Execute PHP CS Fixer
run: vendor/bin/php-cs-fixer fix --diff --dry-run

psalm:
name: Psalm
runs-on: ubuntu-latest

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

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:3.4.0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
args: --dry-run --diff
php-version: '8.0'
coverage: none

- name: Download dependencies
run: composer install --no-interaction --no-progress

- name: Download Psalm
run: composer bin psalm install --no-interaction --no-progress

- name: Execute Psalm
run: vendor/bin/psalm.phar --no-progress --output-format=github
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Files
.php_cs
.php_cs.cache
/composer.lock
composer.lock
/phpstan.neon
!/test/output/.gitkeep

# Directories
/test/output/*
/test/support/_generated
/vendor
/vendor-bin/**/vendor/
5 changes: 5 additions & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.1.0] - 2023-03-17
### Added
- PHP 8.2 support
- Additional Psalm static analysis

## [4.0.0] - 2022-10-19
### Added
- Codeception v5 support.
Expand Down
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " test to perform tests."
@echo " tests to perform tests."
@echo " coverage to perform tests with code coverage."
@echo " static to run phpstan and php-cs-fixer check."
@echo " static-phpstan to run phpstan."
@echo " static-psalm to run psalm."
@echo " static-cs-check to run php-cs-fixer."
@echo " static-cs-fix to run php-cs-fixer, writing the changes."

.PHONY: test
test:
tests:
vendor/bin/codecept build
vendor/bin/codecept run

.PHONY: coverage
coverage:
vendor/bin/codecept build
vendor/bin/codecept run --coverage --coverage-xml --coverage-html

.PHONY: static
static: static-phpstan static-cs-check
static: static-phpstan static-psalm static-cs-check

static-phpstan:
docker run --rm -it -e REQUIRE_DEV=true -v ${PWD}:/app -w /app oskarstark/phpstan-ga:0.12.85 analyze $(PHPSTAN_PARAMS)
composer install
composer bin phpstan install
vendor/bin/phpstan analyze $(PHPSTAN_PARAMS)

static-psalm:
composer install
composer bin psalm install
vendor/bin/psalm.phar $(PSALM_PARAMS)

static-cs-fix:
docker run --rm -it -v ${PWD}:/app -w /app oskarstark/php-cs-fixer-ga:2.19.0 --diff-format udiff $(CS_PARAMS)
composer install
composer bin php-cs-fixer install
vendor/bin/php-cs-fixer fix --diff $(CS_PARAMS)

static-cs-check:
$(MAKE) static-cs-fix CS_PARAMS="--dry-run"
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"require-dev": {
"ext-json": "*",
"bamarni/composer-bin-plugin": "^1.8",
"codeception/module-asserts": "^3.0",
"codeception/module-rest": "^3.0"
},
Expand All @@ -32,6 +33,15 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"bamarni/composer-bin-plugin": true
}
},
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
}
}
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- vendor-bin/phpstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon

parameters:
level: max
checkMissingIterableValueType: false
Expand Down
16 changes: 16 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="6"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
9 changes: 9 additions & 0 deletions vendor-bin/php-cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"require-dev": {
"php": "^8.0",
"friendsofphp/php-cs-fixer": "^3.15"
},
"config": {
"preferred-install": "dist"
}
}
10 changes: 10 additions & 0 deletions vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"require-dev": {
"php": "^8.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1"
},
"config": {
"preferred-install": "dist"
}
}
9 changes: 9 additions & 0 deletions vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"require-dev": {
"php": "^8.0",
"psalm/phar": "^5.8"
},
"config": {
"preferred-install": "dist"
}
}

0 comments on commit 57949f6

Please sign in to comment.