Skip to content

Commit 4c80c55

Browse files
authored
Add PHP 8.0 support (#5)
* Add PHP 8.0 support * Fix phpcs sniffs * Configure php compat sniff
1 parent 8e79941 commit 4c80c55

File tree

5 files changed

+63
-69
lines changed

5 files changed

+63
-69
lines changed

.circleci/config.yml

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
1-
version: 2
1+
version: 2.1
2+
3+
executors:
4+
php74:
5+
docker:
6+
- image: skpr/php-cli:7.4-1.x
7+
php80:
8+
docker:
9+
- image: skpr/php-cli:8.0-1.x
210

311
workflows:
4-
version: 2
512
build:
613
jobs:
7-
- build_lowest
8-
- build_highest
9-
10-
defaults: &defaults
11-
docker:
12-
- image: previousnext/php-apache:7.3-3.x-dev
13-
working_directory: /data
14-
steps:
15-
- checkout
16-
- restore_cache:
17-
keys:
18-
- deps-{{ arch }}
19-
- run:
20-
name: "Install Dependencies"
21-
command: composer update --prefer-dist --no-progress --no-suggest --no-interaction ${PREFER_LOWEST}
22-
- save_cache:
23-
key: deps-{{ arch }}
24-
paths:
25-
- vendor
26-
- run:
27-
name: "Lint"
28-
command: ./bin/phpcs
29-
- run:
30-
name: "Test"
31-
command: |
32-
mkdir -p ~/phpunit
33-
./bin/phpunit --testsuite unit --log-junit ~/phpunit/phpunit.xml
34-
- store_test_results:
35-
path: ~/phpunit
36-
- store_artifacts:
37-
path: ~/phpunit
14+
- build:
15+
matrix:
16+
parameters:
17+
php: ["php74", "php80"]
18+
composer-opts: ["", "--prefer-lowest"]
3819

3920
jobs:
40-
build_lowest:
41-
<<: *defaults
42-
docker:
43-
- image: previousnext/php-apache:7.1-3.x-dev
44-
45-
environment:
46-
- PREFER_LOWEST: --prefer-lowest
47-
build_highest:
48-
<<: *defaults
49-
environment:
50-
- PREFER_LOWEST: ''
21+
build:
22+
parameters:
23+
php:
24+
type: executor
25+
composer-opts:
26+
type: string
27+
executor: << parameters.php >>
28+
working_directory: /data
29+
steps:
30+
- checkout
31+
- restore_cache:
32+
keys:
33+
- deps-{{ arch }}
34+
- run:
35+
name: "Install Dependencies"
36+
command: composer2 update --prefer-dist --no-progress --no-suggest --no-interaction << parameters.composer-opts >>
37+
- save_cache:
38+
key: deps-{{ arch }}
39+
paths:
40+
- vendor
41+
- run:
42+
name: "Lint"
43+
command: ./bin/phpcs --runtime-set testVersion 8.0-
44+
- run:
45+
name: "Test"
46+
command: |
47+
mkdir -p ~/phpunit
48+
./bin/phpunit --testsuite unit --log-junit ~/phpunit/phpunit.xml
49+
- store_test_results:
50+
path: ~/phpunit
51+
- store_artifacts:
52+
path: ~/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/bin
22
/vendor
3+
/.phpunit.result.cache
34
/composer.lock

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
}
1414
],
1515
"require": {
16-
"php": "^7.1",
16+
"php": "^7.2||^8.0",
1717
"phpunit/phpunit": "^6.4||^7.0||^8.0",
1818
"symfony/console": "^3.4||^4.4"
1919
},
2020
"require-dev": {
21-
"drupal/coder": ">=8.2.12"
21+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
22+
"drupal/coder": "~8.3.12",
23+
"phpcompatibility/php-compatibility": "^9.3"
2224
},
2325
"autoload": {
2426
"psr-4": {"PhpUnitFinder\\": "src/"}

phpcs.xml

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<ruleset name="phpunit-finder">
3-
<description>PHP CodeSniffer configuration for PHPUnit Finder</description>
4-
<!-- folders to scan -->
2+
<ruleset name="pnx-project">
3+
<description>PHP Codesniffer configuration.</description>
54
<file>./src</file>
6-
<file>./tests</file>
7-
<!-- extensions to scan -->
5+
<exclude-pattern>./tests/bootstrap.php</exclude-pattern>
86
<arg name="extensions" value="php"/>
9-
<!-- additional arguments -->
107
<arg name="report" value="full"/>
11-
<!-- inherit from coder -->
12-
<rule ref="./vendor/drupal/coder/coder_sniffer/Drupal"/>
13-
<!-- Additional detailed sniff configuration -->
14-
<!-- You can determine sniff names by running with -s flag -->
15-
<!-- Example 1 - ignore Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
16-
<rule ref="Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps">
17-
<severity>0</severity>
18-
</rule>
19-
// End example 1 -->
20-
<!-- Example 2 - ignore rule for specific files
21-
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
22-
<exclude-pattern>OfferNormalizerTrait.php</exclude-pattern>
23-
<exclude-pattern>TimeOfUseValidationTrait.php</exclude-pattern>
24-
</rule>
25-
// End example 2 -->
8+
<arg name="colors"/>
9+
<arg value="sp"/>
10+
<rule ref="Drupal">
11+
<!-- ignore for now -->
12+
<exclude name="Drupal.Classes.UseGlobalClass.RedundantUseStatement" />
13+
</rule>
14+
<rule ref="PHPCompatibility"/>
15+
<config name="testVersion" value="7.3-"/>
2616
</ruleset>

src/FinderCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PHPUnit\Framework\TestCase;
66
use PHPUnit\Util\Configuration;
7-
use ReflectionClass;
87
use Symfony\Component\Console\Command\Command;
98
use Symfony\Component\Console\Input\InputArgument;
109
use Symfony\Component\Console\Input\InputInterface;
@@ -43,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
4342
$suite = $config->getTestSuiteConfiguration($suiteName);
4443
foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) {
4544
if ($test instanceof TestCase) {
46-
$testFilenames[] = ((new ReflectionClass($test))->getFileName());
45+
$testFilenames[] = ((new \ReflectionClass($test))->getFileName());
4746
}
4847
}
4948
}

0 commit comments

Comments
 (0)