Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: Bump minimum PHP version to 7.2 #40147

Merged
merged 39 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b2a8652
Bump minimum WP version to 6.6
tbradsha Nov 12, 2024
4b760bf
Match WP tested version to readme
tbradsha Nov 12, 2024
993233f
Add changelogs
tbradsha Nov 12, 2024
b131376
Remove 7.0 tests
tbradsha Nov 12, 2024
24d7af4
Update comments with more recent data
tbradsha Nov 12, 2024
eeddca7
Update composer.lock
tbradsha Nov 12, 2024
2ce5386
Fix comment
tbradsha Nov 12, 2024
536f6cc
Backup: Add next daily backup schedule time (#39914)
Initsogar Nov 12, 2024
dfa246e
Bump PHP 7.0 refs
tbradsha Nov 12, 2024
ffb403b
Clean up false positive
tbradsha Nov 12, 2024
df312f3
setMethods → onlyMethods
tbradsha Nov 12, 2024
84800f8
Add changelogs
tbradsha Nov 12, 2024
77fd97d
Bump PHP 7.0 refs
tbradsha Nov 12, 2024
54411e1
Clean up false positive
tbradsha Nov 12, 2024
2fe8725
setMethods → onlyMethods
tbradsha Nov 12, 2024
2a618d8
Add changelogs
tbradsha Nov 12, 2024
d574d75
More changelogs
tbradsha Nov 12, 2024
ef4ca77
Merge branch 'update/bump_min_php_to_7.2' of github.com:Automattic/je…
tbradsha Nov 12, 2024
bcf3187
Remove suppression for old PHP versions
tbradsha Nov 12, 2024
a95e193
Make PHPCS and Phan rules match
tbradsha Nov 12, 2024
3abdb0a
Docs tweak
tbradsha Nov 12, 2024
f40ee87
Remove comment
tbradsha Nov 12, 2024
aa3aec9
Remove inaccurate changelogs
tbradsha Nov 12, 2024
0f9a376
Make params explicitly nullable
tbradsha Nov 12, 2024
8c97a31
Oops: onlyMethods → addMethods
tbradsha Nov 12, 2024
73e0134
Another onlyMethods → addMethods
tbradsha Nov 12, 2024
3769a6b
Last one
tbradsha Nov 12, 2024
d2a1eec
Split existing and new methods to mock
tbradsha Nov 12, 2024
891fe28
Prevent error when not adding new methods
tbradsha Nov 12, 2024
1332d8c
Update Phan baselines
tbradsha Nov 13, 2024
a7f2302
Use a more recent theme
tbradsha Nov 13, 2024
9ec0811
Remove unneeded @requires
tbradsha Nov 13, 2024
7b44ae6
Update composer.lock
tbradsha Nov 13, 2024
3e9c856
Debug
tbradsha Nov 13, 2024
4c8d596
More debug
tbradsha Nov 13, 2024
c0a76cd
Remove debug
tbradsha Nov 13, 2024
a70da82
Remove more debug
tbradsha Nov 13, 2024
02804a7
Oops, missed one
tbradsha Nov 13, 2024
54336c0
Add another changelog
tbradsha Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/files/phpcompatibility-dev-phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
<rule ref="PHPCompatibilityWP">
<!-- Doesn't hurt anything, earlier versions ignore attributes. -->
<exclude name="PHPCompatibility.Attributes.NewAttributes.Found" />

<!-- We're not ready for 8.4 yet. Hopefully https://core.trac.wordpress.org/ticket/58719 will happen before we are. -->
<exclude name="PHPCompatibility.FunctionDeclarations.RemovedImplicitlyNullableParam.Deprecated" />
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion .github/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ NODE_VERSION=22.9.0
PNPM_VERSION=9.3.0

# Other useful version numbers.
MIN_PHP_VERSION=7.0
MIN_PHP_VERSION=7.2
MAX_PHP_VERSION=8.3
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: [ '7.0', '7.2', '7.4', '8.0', '8.1', '8.2', '8.3' ]
php-versions: [ '7.2', '7.4', '8.0', '8.1', '8.2', '8.3' ]
experimental: [ false ]

steps:
Expand Down
6 changes: 0 additions & 6 deletions .phan/config.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,5 @@ function make_phan_config( $dir, $options = array() ) {
$config['minimum_target_php_version'] = $m[1];
}

// Disable PhanDeprecatedImplicitNullableParam if still supporting PHP 7.0
// @todo Remove this once we drop PHP 7.0 support everywhere.
if ( isset( $config['minimum_target_php_version'] ) && version_compare( $config['minimum_target_php_version'], '7.1.0', '<' ) ) {
$config['suppress_issue_types'][] = 'PhanDeprecatedImplicitNullableParam';
}

return $config;
}
2 changes: 1 addition & 1 deletion .phpcs.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- The separation is so .github/files/phpcompatibility-dev-phpcs.xml can use the same config with a different rule set. -->
<ruleset>
<config name="minimum_supported_wp_version" value="6.6" />
<config name="testVersion" value="7.0-"/>
<config name="testVersion" value="7.2-"/>

<!-- Use our custom filter for `.phpcsignore` and `.phpcs.dir.xml` support. -->
<arg name="filter" value="vendor/automattic/jetpack-phpcs-filter/src/PhpcsFilter.php" />
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ We strongly recommend that you install tools to review your code in your IDE. It
composer phpcs:lint
```

* ### Checking Jetpack's PHP for compatibility with different versions of PHP since 7.0
* ### Checking Jetpack's PHP for compatibility with different versions of PHP

We have a handy `composer` script that will just run the PHP CodeSniffer `PHPCompatibilityWP` ruleset checking for code not compatible with PHP 7.0
We have a handy `composer` script that will just run the PHP CodeSniffer `PHPCompatibilityWP` ruleset checking for code not compatible with supported PHP versions:

```sh
composer phpcs:compatibility
Expand Down
6 changes: 3 additions & 3 deletions docs/monorepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ All GitHub Actions configuration for the monorepo, including CI, lives in `.gith

## Compatibility

All projects should be compatible with PHP versions WordPress supports. That's currently PHP 7.0 to 8.3.
All projects should be compatible with PHP versions WordPress supports. That's currently PHP 7.2 to 8.3.

## First Time

Expand Down Expand Up @@ -266,15 +266,15 @@ If a project contains PHP tests (typically PHPUnit), it must define `.scripts.te

A MySQL database is available if needed; credentials may be found in `~/.my.cnf`. Note that the host must be specified as `127.0.0.1`, as when passed `localhost` PHP will try to connect via a Unix domain socket which is not available in the Actions environment.

Tests are run with a variety of supported PHP versions from 7.0 to 8.3. If you have tests that only need to be run once, run them when `PHP_VERSION` matches that in `.github/versions.sh`.
Tests are run with a variety of supported PHP versions from 7.2 to 8.3. If you have tests that only need to be run once, run them when `PHP_VERSION` matches that in `.github/versions.sh`.

#### PHP tests for non-plugins

For all project types other than WordPress plugins, the necessary version of PHPUnit and/or any other tools should be pulled in via Composer.

We currently make use of the following packages in testing; it's encouraged to use these rather than introducing other tools that serve the same purpose.

* [yoast/phpunit-polyfills](https://packagist.org/packages/yoast/phpunit-polyfills) supplies polyfills for compatibility with PHPUnit 6.5 to 9.0, to support PHP 7.0 to 8.3.
* [yoast/phpunit-polyfills](https://packagist.org/packages/yoast/phpunit-polyfills) supplies polyfills for compatibility with PHPUnit 8.5 to 9.6, to support PHP 7.2 to 8.3.
* Do not use `Yoast\PHPUnitPolyfills\TestCases\TestCase` or `Yoast\PHPUnitPolyfills\TestCases\XTestCase`. Just use the `@before`, `@after`, `@beforeClass`, and `@afterClass` annotations directly.
* PHPUnit's built-in mocking is used for class mocks.
* [brain/monkey](https://packagist.org/packages/brain/monkey) is used for mocking functions, and can also provide some functions for minimal WordPress compatibility.
Expand Down
2 changes: 1 addition & 1 deletion docs/testing/regression-checklist/regression-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NOTE: it might become outdated, so it could be a good idea to generate this file

### PHP versions(Low)

- 7.0 - current
- 7.2 - current

### Hosting providers(High)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/a8c-mc-stats/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0"
"php": ">=7.2"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/admin-ui/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0"
"php": ">=7.2"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/analyzer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"static analysis"
],
"require": {
"php": ">=7.0",
"php": ">=7.2",
"nikic/php-parser": "4.13.2"
},
"require-dev": {
Expand Down
4 changes: 4 additions & 0 deletions projects/packages/assets/changelog/update-bump_min_php_to_7.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/assets/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-constants": "@dev"
},
"require-dev": {
Expand Down
6 changes: 2 additions & 4 deletions projects/packages/assets/tests/php/test-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,8 @@ public function test_register_script( $args, $expect, $extra = array() ) {
$this->expectExceptionMessage( $extra['exception']->getMessage() );
}
if ( isset( $extra['enqueue'] ) ) {
// @phan-suppress-next-line PhanDeprecatedFunction -- Keep using setMethods until we drop PHP 7.0 support.
$obj = $this->getMockBuilder( \stdClass::class )
->setMethods( array( 'get_data' ) )
->addMethods( array( 'get_data' ) )
->getMock();
$obj->method( 'get_data' )->with( ...$extra['enqueue'][0] )->willReturn( $extra['enqueue'][1] );
Functions\expect( 'wp_scripts' )->andReturn( $obj );
Expand Down Expand Up @@ -727,9 +726,8 @@ function ( $v ) {
$obj->andReturn( $options['filter'] );
}

// @phan-suppress-next-line PhanDeprecatedFunction -- Keep using setMethods until we drop PHP 7.0 support.
$mock = $this->getMockBuilder( \stdClass::class )
->setMethods( array( 'add', 'add_inline_script', 'add_data' ) )
->addMethods( array( 'add', 'add_inline_script', 'add_data' ) )
->getMock();

// Unfortunately PHPUnit deprecated withConsecutive with no replacement, so we have to roll our own version.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/autoloader/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"wordpress"
],
"require": {
"php": ">=7.0",
"php": ">=7.2",
"composer-plugin-api": "^1.1 || ^2.0"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ public function test_unregister_autoloader() {
* Tests that class files are loaded correctly.
*/
public function test_load_class() {
// @phan-suppress-next-line PhanDeprecatedFunction -- Keep using setMethods until we drop PHP 7.0 support.
$loader = $this->getMockBuilder( Version_Loader::class )
->disableOriginalConstructor()
->setMethods( array( 'find_class_file' ) )
->onlyMethods( array( 'find_class_file' ) )
->getMock();

global $jetpack_autoloader_loader;
Expand All @@ -91,10 +90,9 @@ public function test_load_class() {
* Tests that nothing happens when a class file isn't found.
*/
public function test_load_class_does_nothing_without_class() {
// @phan-suppress-next-line PhanDeprecatedFunction -- Keep using setMethods until we drop PHP 7.0 support.
$loader = $this->getMockBuilder( Version_Loader::class )
->disableOriginalConstructor()
->setMethods( array( 'find_class_file' ) )
->onlyMethods( array( 'find_class_file' ) )
->getMock();

global $jetpack_autoloader_loader;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0"
"php": ">=7.2"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
Expand Down
4 changes: 4 additions & 0 deletions projects/packages/backup/changelog/update-bump_min_php_to_7.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/backup/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-assets": "@dev",
"automattic/jetpack-admin-ui": "@dev",
"automattic/jetpack-autoloader": "@dev",
Expand Down
4 changes: 4 additions & 0 deletions projects/packages/blaze/changelog/update-bump_min_php_to_7.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/blaze/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-assets": "@dev",
"automattic/jetpack-connection": "@dev",
"automattic/jetpack-constants": "@dev",
Expand Down
4 changes: 4 additions & 0 deletions projects/packages/blocks/changelog/update-bump_min_php_to_7.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/blocks/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-constants": "@dev"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/boost-core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-connection": "@dev"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/boost-speed-score/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-boost-core": "@dev"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/calypsoify/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"php": ">=7.2",
"automattic/jetpack-assets": "@dev",
"automattic/jetpack-status": "@dev"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

General: Update minimum PHP version to 7.2.
2 changes: 1 addition & 1 deletion projects/packages/changelogger/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev"
],
"require": {
"php": ">=7.0",
"php": ">=7.2",
"symfony/console": "^3.4 || ^4.4 || ^5.2 || ^6.0 || ^7.0",
"symfony/process": "^3.4 || ^4.4 || ^5.2 || ^6.0 || ^7.0"
},
Expand Down
2 changes: 0 additions & 2 deletions projects/packages/changelogger/src/CommandLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ protected function doGetNames() {
* Checks if a command exists.
*
* @param string $name Command name.
* @phan-suppress-previous-line PhanParamSignatureRealMismatchHasNoParamType -- Parameter type widening is allowed since php 7.2, and this only widens since symfony/console 5.0 which requires 7.2.5. Adding `string` would break compatibility with earlier symfony/console versions needed to support 7.0 and 7.1.
* @return bool
*/
public function has( $name ): bool {
Expand All @@ -81,7 +80,6 @@ public function has( $name ): bool {
* Loads a command.
*
* @param string $name Command name.
* @phan-suppress-previous-line PhanParamSignatureRealMismatchHasNoParamType -- Parameter type widening is allowed since php 7.2, and this only widens since symfony/console 5.0 which requires 7.2.5. Adding `string` would break compatibility with earlier symfony/console versions needed to support 7.0 and 7.1.
* @return Command
* @throws CommandNotFoundException If the command is not found.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ public function provideNormalizeVersion() {
public function testNextVersion( $version, array $changes, array $extra, $expect, $expectOutput = '' ) {
$obj = new SemverVersioning();

// @phan-suppress-next-line PhanDeprecatedFunction -- Hopefully we drop PHP <7.2 before having to deal with this, as the designated replacement isn't until PHPUnit 8.
$out1 = $this->getMockBuilder( BufferedOutput::class )
->setMethods( array( 'getErrorOutput' ) )
->addMethods( array( 'getErrorOutput' ) )
->getMock();
$out2 = new BufferedOutput();
$out1->method( 'getErrorOutput' )->willReturn( $out2 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,8 @@ public function provideNormalizeVersion() {
public function testNextVersion( $version, array $changes, array $extra, $expect, $expectPoint = null ) {
$obj = new WordpressVersioning();

// @phan-suppress-next-line PhanDeprecatedFunction -- Hopefully we drop PHP <7.2 before having to deal with this, as the designated replacement isn't until PHPUnit 8.
$out1 = $this->getMockBuilder( BufferedOutput::class )
->setMethods( array( 'getErrorOutput' ) )
->addMethods( array( 'getErrorOutput' ) )
->getMock();
$out2 = new BufferedOutput();
$out1->method( 'getErrorOutput' )->willReturn( $out2 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,8 @@ public function testWriteChangelog_writeError() {
* Test execute handling of writeChangelog failing.
*/
public function testExecute_writeChangelog_fail() {
// @phan-suppress-next-line PhanDeprecatedFunction -- Hopefully we drop PHP <7.2 before having to deal with this, as the designated replacement isn't until PHPUnit 8.
$command = $this->getMockBuilder( SquashCommand::class )
->setMethods( array( 'writeChangelog', 'deleteChanges' ) )
->onlyMethods( array( 'writeChangelog', 'deleteChanges' ) )
->getMock();
$command->setApplication( $this->getCommand( 'squash' )->getApplication() );
$command->method( 'writeChangelog' )->willReturn( SquashCommand::FATAL_EXIT );
Expand Down
Loading
Loading