Skip to content
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

[Tentative] Drop PHP < 8 #1054

Merged
merged 20 commits into from
Apr 29, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
php: [7.4]
php: [8.3]
dependency-version: [prefer-stable]

name: Build website
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

strategy:
matrix:
php: [7.4]
php: [8.3]
dependency-version: [prefer-stable]

name: Codestyle check
Expand Down
30 changes: 5 additions & 25 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,20 @@ jobs:
tools: composer:v2
coverage: xdebug

- name: Cache library packages
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-coverage-${{ matrix.php }}-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-coverage-${{ matrix.php }}-

- name: Cache test packages
id: composer-test-cache
uses: actions/cache@v3
with:
path: src/test/vendor
key: ${{ runner.os }}-coverage-test-${{ matrix.php }}-${{ hashFiles('src/test/composer.json') }}
restore-keys: ${{ runner.os }}-coverage-test-${{ matrix.php }}-

- name: Upgrade PHPUnit
run: |
composer require symfony/config:^6.4 --no-update --no-interaction --dev
cd src/test && composer require phpunit/phpunit:^5.7.27 --no-update --no-interaction --dev
key: coverage-${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependency-version }}-${{ hashFiles('**/composer.json') }}

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer update --no-progress --prefer-stable --prefer-dist --no-progress --ignore-platform-req=php+

- name: Install test dependencies
if: steps.composer-test-cache.outputs.cache-hit != 'true'
run: cd src/test && composer update --no-progress --prefer-dist --prefer-stable --ignore-platform-req=php+

- name: Fix PHP compatibility
run: php src/test/php/fix-php-compatibility.php
run: |
composer update --prefer-dist --no-progress --${{ matrix.dependency-version }} --ignore-platform-req=php

- name: Execute Unit Tests
run: src/test/vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Archive code coverage results
uses: codecov/codecov-action@v3
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/generate_phar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ on:
pull_request:
branches: [ '**' ]
release:
types:
- created
types: [ 'created', 'published' ]

jobs:
php-tests:
Expand All @@ -18,8 +17,8 @@ jobs:

strategy:
matrix:
php: [5.4]
dependency-version: [prefer-stable]
php: [ '8.0' ]
dependency-version: [ 'prefer-stable' ]

name: Release phar

Expand Down Expand Up @@ -49,9 +48,6 @@ jobs:
- name: Git submodules
run: git submodule update --init

- name: Fix PHP compatibility
run: php src/phar/compatibility.php

- name: Ant
run: ant package -D-phar:filename=./phpmd.phar && ./phpmd.phar --version

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4' ]
php: [ '8.3' ]
setup: [ 'stable' ]
phpstan: [1.10.25]
phpstan: [ '1.10.25' ]

name: PHP ${{ matrix.php }} - ${{ matrix.setup }} - ${{ matrix.phpstan }}

Expand Down
32 changes: 4 additions & 28 deletions .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
php: [ 8.3 ]
symfony: [ 2, 3, 4, 5, 6, 7 ]
symfony: [ 5, 6, 7 ]

name: Symfony ${{ matrix.symfony }}

Expand All @@ -37,21 +37,12 @@ jobs:
tools: composer:v2
coverage: none

- name: Cache library packages
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-

- name: Cache test packages
id: composer-test-cache
uses: actions/cache@v3
with:
path: src/test/vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-symfony-test-${{ matrix.symfony }}-${{ hashFiles('src/test/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-symfony-test-${{ matrix.symfony }}-
key: ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-${{ hashFiles('**/composer.json') }}

- name: Set Symfony version
run: |
Expand All @@ -60,24 +51,9 @@ jobs:
symfony/filesystem:^${{ matrix.symfony }} \
symfony/config:^${{ matrix.symfony }}

- name: Upgrade PHPUnit
if: matrix.php >= 7.2
run: cd src/test && composer require phpunit/phpunit:^5.7.27 --no-update --no-interaction --dev

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer update --prefer-dist --no-progress --prefer-stable --ignore-platform-req=php+

- name: Install test dependencies
if: steps.composer-test-cache.outputs.cache-hit != 'true'
run: cd src/test && composer update --prefer-dist --no-progress --prefer-stable --ignore-platform-req=php+

- name: Fix PHP compatibility
if: steps.composer-test-cache.outputs.cache-hit != 'true'
run: php src/test/php/fix-php-compatibility.php

- name: Check Symfony version
run: php src/test/symfony-version.php

- name: Run test suite
run: src/test/vendor/bin/phpunit -v
run: vendor/bin/phpunit --display-deprecations
4 changes: 2 additions & 2 deletions .github/workflows/tests-with-composer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-php-composer-${{ matrix.setup }}-
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.setup }}-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
Expand Down
33 changes: 3 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ jobs:

strategy:
matrix:
php: [ 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ]
setup: [ lowest, stable ]
exclude:
- setup: lowest
php: 7.2
- setup: lowest
php: 7.3
- setup: lowest
php: 7.4

name: PHP ${{ matrix.php }} - prefer-${{ matrix.setup }}

Expand All @@ -42,36 +35,16 @@ jobs:
coverage: none
tools: composer:v2

- name: Cache library packages
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.setup }}-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.setup }}-

- name: Cache test packages
id: composer-test-cache
uses: actions/cache@v3
with:
path: src/test/vendor
key: ${{ runner.os }}-php-test-${{ matrix.php }}-${{ matrix.setup }}-${{ hashFiles('src/test/composer.json') }}
restore-keys: ${{ runner.os }}-php-test-${{ matrix.php }}-${{ matrix.setup }}-

- name: Upgrade PHPUnit
if: matrix.php >= 7.2
run: cd src/test && composer require phpunit/phpunit:^5.7.27 --no-update --no-interaction --dev

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer update --no-progress --prefer-${{ matrix.setup }} --prefer-dist --no-progress --ignore-platform-req=php+

- name: Install test dependencies
if: steps.composer-test-cache.outputs.cache-hit != 'true'
run: cd src/test && composer update --no-progress --prefer-dist --prefer-stable --ignore-platform-req=php+

- name: Fix PHP compatibility
run: php src/test/php/fix-php-compatibility.php

- name: Execute Unit Tests
run: src/test/vendor/bin/phpunit -v
run: vendor/bin/phpunit ${{ matrix.setup != 'lowest' && matrix.php >= 8.1 && '--display-deprecations' || '' }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
/*.xml
composer.lock
vendor
src/test/vendor
dist
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build:
environment:
php:
version: 7.4.0
version: 8.0.0

checks:
php:
Expand Down
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ install:
- ps: Set-Service wuauserv -StartupType Manual
- cinst -y OpenSSL.Light
- SET PATH=C:\Program Files\OpenSSL;%PATH%
- cinst -y php -version 7.1.14
- cd c:\tools\php71
- cinst -y php -version 8.0.30
- cd c:\tools\php80
- copy php.ini-production php.ini
- echo date.timezone="UTC" >> php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- cd C:\projects\phpmd
- SET PATH=C:\tools\php71;%PATH%
- SET PATH=C:\tools\php80;%PATH%
- php -r "readfile('http://getcomposer.org/installer');" | php
- php composer.phar install --prefer-source --no-interaction

Expand Down
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project.stability = stable
# Disable pear support. This cannot be removed as long as setup tool is used
project.pear.uri = pear.example.com

vendor.dir.includes = symfony/**/*,composer/**/*,pdepend/**/*,autoload.php
vendor.dir.includes = psr/**/*,symfony/**/*,composer/**/*,pdepend/**/*,autoload.php
vendor.dir.excludes = symfony/**/Tests/**/*

# Default coding standard
Expand All @@ -19,4 +19,4 @@ project.scm.uri = github.com/${project.name}/${project.name}/commit
# Execute the following command for pdepend profiling
profile.command = ${basedir}/src/bin/phpmd '/opt/Sources/PHP/Flow3/Packages/Framework' xml naming,codesize,unusedcode,design --reportfile pmd.xml

phpunit.package.name = phpunit-4.8.36
phpunit.package.name = phpunit-9.6.15
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<arg line="composer.phar" />
<arg line="config" />
<arg line="platform.php" />
<arg line="5.3.9"/>
<arg line="8.0.0"/>
</exec>
<exec executable="php" failonerror="true">
<arg line="composer.phar" />
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@
},
"minimum-stability": "stable",
"require": {
"php": ">=5.3.9",
"php": "^8.0.0",
"ext-xml": "*",
"composer/xdebug-handler": "^1.0 || ^2.0 || ^3.0",
"composer/xdebug-handler": "^3.0",
"pdepend/pdepend": "^2.16.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.9.2 || ^3.7.2",
"mikey179/vfsstream": "^1.6.8",
"gregwar/rst": "^1.0",
"ext-simplexml": "*",
"ext-json": "*",
"easy-doc/easy-doc": "0.0.0 || ^1.3.2"
"easy-doc/easy-doc": "^1.3.2",
"gregwar/rst": "^1.0",
"mikey179/vfsstream": "^1.6.8",
"phpunit/phpunit": "^9.6.15 || ^10.5.2",
"squizlabs/php_codesniffer": "^3.8.0"
},
"autoload": {
"psr-0": {
Expand All @@ -58,7 +59,7 @@
"src/bin/phpmd"
],
"scripts": {
"test": "php src/test/php/install-test-vendor.php && php src/test/vendor/bin/phpunit --no-coverage",
"test": "phpunit",
"cs-check": "phpcs -p --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1",
"cs-fix": "phpcbf -p --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1",
"build-website": "easy-doc build src/site/config.php --verbose"
Expand Down
28 changes: 17 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?xml version="1.0"?>
<phpunit bootstrap="src/test/php/bootstrap.php">
<testsuites>
<testsuite name="PHPMD AllTests">
<directory suffix="Test.php">src/test/php</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/main/php</directory>
</whitelist>
</filter>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="src/test/php/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
>
<coverage/>
<testsuites>
<testsuite name="PHPMD AllTests">
<directory>src/test/php</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src/main/php</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/bin/phpmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (!ini_get('date.timezone')) {
if (extension_loaded('suhosin') && is_numeric(ini_get('suhosin.memory_limit'))) {
$limit = ini_get('memory_limit');
if (preg_match('(^(\d+)([BKMGT]))', $limit, $match)) {
$shift = array('B' => 0, 'K' => 10, 'M' => 20, 'G' => 30, 'T' => 40);
$shift = ['B' => 0, 'K' => 10, 'M' => 20, 'G' => 30, 'T' => 40];
$limit = ($match[1] * (1 << $shift[$match[2]]));
}
if (ini_get('suhosin.memory_limit') > $limit && $limit > -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/conf/phar_bootstrap.stub
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
define('PHP_PMD_RELEASE', 'phar');

// Disable deprecations as they are not actionable by end users
@set_error_handler(E_ALL ^ (E_USER_DEPRECATED | E_DEPRECATED));
@set_error_handler(null, E_ALL ^ (E_USER_DEPRECATED | E_DEPRECATED));

Phar::mapPhar('${archive.alias}');

Expand Down