Skip to content

Commit b56185b

Browse files
committed
Support PHP 7.4 to 8.5 and WP 6.*
Deprecate PHP 7.2 and 7.6, as well as WP 5.*
1 parent 53d9bab commit b56185b

File tree

7 files changed

+30
-48
lines changed

7 files changed

+30
-48
lines changed

.github/workflows/php-qa.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
steps:
4242

4343
- name: Checkout
44-
uses: actions/checkout@v4
44+
uses: actions/checkout@v6
4545

4646
- name: Setup PHP
4747
uses: shivammathur/setup-php@v2
@@ -71,22 +71,9 @@ jobs:
7171
strategy:
7272
fail-fast: false
7373
matrix:
74-
php-ver: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
75-
wp-ver: [ '5.*', '6.*' ]
74+
php-ver: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
75+
wp-ver: [ '6.0.*', '6.5.*', '6.*' ]
7676
dependency-versions: [ 'highest', 'lowest' ]
77-
exclude:
78-
- php-ver: '8.1'
79-
wp-ver: '5.*'
80-
dependency-versions: 'lowest'
81-
- php-ver: '8.2'
82-
wp-ver: '5.*'
83-
dependency-versions: 'lowest'
84-
- php-ver: '8.3'
85-
wp-ver: '5.*'
86-
- php-ver: '8.4'
87-
wp-ver: '5.*'
88-
- php-ver: '8.4'
89-
dependency-versions: 'lowest'
9077

9178
steps:
9279

@@ -95,7 +82,7 @@ jobs:
9582
run: echo "USE_COVERAGE=yes" >> $GITHUB_ENV
9683

9784
- name: Checkout
98-
uses: actions/checkout@v4
85+
uses: actions/checkout@v6
9986

10087
- name: Setup PHP
10188
uses: shivammathur/setup-php@v2
@@ -104,22 +91,22 @@ jobs:
10491
ini-values: zend.assertions=1, error_reporting=E_ALL, display_errors=On
10592
coverage: ${{ ((env.USE_COVERAGE == 'yes') && 'xdebug') || 'none' }}
10693

107-
- name: Adjust WP version
94+
- name: Adjust dependencies
10895
run: |
10996
composer remove --dev --no-update "roots/wordpress-no-content"
97+
composer remove --dev --no-update "inpsyde/php-coding-standards"
98+
composer remove --dev --no-update "vimeo/psalm"
11099
composer remove --dev --no-update "phpunit/phpunit"
111100
composer require --no-update "roots/wordpress-no-content:${{ matrix.wp-ver }}"
112-
composer require --no-update "phpunit/phpunit:^7.5.20 || ^9.6.4"
101+
composer require --no-update "phpunit/phpunit:^9.6.29"
113102
114103
- name: Install dependencies
115104
uses: ramsey/composer-install@v3
116105
with:
117106
dependency-versions: ${{ matrix.dependency-versions }}
118107

119108
- name: Run unit tests
120-
run: |
121-
./vendor/bin/phpunit --atleast-version 9 && ./vendor/bin/phpunit --migrate-configuration || echo 'Config does not need updates.'
122-
./vendor/bin/phpunit ${{ ((env.USE_COVERAGE == 'yes') && '--coverage-html=coverage-report') || '--no-coverage' }}
109+
run: ./vendor/bin/phpunit ${{ ((env.USE_COVERAGE == 'yes') && '--coverage-html=coverage-report') || '--no-coverage' }}
123110

124111
- name: Upload coverage report
125112
uses: actions/upload-artifact@v4
@@ -134,11 +121,11 @@ jobs:
134121
strategy:
135122
fail-fast: true
136123
matrix:
137-
php-ver: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
124+
php-ver: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
138125
steps:
139126

140127
- name: Checkout
141-
uses: actions/checkout@v4
128+
uses: actions/checkout@v6
142129

143130
- name: Setup PHP
144131
uses: shivammathur/setup-php@v2

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
"source": "https://github.com/wecodemore/wordpress-early-hook"
3232
},
3333
"require": {
34-
"php": ">=7.1 < 8.5"
34+
"php": ">=7.4 <= 8.5"
3535
},
3636
"require-dev": {
37-
"roots/wordpress-no-content": ">=6.1.1",
37+
"roots/wordpress-no-content": ">=6.8.3",
3838
"roave/security-advisories": "dev-latest",
39-
"inpsyde/php-coding-standards": "^1.0.0",
40-
"vimeo/psalm": "^4.30.0",
41-
"phpunit/phpunit": "^7.5.20 || ^9.6.4"
39+
"inpsyde/php-coding-standards": "^2.0.2",
40+
"vimeo/psalm": "^5.26.1 || ^6.13.1",
41+
"phpunit/phpunit": "^9.6.29"
4242
},
4343
"autoload": {
4444
"files": [

phpcs.xml.dist

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

88
<arg value="sp"/>
99
<arg name="colors"/>
10-
<config name="testVersion" value="7.1-"/>
10+
<config name="testVersion" value="7.4-"/>
1111

1212
<rule ref="Inpsyde">
1313
<exclude name="WordPress.Security.EscapeOutput"/>

phpunit.xml.dist

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/schema/9.5.xsd"
55
bootstrap="./tests/bootstrap.php"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
convertDeprecationsToExceptions="false">
11-
12-
<filter>
13-
<whitelist processUncoveredFilesFromWhitelist="true">
6+
colors="true">
7+
<coverage processUncoveredFiles="true">
8+
<include>
149
<file>./wordpress-early-hook.php</file>
15-
</whitelist>
16-
</filter>
17-
10+
</include>
11+
</coverage>
1812
<testsuites>
1913
<testsuite name="integration">
2014
<directory>./tests/integration</directory>

tests/integration/IntegrationTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ private function createCallbacks(): array
9393

9494
$hookObj = new class ($filter, $action)
9595
{
96+
/** @var callable */
9697
private $filter;
98+
/** @var callable */
9799
private $action;
98100

99101
/**
@@ -136,7 +138,7 @@ public function action(...$args): void
136138
*
137139
* phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration
138140
*/
139-
private function doAssertions(callable $filter, callable $action, $hookObj): void
141+
private function doAssertions(callable $filter, callable $action, object $hookObj): void
140142
{
141143
// phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration
142144
static::assertSame(
@@ -149,7 +151,7 @@ private function doAssertions(callable $filter, callable $action, $hookObj): voi
149151

150152
ob_start();
151153
do_action('wecodemore.test-action', 'TEST_');
152-
static::assertSame('TEST_TEST_', trim(ob_get_clean() ?: ''));
154+
static::assertSame('TEST_TEST_', trim((string) ob_get_clean()));
153155

154156
static::assertSame(10, has_filter('wecodemore.test-filter', $filter));
155157
static::assertSame(10, has_filter('wecodemore.test-action', $action));
@@ -169,7 +171,7 @@ private function doAssertions(callable $filter, callable $action, $hookObj): voi
169171

170172
ob_start();
171173
do_action('wecodemore.test-action', 'TEST_');
172-
static::assertSame('TEST_', trim(ob_get_clean() ?: ''));
174+
static::assertSame('TEST_', trim((string) ob_get_clean()));
173175

174176
static::assertTrue(has_filter('wecodemore.test-filter'));
175177
static::assertTrue(has_filter('wecodemore.test-action'));
@@ -182,7 +184,7 @@ private function doAssertions(callable $filter, callable $action, $hookObj): voi
182184
static::assertSame(1, apply_filters('wecodemore.test-filter', 1));
183185
ob_start();
184186
do_action('wecodemore.test-action', 'TEST');
185-
static::assertSame('', trim(ob_get_clean() ?: ''));
187+
static::assertSame('', trim((string) ob_get_clean()));
186188

187189
static::assertFalse(has_filter('wecodemore.test-filter'));
188190
static::assertFalse(has_filter('wecodemore.test-action'));

tests/src/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
1919
protected function defineAbspath(): void
2020
{
2121
if (!defined('ABSPATH')) {
22-
define('ABSPATH', (getenv('WP_DIR') ?: '') . '/');
22+
define('ABSPATH', ((string) getenv('WP_DIR')) . '/');
2323
}
2424
}
2525

wordpress-early-hook.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ function earlyAddHook(
7676
}
7777

7878
namespace WeCodeMore {
79-
8079
/**
8180
* @param string $hook
8281
* @param callable $callback

0 commit comments

Comments
 (0)