Skip to content
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
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [Halleck45]
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
include:
- php-version: nightly
fail-fast: false

services:
docker:
image: docker:20.10.16
options: --privileged

steps:
- uses: actions/checkout@v4

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: "Remove ': void' return type hint for older PHP versions"
run: |
# if php version < 7.1, remove ': void' return type hint
if [[ "${{ matrix.php-version }}" < "7.1" ]]; then
echo "Removing ': void' return type hint for PHP version ${{ matrix.php-version }}"
# Find and replace ': void' in all PHP files
find . -type f -name "*.php" -exec sed -i 's/: void//g' {} +
fi

- name: Install Composer dependencies (${{ matrix.php-version }})
run: composer install --no-interaction --prefer-dist --no-progress

- name: Run tests (${{ matrix.php-version }})
run: make test

build:
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.0

- name: Build project
run: make build

- name: Add build artifact
run: git add -f build/phpmetrics.phar

- name: Upload release asset
uses: softprops/action-gh-release@v2
with:
files: build/phpmetrics.phar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
composer.lock
vendor
tooling/vendor
.idea
md5sums
control
Expand All @@ -8,3 +9,12 @@ build/phpmetrics.dsc
build/phpmetrics.deb
build/phpmetrics.tar.gz
build/phpmetrics.changes
.php-cs-fixer.cache
.phpunit.result.cache

# build
buildroot/
downloads/
pkgroot/
source/
spc
14 changes: 14 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__ . '/src')
;

return (new PhpCsFixer\Config())
->setRules([
'@PER-CS' => true,
'@PHP82Migration' => true,
])
->setFinder($finder)
->setUnsupportedPhpVersionAllowed(true)
;
73 changes: 0 additions & 73 deletions .travis.yml

This file was deleted.

14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

include artifacts/Makefile

# Run unit tests
# Run unit tests
test:
./vendor/bin/phpunit -c phpunit.xml.dist
./vendor/bin/phpunit -c phpunit.xml.dist --exclude-group binary

# Codesniffer check
phpcs:
./vendor/bin/phpcs src/ tests/ --extensions=php -n

# Codesniffer fix
phpcbf:
./vendor/bin/phpcbf src/ tests/ --extensions=php -n
# Compatibility check
compatibility:
(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

# Used for tag releasing
# Don't use directly, use `make release` instead
Expand Down
3 changes: 2 additions & 1 deletion artifacts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ BUILD_DIR=releases

include artifacts/phar/Makefile
include artifacts/debian/Makefile
include artifacts/standalone/Makefile

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

build: prepare-build build-phar build-deb
build: prepare-build build-phar build-deb build-standalone

10 changes: 10 additions & 0 deletions artifacts/standalone/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build-standalone: build-standalone-linux

build-standalone-linux:
mkdir -p ${BUILD_DIR}
curl -fsSL -o spc.tgz https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64.tar.gz && tar -zxvf spc.tgz && rm spc.tgz
./spc download --with-php=8.4 --for-extensions "apcu,phar,curl,dom,fileinfo,filter,intl,mbstring,mysqlnd,openssl,tokenizer,zlib" --prefer-pre-built
./spc install-pkg upx
./spc build --build-micro "apcu,phar,curl,dom,fileinfo,filter,intl,mbstring,mysqlnd,openssl,tokenizer,zlib" --with-upx-pack
./spc micro:combine ${BUILD_DIR}/phpmetrics.phar --output=${BUILD_DIR}/phpmetrics-linux-x86_64

17 changes: 9 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@
},
"files": ["./src/functions.php"]
},
"autoload-dev": {
"psr-4": {
"Test\\Hal\\": "tests/"
}
},
"require": {
"php": ">=5.5",
"ext-dom": "*",
"ext-tokenizer": "*",
"nikic/php-parser": "^3|^4"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14",
"sebastian/comparator": ">=1.2.3",
"squizlabs/php_codesniffer": "^3.5",
"symfony/dom-crawler": "^3.0 || ^4.0 || ^5.0"
"nikic/php-parser": "^3|^4|^5"
},
"bin": [
"bin/phpmetrics"
],
"config": {
"sort-packages": true
},
"require-dev": {
"phpunit/phpunit": "*"
}
}
6 changes: 6 additions & 0 deletions craft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
php-version: 8.4
extensions: "apcu,phar,curl,dom,fileinfo,filter,intl,mbstring,mysqlnd,openssl,tokenizer,zlib"
sapi: micro
build-options:
with-upx-pack: true
prefer-pre-built: true
21 changes: 21 additions & 0 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ Then, in order to run the test suite:

Thanks for your help.

## Why the code is so old?

### Philosophy

PhpMetrics has several goals:
+ be stable
+ be performant
+ run on the **maximum of PHP versions** (PHP 5.3 to PHP 8.4)
+ be installable everywhere, **without dependency conflicts**

For these reasons, the code of PhpMetrics is intentionally written in "legacy" PHP.

### Dependencies

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.

For these reasons, PhpMetrics comes with the minimum of dependencies. Only the dependency on `nikic/php-parser` is accepted.

No Pull Request that modifies the `require` block will be accepted.


## Releasing

Please NEVER tag manually.
Expand Down
93 changes: 0 additions & 93 deletions phpcs.xml.dist

This file was deleted.

Loading