Skip to content

Commit ee6a471

Browse files
committed
Remove support for PHP < 7.3, style now PSR-12
1 parent bea4e1e commit ee6a471

File tree

10 files changed

+88
-78
lines changed

10 files changed

+88
-78
lines changed

.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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
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:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
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",
5+
"php": "^7.3 || ^8.0",
66
"squizlabs/php_codesniffer": "*",
77
"league/climate": "^3.4"
88
},
99
"require-dev": {
10-
"phpunit/phpunit": "^5.7.16"
10+
"phpunit/phpunit": "^8.5.21"
1111
},
1212
"autoload": {
1313
"psr-4": {

tests/Filter/FilterTest.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
namespace PhpcsDiff\Tests\Filter;
44

5+
use PhpcsDiff\Filter\Exception\FilterException;
6+
use PhpcsDiff\Filter\Exception\InvalidRuleException;
57
use PhpcsDiff\Filter\Filter;
68
use PhpcsDiff\Filter\Rule\FileRule;
79
use PhpcsDiff\Tests\TestBase;
810

911
class FilterTest extends TestBase
1012
{
11-
protected function setUp()
13+
protected function setUp(): void
1214
{
1315
parent::setUp();
1416

@@ -21,7 +23,7 @@ protected function setUp()
2123
fclose($handle);
2224
}
2325

24-
protected function tearDown()
26+
protected function tearDown(): void
2527
{
2628
parent::tearDown();
2729

@@ -35,7 +37,7 @@ protected function tearDown()
3537
/**
3638
* @return array
3739
*/
38-
public function unfilteredDataProvider()
40+
public function unfilteredDataProvider(): array
3941
{
4042
return [
4143
[
@@ -101,12 +103,12 @@ public function unfilteredDataProvider()
101103

102104
/**
103105
* @covers Filter::__construct
104-
* @expectedException \PhpcsDiff\Filter\Exception\InvalidRuleException
105-
* @expectedException \PhpcsDiff\Filter\Exception\FilterException
106-
* @throws \PhpcsDiff\Filter\Exception\FilterException
106+
* @throws FilterException
107107
*/
108-
public function testInvalidRule()
108+
public function testInvalidRule(): void
109109
{
110+
$this->expectException(FilterException::class);
111+
$this->expectException(InvalidRuleException::class);
110112
new Filter(
111113
[
112114
new \stdClass(),
@@ -121,9 +123,9 @@ public function testInvalidRule()
121123

122124
/**
123125
* @covers Filter::filter
124-
* @throws \PhpcsDiff\Filter\Exception\FilterException
126+
* @throws FilterException
125127
*/
126-
public function testFilterInstance()
128+
public function testFilterInstance(): void
127129
{
128130
$filter = (new Filter(
129131
[
@@ -148,9 +150,9 @@ public function testFilterInstance()
148150
* @param array $unfilteredData
149151
* @param array $filteredData
150152
* @param array $contaminatedData
151-
* @throws \PhpcsDiff\Filter\Exception\FilterException
153+
* @throws FilterException
152154
*/
153-
public function testFileFilter(array $unfilteredData, array $filteredData, array $contaminatedData)
155+
public function testFileFilter(array $unfilteredData, array $filteredData, array $contaminatedData): void
154156
{
155157
$filter = (new Filter(
156158
[

tests/Filter/Rule/FileRuleTest.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
namespace PhpcsDiff\Tests\Filter\Rule;
44

5+
use PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException;
6+
use PhpcsDiff\Filter\Rule\Exception\RuleException;
7+
use PhpcsDiff\Filter\Rule\Exception\RuntimeException;
58
use PhpcsDiff\Filter\Rule\FileRule;
69
use PhpcsDiff\Tests\TestBase;
710

811
class FileRuleTest extends TestBase
912
{
10-
public function setUp()
13+
public function setUp(): void
1114
{
1215
parent::setUp();
1316

@@ -18,7 +21,7 @@ public function setUp()
1821
fclose(fopen('test.txt', 'wb'));
1922
}
2023

21-
public function tearDown()
24+
public function tearDown(): void
2225
{
2326
parent::tearDown();
2427

@@ -32,46 +35,46 @@ public function tearDown()
3235

3336
/**
3437
* @covers FileRule::__invoke
35-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException
36-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
37-
* @expectedExceptionMessage The data argument provided is not a string.
38-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
38+
* @throws RuleException
3939
*/
4040
public function testNonString()
4141
{
42+
$this->expectExceptionMessage("The data argument provided is not a string.");
43+
$this->expectException(RuleException::class);
44+
$this->expectException(InvalidArgumentException::class);
4245
$rule = new FileRule();
4346
$rule(null);
4447
}
4548

4649
/**
4750
* @covers FileRule::__invoke
48-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuntimeException
49-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
50-
* @expectedExceptionMessage The file provided does not exist.
51-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
51+
* @throws RuleException
5252
*/
5353
public function testNonExistentFile()
5454
{
55+
$this->expectExceptionMessage("The file provided does not exist.");
56+
$this->expectException(RuleException::class);
57+
$this->expectException(RuntimeException::class);
5558
$rule = new FileRule();
5659
$rule('');
5760
}
5861

5962
/**
6063
* @covers FileRule::__invoke
61-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuntimeException
62-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
63-
* @expectedExceptionMessage The file provided is not a regular file.
64-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
64+
* @throws RuleException
6565
*/
6666
public function testNonFile()
6767
{
68+
$this->expectException(RuntimeException::class);
69+
$this->expectException(RuleException::class);
70+
$this->expectExceptionMessage("The file provided is not a regular file.");
6871
$rule = new FileRule();
6972
$rule('test');
7073
}
7174

7275
/**
7376
* @covers PhpFileRule::__invoke
74-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
77+
* @throws RuleException
7578
*/
7679
public function testFile()
7780
{

tests/Filter/Rule/HasMessagesRuleTest.php

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

33
namespace PhpcsDiff\Tests\Filter\Rule;
44

5+
use PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException;
6+
use PhpcsDiff\Filter\Rule\Exception\RuleException;
57
use PhpcsDiff\Filter\Rule\FileRule;
68
use PhpcsDiff\Filter\Rule\HasMessagesRule;
79
use PhpcsDiff\Tests\TestBase;
@@ -10,48 +12,48 @@ class HasMessagesRuleTest extends TestBase
1012
{
1113
/**
1214
* @covers HasMessagesRule::__invoke
13-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException
14-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
15-
* @expectedExceptionMessage The data argument provided has no messages.
16-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
15+
* @throws RuleException
1716
*/
18-
public function testNoMessages()
17+
public function testNoMessages(): void
1918
{
19+
$this->expectException(InvalidArgumentException::class);
20+
$this->expectException(RuleException::class);
21+
$this->expectExceptionMessage("The data argument provided has no messages.");
2022
$rule = new HasMessagesRule();
2123
$rule([]);
2224
}
2325

2426
/**
2527
* @covers HasMessagesRule::__invoke
26-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException
27-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
28-
* @expectedExceptionMessage The data argument provided has no messages.
29-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
28+
* @throws RuleException
3029
*/
31-
public function testEmptyMessages()
30+
public function testEmptyMessages(): void
3231
{
32+
$this->expectException(InvalidArgumentException::class);
33+
$this->expectException(RuleException::class);
34+
$this->expectExceptionMessage("The data argument provided has no messages.");
3335
$rule = new HasMessagesRule();
3436
$rule(['messages' => []]);
3537
}
3638

3739
/**
3840
* @covers HasMessagesRule::__invoke
39-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\InvalidArgumentException
40-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
41-
* @expectedExceptionMessage The data argument provided has no messages.
42-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
41+
* @throws RuleException
4342
*/
44-
public function testNullMessages()
43+
public function testNullMessages(): void
4544
{
45+
$this->expectException(InvalidArgumentException::class);
46+
$this->expectException(RuleException::class);
47+
$this->expectExceptionMessage("The data argument provided has no messages.");
4648
$rule = new HasMessagesRule();
4749
$rule(['messages' => null]);
4850
}
4951

5052
/**
5153
* @covers FileRule::__invoke
52-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
54+
* @throws RuleException
5355
*/
54-
public function testMessages()
56+
public function testMessages(): void
5557
{
5658
$rule = new HasMessagesRule();
5759
$actual = $rule(['messages' => ['message']]);

tests/Filter/Rule/PhpFileRuleTest.php

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

33
namespace PhpcsDiff\Tests\Filter\Rule;
44

5+
use PhpcsDiff\Filter\Rule\Exception\RuleException;
6+
use PhpcsDiff\Filter\Rule\Exception\RuntimeException;
57
use PhpcsDiff\Filter\Rule\PhpFileRule;
68
use PhpcsDiff\Tests\TestBase;
79

810
class PhpFileRuleTest extends TestBase
911
{
1012
protected $handle;
1113

12-
public function setUp()
14+
public function setUp(): void
1315
{
1416
parent::setUp();
1517

@@ -25,7 +27,7 @@ public function setUp()
2527
fclose($handle);
2628
}
2729

28-
public function tearDown()
30+
public function tearDown(): void
2931
{
3032
parent::tearDown();
3133

@@ -41,35 +43,35 @@ public function tearDown()
4143

4244
/**
4345
* @covers PhpFileRule::__invoke
44-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuntimeException
45-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
46-
* @expectedExceptionMessage The file provided does not have a .php extension.
47-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
46+
* @throws RuleException
4847
*/
49-
public function testNonPhpFile()
48+
public function testNonPhpFile(): void
5049
{
50+
$this->expectException(RuntimeException::class);
51+
$this->expectException(RuleException::class);
52+
$this->expectExceptionMessage("The file provided does not have a .php extension.");
5153
$rule = new PhpFileRule();
5254
$rule('test.txt');
5355
}
5456

5557
/**
5658
* @covers PhpFileRule::__invoke
57-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuntimeException
58-
* @expectedException \PhpcsDiff\Filter\Rule\Exception\RuleException
59-
* @expectedExceptionMessage The file provided does not have the text/x-php mime type.
60-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
59+
* @throws RuleException
6160
*/
62-
public function testIncorrectMimeType()
61+
public function testIncorrectMimeType(): void
6362
{
63+
$this->expectException(RuntimeException::class);
64+
$this->expectException(RuleException::class);
65+
$this->expectExceptionMessage("The file provided does not have the text/x-php mime type.");
6466
$rule = new PhpFileRule();
6567
$rule('image.php');
6668
}
6769

6870
/**
6971
* @covers PhpFileRule::__invoke
70-
* @throws \PhpcsDiff\Filter\Rule\Exception\RuleException
72+
* @throws RuleException
7173
*/
72-
public function testPhpFile()
74+
public function testPhpFile(): void
7375
{
7476
$rule = new PhpFileRule();
7577
$actual = $rule('test.php');

tests/Mapper/PhpcsViolationsMapperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PhpcsViolationsMapperTest extends TestBase
1111
/**
1212
* @covers PhpcsOutputMapper::__construct
1313
*/
14-
public function testMapperInstance()
14+
public function testMapperInstance(): void
1515
{
1616
$mapper = new PhpcsViolationsMapper([], '');
1717

@@ -21,7 +21,7 @@ public function testMapperInstance()
2121
/**
2222
* @covers PhpcsOutputMapper::map
2323
*/
24-
public function testEmptyMapper()
24+
public function testEmptyMapper(): void
2525
{
2626
$mappedData = (new PhpcsViolationsMapper([], ''))->map([]);
2727

0 commit comments

Comments
 (0)