Skip to content

Commit 3404c58

Browse files
authored
Merge pull request #10 from TotalWipeOut/master
PHP version and other upgrades
2 parents bea4e1e + a7efe8f commit 3404c58

21 files changed

+400
-155
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.DS_Store
22
.idea
33
vendor
4+
.phpunit.cache
5+
coverage.clover

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tools:
2525
php_code_coverage: true
2626
php_code_sniffer:
2727
config:
28-
standard: PSR2
28+
standard: PSR12
2929
filter:
3030
paths: ['src']
3131
php_loc:

.styleci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
preset: psr2
1+
preset: psr12

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
language: php
22

3-
dist: trusty
3+
dist: xenial
44

55
sudo: false
66

77
php:
8-
- 5.6
9-
- 7.0
10-
- 7.1
11-
- 7.2
8+
- 7.3
9+
- 7.4
10+
- 8.0
1211
- nightly
1312

1413
matrix:
1514
allow_failures:
1615
- php: nightly
1716

1817
before_script:
18+
- wget https://scrutinizer-ci.com/ocular.phar
1919
- composer update --no-interaction
2020

2121
script:
22-
- vendor/bin/phpunit --stop-on-failure
22+
- XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover=coverage.clover --stop-on-failure
23+
- if [ -f coverage.clover ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;

bin/phpcs-diff

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@
88
*/
99

1010
if (is_file(__DIR__ . '/../../../autoload.php')) {
11-
include_once __DIR__ . '/../../../autoload.php';
11+
$autoload = __DIR__ . '/../../../autoload.php';
1212
} elseif (is_file(__DIR__ . '/../autoload.php')) {
13-
include_once __DIR__ . '/../autoload.php';
13+
$autoload = __DIR__ . '/../autoload.php';
14+
} elseif (is_file(__DIR__ . '/../vendor/autoload.php')) {
15+
$autoload = __DIR__ . '/../vendor/autoload.php';
16+
}
17+
18+
if (isset($autoload)) {
19+
require $autoload;
1420
} else {
15-
include_once 'vendor/autoload.php';
21+
echo 'Can not find autoloader, did you run composer? ' . __DIR__;
22+
die(1);
1623
}
1724

1825
$climate = new League\CLImate\CLImate();

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
"name": "olivertappin/phpcs-diff",
33
"description": "Detects violations of a defined coding standard based on a git diff.",
44
"require": {
5-
"php": "^5.6|^7.0",
6-
"squizlabs/php_codesniffer": "*",
5+
"php": "^7.3 || ^8.0",
6+
"ext-json": "*",
7+
"ext-gettext": "*",
8+
"squizlabs/php_codesniffer": "^3.5.7",
79
"league/climate": "^3.4"
810
},
911
"require-dev": {
10-
"phpunit/phpunit": "^5.7.16"
12+
"phpunit/phpunit": "^7.5.20 || ^8.5.21 || ^9.5.10",
13+
"phpunit/php-code-coverage": "^9.2"
1114
},
1215
"autoload": {
1316
"psr-4": {

phpunit.xml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
>
5+
cacheResultFile=".phpunit.cache/test-results"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="true"
8+
beStrictAboutCoversAnnotation="true"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
convertDeprecationsToExceptions="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
verbose="true">
1215
<testsuites>
13-
<testsuite name="Package Test Suite">
14-
<directory suffix=".php">./tests/</directory>
16+
<testsuite name="default">
17+
<directory>tests</directory>
1518
</testsuite>
1619
</testsuites>
20+
21+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22+
processUncoveredFiles="true">
23+
<include>
24+
<directory suffix=".php">src</directory>
25+
</include>
26+
</coverage>
1727
</phpunit>

src/Filter/Filter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(array $rules, array $unfilteredData)
5151
/**
5252
* @return $this
5353
*/
54-
public function filter()
54+
public function filter(): Filter
5555
{
5656
foreach ($this->unfilteredData as $key => $item) {
5757
foreach ($this->rules as $rule) {
@@ -70,15 +70,15 @@ public function filter()
7070
/**
7171
* @return array
7272
*/
73-
public function getFilteredData()
73+
public function getFilteredData(): array
7474
{
7575
return $this->filteredData;
7676
}
7777

7878
/**
7979
* @return array
8080
*/
81-
public function getContaminatedData()
81+
public function getContaminatedData(): array
8282
{
8383
return $this->contaminatedData;
8484
}

src/Filter/Rule/FileRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace PhpcsDiff\Filter\Rule;
44

55
use PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException;
6+
use PhpcsDiff\Filter\Rule\Exception\RuleException;
67
use PhpcsDiff\Filter\Rule\Exception\RuntimeException;
78

89
class FileRule implements RuleInterface
910
{
1011
/**
1112
* @param mixed $data
12-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
13+
* @throws RuleException
1314
*/
1415
public function __invoke($data)
1516
{

src/Filter/Rule/HasMessagesRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace PhpcsDiff\Filter\Rule;
44

55
use PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException;
6+
use PhpcsDiff\Filter\Rule\Exception\RuleException;
67

78
class HasMessagesRule implements RuleInterface
89
{
910
/**
1011
* @param mixed $data
11-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
12+
* @throws RuleException
1213
*/
1314
public function __invoke($data)
1415
{

0 commit comments

Comments
 (0)