Skip to content

Commit 3946efd

Browse files
committed
Updated tests in order to be executed in PHP 8.4, and supports Php 8.4
1 parent c43217c commit 3946efd

File tree

148 files changed

+1425
-727
lines changed

Some content is hidden

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

148 files changed

+1425
-727
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [Halleck45]

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
release:
9+
types: [created]
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
php-version: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
17+
#php-version: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
18+
include:
19+
- php-version: nightly
20+
fail-fast: false
21+
22+
services:
23+
docker:
24+
image: docker:20.10.16
25+
options: --privileged
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Set up PHP ${{ matrix.php-version }}
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php-version }}
34+
35+
- name: "Remove ': void' return type hint for older PHP versions"
36+
run: |
37+
# if php version < 7.1, remove ': void' return type hint
38+
if [[ "${{ matrix.php-version }}" < "7.1" ]]; then
39+
echo "Removing ': void' return type hint for PHP version ${{ matrix.php-version }}"
40+
# Find and replace ': void' in all PHP files
41+
find . -type f -name "*.php" -exec sed -i 's/: void//g' {} +
42+
fi
43+
44+
- name: Install Composer dependencies (${{ matrix.php-version }})
45+
run: composer install --no-interaction --prefer-dist --no-progress
46+
47+
- name: Run tests (${{ matrix.php-version }})
48+
run: make test
49+
50+
- name: Run Docker tests
51+
run: docker run --rm test_phpmetrics
52+
53+
build:
54+
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')
55+
needs: test
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up PHP
61+
uses: shivammathur/setup-php@v2
62+
with:
63+
php-version: 7.0
64+
65+
- name: Build project
66+
run: make build
67+
68+
- name: Add build artifact
69+
run: git add -f build/phpmetrics.phar
70+
71+
- name: Upload release asset
72+
uses: softprops/action-gh-release@v2
73+
with:
74+
files: build/phpmetrics.phar
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
composer.lock
22
vendor
3+
tooling/vendor
34
.idea
45
md5sums
56
control
@@ -8,3 +9,12 @@ build/phpmetrics.dsc
89
build/phpmetrics.deb
910
build/phpmetrics.tar.gz
1011
build/phpmetrics.changes
12+
.php-cs-fixer.cache
13+
.phpunit.result.cache
14+
15+
# build
16+
buildroot/
17+
downloads/
18+
pkgroot/
19+
source/
20+
spc

.php-cs-fixer.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__ . '/src')
5+
;
6+
7+
return (new PhpCsFixer\Config())
8+
->setRules([
9+
'@PER-CS' => true,
10+
'@PHP82Migration' => true,
11+
])
12+
->setFinder($finder)
13+
->setUnsupportedPhpVersionAllowed(true)
14+
;

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
include artifacts/Makefile
44

5-
# Run unit tests
5+
# Run unit tests
66
test:
77
./vendor/bin/phpunit -c phpunit.xml.dist
88

99
# Codesniffer check
1010
phpcs:
11-
./vendor/bin/phpcs src/ tests/ --extensions=php -n
11+
./tooling/vendor/bin/php-cs-fixer check src
1212

13-
# Codesniffer fix
14-
phpcbf:
15-
./vendor/bin/phpcbf src/ tests/ --extensions=php -n
13+
# Compatibility check
14+
compatibility:
15+
(docker run --rm -v `pwd`:/www --workdir=/www php:5.6-cli find src -iname "*.php" -exec php -l {} \; |grep -v "Php7NodeTraverser.php" | grep -v "No syntax errors detected") && echo OK
1616

1717
# Used for tag releasing
1818
# Don't use directly, use `make release` instead

artifacts/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ BUILD_DIR=releases
44

55
include artifacts/phar/Makefile
66
include artifacts/debian/Makefile
7+
include artifacts/standalone/Makefile
78

89
prepare-build:
910
@# Disable the deletion of all releases packages as task build-debian is disabled.
@@ -12,5 +13,5 @@ prepare-build:
1213
@# Only remove the phar that must be replaced by the new release.
1314
@rm -f ${BUILD_DIR}/phpmetrics.phar
1415

15-
build: prepare-build build-phar build-deb
16+
build: prepare-build build-phar build-deb build-standalone
1617

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@
3030
},
3131
"files": ["./src/functions.php"]
3232
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Test\\Hal\\": "tests/"
36+
}
37+
},
3338
"require": {
34-
"php": ">=5.5",
3539
"ext-dom": "*",
3640
"ext-tokenizer": "*",
37-
"nikic/php-parser": "^3|^4"
38-
},
39-
"require-dev": {
40-
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14",
41-
"sebastian/comparator": ">=1.2.3",
42-
"squizlabs/php_codesniffer": "^3.5",
43-
"symfony/dom-crawler": "^3.0 || ^4.0 || ^5.0"
41+
"nikic/php-parser": "^3|^4|^5"
4442
},
4543
"bin": [
4644
"bin/phpmetrics"
4745
],
4846
"config": {
4947
"sort-packages": true
48+
},
49+
"require-dev": {
50+
"phpunit/phpunit": "*"
5051
}
5152
}

craft.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
php-version: 8.4
2+
extensions: "apcu,phar,curl,dom,fileinfo,filter,intl,mbstring,mysqlnd,openssl,tokenizer,zlib"
3+
sapi: micro
4+
build-options:
5+
with-upx-pack: true
6+
prefer-pre-built: true

doc/contributing.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ Then, in order to run the test suite:
1111

1212
Thanks for your help.
1313

14+
## Why the code is so old?
15+
16+
### Philosophy
17+
18+
PhpMetrics has several goals:
19+
+ be stable
20+
+ be performant
21+
+ run on the **maximum of PHP versions** (PHP 5.3 to PHP 8.4)
22+
+ be installable everywhere, **without dependency conflicts**
23+
24+
For these reasons, the code of PhpMetrics is intentionally written in "legacy" PHP.
25+
26+
### Dependencies
27+
28+
Not all projects are on the latest version of PHP, Symfony, or Laravel. Yes, there are projects that use Symfony 2. And these projects may also need metrics and quality.
29+
30+
For these reasons, PhpMetrics comes with the minimum of dependencies. Only the dependency on `nikic/php-parser` is accepted.
31+
32+
No Pull Request that modifies the `require` block will be accepted.
33+
34+
1435
## Releasing
1536

1637
Please NEVER tag manually.

phpcs.xml.dist

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

0 commit comments

Comments
 (0)