Skip to content

Commit 1f17809

Browse files
authored
Drop support for PHP < 7.2
Merge pull request #182 from Brain-WP/feature/162-drop-support-for-php-lt-7.2
2 parents f5967ba + 2ae2acd commit 1f17809

File tree

14 files changed

+40
-194
lines changed

14 files changed

+40
-194
lines changed

.github/workflows/php-qa.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
strategy:
5353
matrix:
54-
php: ['5.6', '7.0', '7.4', '8.0', '8.5', 'nightly']
54+
php: ['7.2', '7.4', '8.0', '8.5', 'nightly']
5555

5656
name: "Lint: PHP ${{ matrix.php }}"
5757

@@ -87,7 +87,7 @@ jobs:
8787

8888
strategy:
8989
matrix:
90-
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
90+
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
9191
dependencies: ['lowest', 'highest']
9292

9393
continue-on-error: ${{ matrix.php == '8.6' }}
@@ -126,16 +126,16 @@ jobs:
126126
run: ./vendor/bin/phpunit --migrate-configuration
127127

128128
- name: Run unit tests (without code coverage)
129-
if: ${{ matrix.php != '7.4' || matrix.dependencies != 'highest' || github.event.repository.fork == true }}
129+
if: ${{ matrix.php != '8.1' || matrix.dependencies != 'highest' || github.event.repository.fork == true }}
130130
run: ./vendor/bin/phpunit
131131

132132
- name: Run unit tests with code coverage
133-
if: ${{ matrix.php == '7.4' && matrix.dependencies == 'highest' && github.event.repository.fork == false }}
133+
if: ${{ matrix.php == '8.1' && matrix.dependencies == 'highest' && github.event.repository.fork == false }}
134134
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml
135135

136136
- name: Update codecov.io
137137
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
138-
if: ${{ matrix.php == '7.4' && matrix.dependencies == 'highest' && github.event.repository.fork == false }} # upload coverage once is enough
138+
if: ${{ matrix.php == '8.1' && matrix.dependencies == 'highest' && github.event.repository.fork == false }} # upload coverage once is enough
139139
env:
140140
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
141141
with:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ It provides **two set of helpers**:
1414

1515
## Requirements
1616

17-
* PHP 5.6+
17+
* PHP 7.2+
1818
* [Composer](https://getcomposer.org/) to install
1919

2020
Via Composer following packages are required:
@@ -24,7 +24,7 @@ Via Composer following packages are required:
2424

2525
When installed for development, following packages are also required:
2626

27-
* [phpunit/phpunit](https://packagist.org/packages/phpunit/phpunit) version 5.7 or higher \(BSD-3-Clause\)
27+
* [phpunit/phpunit](https://packagist.org/packages/phpunit/phpunit) version 8.5 or higher \(BSD-3-Clause\)
2828

2929
## License
3030

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
},
2828
"license": "MIT",
2929
"require": {
30-
"php": ">=5.6.0",
30+
"php": ">=7.2.0",
3131
"mockery/mockery": "~1.3.6 || ~1.4.4 || ~1.5.1 || ^1.6.10",
32-
"antecedent/patchwork": "^2.1.17"
32+
"antecedent/patchwork": "^2.2.3"
3333
},
3434
"require-dev": {
35-
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.49 || ^9.6.30",
35+
"phpunit/phpunit": "^8.5.52 || ^9.6.34",
3636
"phpcompatibility/php-compatibility": "^9.3.0",
3737
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0"
3838
},
@@ -71,7 +71,7 @@
7171
},
7272
"scripts" : {
7373
"phpcompat": [
74-
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -ps . --standard=PHPCompatibility --ignore=*/vendor/* --parallel=10 --extensions=php --basepath=./ --runtime-set testVersion 5.6-"
74+
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -ps . --standard=PHPCompatibility --ignore=*/vendor/* --parallel=10 --extensions=php --basepath=./ --runtime-set testVersion 7.2-"
7575
]
7676
}
7777
}

docs/functions-testing-tools/functions-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ After Brain Monkey is part of the project \(see _Getting Started / Installation_
2929
Let's take PHPUnit as example, the average test case class that uses Brain Monkey would be something like:
3030

3131
```php
32-
use PHPUnit_Framework_TestCase;
32+
use PHPUnit\Framework\TestCase;
3333
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
3434
use Brain\Monkey;
3535

36-
class MyTestCase extends PHPUnit_Framework_TestCase
36+
class MyTestCase extends TestCase
3737
{
3838
// Adds Mockery expectations to the PHPUnit assertions count.
3939
use MockeryPHPUnitIntegration;
@@ -46,7 +46,7 @@ class MyTestCase extends PHPUnit_Framework_TestCase
4646
}
4747
```
4848

49-
After that for all test classes can extend this class instead of directly extending `PHPUnit_Framework_TestCase`.
49+
After that, all test classes can extend this class instead of directly extending `PHPUnit\Framework\TestCase`.
5050

5151
That's all. Again, I used PHPUnit for the example, but any testing framework can be used.
5252

docs/general/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
To install Brain Monkey you need:
44

5-
* PHP 5.6+
5+
* PHP 7.2+
66
* [Composer](https://getcomposer.org)
77

88
Brain Monkey is available on Packagist, so the only thing you need to do is to add it as a dependency for your project.

docs/what-and-why.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ All the rest is joy.
4848

4949
### PHP versions compatibility
5050

51-
Currently, Brain Monkey supports PHP 5.6+.
51+
Currently, Brain Monkey supports PHP 7.2+.
5252

docs/wordpress-specific-tools/wordpress-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ These two functions are:
2222
PHPUnit users will probably want to add these methods to a custom test case class:
2323

2424
```php
25-
use PHPUnit_Framework_TestCase;
25+
use PHPUnit\Framework\TestCase;
2626
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
2727
use Brain\Monkey;
2828

29-
class MyTestCase extends PHPUnit_Framework_TestCase {
29+
class MyTestCase extends TestCase {
3030

3131
// Adds Mockery expectations to the PHPUnit assertions count.
3232
use MockeryPHPUnitIntegration;
@@ -43,7 +43,7 @@ class MyTestCase extends PHPUnit_Framework_TestCase {
4343
}
4444
```
4545

46-
and then extend various test classes from it instead of directly extend `PHPUnit_Framework_TestCase`.
46+
and then extend various test classes from it instead of directly extending `PHPUnit\Framework\TestCase`.
4747

4848
That's all. You are ready to use all Brain Monkey features.
4949

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
2+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
33
beStrictAboutTestsThatDoNotTestAnything="false"
44
bootstrap="tests/bootstrap.php"
55
colors="true"

src/Name/ClosureParamStringForm.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,13 @@ public static function fromString($param)
7777
public static function fromReflectionParameter(\ReflectionParameter $parameter)
7878
{
7979
$type = '';
80-
if (PHP_MAJOR_VERSION >= 7) {
81-
if ($parameter->hasType()) {
82-
$type = $parameter->getType();
83-
if ($type instanceof \ReflectionNamedType) {
84-
// PHP >= 7.1.
85-
$type = $type->getName();
86-
}
87-
88-
// In PHP 7.0 the ReflectionType::__toString() method will retrieve the type.
89-
$type = ltrim($type, '\\');
90-
}
91-
} else {
92-
preg_match(self::REFLECTION_PARAM_PATTERN, $parameter->__toString(), $matches);
93-
if (isset($matches[1])) {
94-
$type = $matches[1];
80+
if ($parameter->hasType()) {
81+
$type = $parameter->getType();
82+
if ($type instanceof \ReflectionNamedType) {
83+
$type = $type->getName();
9584
}
85+
86+
$type = ltrim($type, '\\');
9687
}
9788

9889
return new static($parameter->getName(), $type, $parameter->isVariadic());

tests/bootstrap.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,3 @@
1616
echo 'Autoload file not found. Please run `composer install`.';
1717
die(1);
1818
}
19-
20-
// PHPUnit cross version compatibility.
21-
if (class_exists('PHPUnit_Framework_Error') === true
22-
&& class_exists('PHPUnit\Framework\Error\Error') === false
23-
) {
24-
class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error');
25-
}

0 commit comments

Comments
 (0)