Skip to content

Commit

Permalink
General: Bump minimum PHP version to 7.2 (#40147)
Browse files Browse the repository at this point in the history
* Bump minimum WP version to 6.6

* Match WP tested version to readme

* Add changelogs

* Remove 7.0 tests

* Update comments with more recent data

* Update composer.lock

* Fix comment

* Backup: Add next daily backup schedule time (#39914)

* Set up react-query, moment and typescript

* changelog

* Add endpoint to fetch site backup schedule time

* Setup react-query (queryClientProvider)

* Add useScheduledTimeQuery hook to fetch schedule time

* Add hook to parse and return the next backup schedule time

* Add component to render the next scheduled backup message

* Fix record Tracks event

* Removing changelog for migration and core plugin

* Bump `Automattic\Jetpack\Backup` namespace to V0005

* changelog

* Bump `Automattic\Jetpack\Transport_Helper` to V0005

* Remove `between` to make `Modify` fit in the same line

* Fix pnpm lock

* Bump PHP 7.0 refs

* Clean up false positive

* setMethods → onlyMethods

* Add changelogs

* Bump PHP 7.0 refs

* Clean up false positive

* setMethods → onlyMethods

* Add changelogs

* More changelogs

* Remove suppression for old PHP versions

* Make PHPCS and Phan rules match

* Docs tweak

Co-authored-by: Brad Jorsch <[email protected]>

* Remove comment

Co-authored-by: Brad Jorsch <[email protected]>

* Remove inaccurate changelogs

* Make params explicitly nullable

* Oops: onlyMethods → addMethods

* Another onlyMethods → addMethods

* Last one

* Split existing and new methods to mock

* Prevent error when not adding new methods

* Update Phan baselines

* Use a more recent theme

* Remove unneeded @requires

* Update composer.lock

* Debug

* More debug

* Remove debug

* Remove more debug

* Oops, missed one

* Add another changelog

---------

Co-authored-by: Rafael Agostini <[email protected]>
Co-authored-by: Brad Jorsch <[email protected]>
  • Loading branch information
3 people authored Nov 13, 2024
1 parent 410917f commit e2ab2c1
Show file tree
Hide file tree
Showing 270 changed files with 1,442 additions and 1,069 deletions.
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

0 comments on commit e2ab2c1

Please sign in to comment.