Skip to content

Upgrade code to php 8.1 #480

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

Merged
merged 3 commits into from
Dec 8, 2023
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
40 changes: 32 additions & 8 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,67 @@ name: "Integrate"
on: # yamllint disable-line rule:truthy
push:
branches:
- "5.x"
- "6.x"
pull_request: null
# Allow manually triggering the workflow.
workflow_dispatch: null

jobs:
code-coverage:
name: "Code Coverage"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
with:
php-version: "8.2"

coding-standards:
name: "Coding Standards"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
runs-on: "ubuntu-22.04"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.2"
tools: "cs2pr"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "locked"

- name: "Run PHP_CodeSniffer"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"

dependency-analysis:
name: "Dependency analysis"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
with:
php-version: "8.2"

lint-root:
name: "Lint root"
uses: "phpDocumentor/.github/.github/workflows/lint.yml@v0.4.0"
uses: "phpDocumentor/.github/.github/workflows/lint.yml@v0.5.0"
with:
php-version: "8.2"
composer-options: "--no-check-publish --ansi"

static-analysis:
name: "Static analysis"
uses: "phpDocumentor/.github/.github/workflows/static-analysis.yml@v0.4.0"
uses: "phpDocumentor/.github/.github/workflows/static-analysis.yml@v0.5.0"
with:
php-version: "8.2"
php-extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, pcntl, posix"

unit-tests:
name: "Unit test"
uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.4.0"
uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.5.0"

integration-tests:
name: "Integration test"
uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.4.0"
uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.5.0"
needs: "unit-tests"
with:
test-suite: "integration"
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@ help: ## Displays this list of targets with descriptions

.PHONY: code-style
code-style:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M -s
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpcs

.PHONY: fix-code-style
fix-code-style:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpcbf

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan and vimeo/psalm
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpstan --configuration=phpstan.neon
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/psalm
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpstan --configuration=phpstan.neon
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/psalm

.PHONY: test
test: test-unit test-functional ## Runs all test suites with phpunit/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpunit

.PHONY: test-unit
test-unit: ## Runs unit tests with phpunit/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit --testsuite=unit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpunit --testsuite=unit

.PHONY: test-functional
test-functional: ## Runs unit tests with phpunit/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit --testsuite=functional
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpunit --testsuite=functional

.PHONY: dependency-analysis
dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 .phive/composer-require-checker check --config-file=/opt/project/composer-require-checker.json
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli .phive/composer-require-checker check --config-file=/opt/project/composer-require-checker.json

vendor: composer.json composer.lock
composer validate --no-check-publish
composer install --no-interaction --no-progress

.PHONY: benchmark
benchmark:
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project php:7.4-cli tools/phpbench run
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project php:8.1-cli tools/phpbench run

.PHONY: rector
rector: ## Refactor code using rector
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/rector process
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/rector process

.PHONY: pre-commit-test
pre-commit-test: fix-code-style test code-style static-code-analysis
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
},
"require": {
"php": "^7.4|8.0.*|8.1.*|8.2.*|8.3.*",
"php": "8.1.*|8.2.*|8.3.*",
"nikic/php-parser": "~4.14",
"phpdocumentor/reflection-common": "^2.1",
"phpdocumentor/reflection-docblock": "^5",
Expand All @@ -28,6 +28,8 @@
"webmozart/assert": "^1.7"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"doctrine/coding-standard": "^12.0",
"mikey179/vfsstream": "~1.2",
"mockery/mockery": "~1.6.0",
"phpspec/prophecy-phpunit": "^2.0",
Expand All @@ -37,6 +39,7 @@
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.18.0",
"squizlabs/php_codesniffer": "^3.8",
"vimeo/psalm": "^5.0"
},
"config": {
Expand All @@ -45,15 +48,17 @@
},
"sort-packages": true,
"platform": {
"php": "7.4.0"
"php": "8.1.0"
},
"allow-plugins": {
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"branch-alias": {
"dev-5.x": "5.3.x-dev"
"dev-5.x": "5.3.x-dev",
"dev-6.x": "6.0.x-dev"
}
}
}
Loading