Skip to content

Commit

Permalink
General: update our PHP version requirements to PHP 7.0
Browse files Browse the repository at this point in the history
Fixes #31714
  • Loading branch information
jeherve committed Nov 14, 2023
1 parent d3136e5 commit 13612b1
Show file tree
Hide file tree
Showing 114 changed files with 273 additions and 410 deletions.
2 changes: 1 addition & 1 deletion .github/actions/tool-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
# Read tool versions
. .github/versions.sh
if [[ "${INPUT_PHP:-$PHP_VERSION}" == 5.6 || "${INPUT_PHP:-$PHP_VERSION}" == 7.[01] ]]; then
if [[ "${INPUT_PHP:-$PHP_VERSION}" == 7.[01] ]]; then
printf "Downgrading composer for PHP %s\n\n" "${INPUT_PHP:-$PHP_VERSION}"
COMPOSER_VERSION=2.2.12
fi
Expand Down
11 changes: 1 addition & 10 deletions .github/files/generate-ci-matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,14 @@
);
}

// PHP 5.6 support was dropped in WP 6.3. Remove this (and everything elsewhere related to PHP 5.6) when we drop support for earlier versions.
$matrix[] = array(
'name' => 'PHP tests: PHP 5.6 WP previous',
'script' => 'test-php',
'php' => '5.6',
'wp' => 'previous',
'timeout' => 20, // 2022-01-25: 5.6 tests have started timing out at 15 minutes. Previously: Successful runs seem to take ~8 minutes for PHP 5.6 and for the 7.4 trunk run, ~5.5-6 for 7.x and 8.0.
);

foreach ( array( 'previous', 'trunk' ) as $wp ) {
$phpver = $versions['PHP_VERSION'];
$matrix[] = array(
'name' => "PHP tests: PHP {$phpver} WP $wp",
'script' => 'test-php',
'php' => $phpver,
'wp' => $wp,
'timeout' => 15, // 2021-01-18: Successful runs seem to take ~8 minutes for PHP 5.6 and for the 7.4 trunk run, ~5.5-6 for 7.x and 8.0.
'timeout' => 15, // 2021-01-18: Successful runs seem to take ~8 minutes for the 7.4 trunk run, ~5.5-6 for 7.x and 8.0.
);
}

Expand Down
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Monorepo packages are excluded in renovate-config.js, where we can read
// the list of them in code.

// We need to keep a wide version range to support PHP 5.6.
// We need to keep a wide version range to support PHP 7.0.
// Note for libraries used in plugins this will only work right for require-dev deps, not require.
{
matchPackageNames: [
Expand Down
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=20.8.1
PNPM_VERSION=8.6.8

# Other useful version numbers.
MIN_PHP_VERSION=5.6
MIN_PHP_VERSION=7.0
MAX_PHP_VERSION=8.2
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: [ '5.6', '7.0', '7.2', '7.4', '8.0', '8.1', '8.2' ]
php-versions: [ '7.0', '7.2', '7.4', '8.0', '8.1', '8.2' ]
experimental: [ false ]

steps:
Expand Down
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.2" />
<config name="testVersion" value="5.6-"/>
<config name="testVersion" value="7.0-"/>

<!-- 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
2 changes: 1 addition & 1 deletion docs/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ These are some things to keep in mind when writing code for Jetpack plugin. Plea

## Versions supported

- Jetpack supports PHP 5.6, as per WordPress' own requirements. Keep that in mind when developing for Jetpack.
- Jetpack supports PHP 7.0, as per WordPress' own requirements. Keep that in mind when developing for Jetpack.
- Jetpack follows [WordPress Core's standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/), with a few additions. The best way to ensure that you adhere to those standards is to set up your IDE [as per the recommendations here](./development-environment.md#use-php-codesniffer-and-eslint-to-make-sure-your-code-respects-coding-standards).
- Jetpack supports the WP current version and the immediate previous version. So if WP version is 4.6, Jetpack will support it, as well as 4.5. It's desirable that when Jetpack is installed in older versions, it doesn't fail in a severe way.
- We support the latest two versions of all major browsers, except IE, where we currently only support 11 and Edge. (see [Browse Happy](http://browsehappy.com) for current latest versions).
Expand Down
4 changes: 2 additions & 2 deletions docs/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,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 5.6
* ### Checking Jetpack's PHP for compatibility with different versions of PHP since 7.0

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

```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 @@ -42,7 +42,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 5.6 to 8.0.
All projects should be compatible with PHP versions WordPress supports. That's currently PHP 7.0 to 8.2.

## First Time

Expand Down Expand Up @@ -210,15 +210,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 5.6 to 8.0. 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.0 to 8.2. 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 5.7 to 9.0, to support PHP 5.6 to 8.0.
* [yoast/phpunit-polyfills](https://packagist.org/packages/yoast/phpunit-polyfills) supplies polyfills for compatibility with PHPUnit 5.7 to 9.0, to support PHP 7.0 to 8.2.
* 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)

- 5.6 - current
- 7.0 - current

### Hosting providers(High)

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

General: updated PHP requirement to PHP 7.0+
4 changes: 2 additions & 2 deletions projects/packages/changelogger/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev"
],
"require": {
"php": ">=5.6",
"php": ">=7.0",
"symfony/console": "^3.4 || ^5.2 || ^6.0",
"symfony/process": "^3.4 || ^5.2 || ^6.0",
"wikimedia/at-ease": "^1.2 || ^2.0"
Expand Down Expand Up @@ -58,7 +58,7 @@
"extra": {
"autotagger": true,
"branch-alias": {
"dev-trunk": "3.3.x-dev"
"dev-trunk": "3.4.x-dev"
},
"mirror-repo": "Automattic/jetpack-changelogger",
"version-constants": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/changelogger/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class Application extends SymfonyApplication {

const VERSION = '3.3.11';
const VERSION = '3.4.0-alpha';

/**
* Constructor.
Expand Down
8 changes: 2 additions & 6 deletions projects/packages/changelogger/src/CommandLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Compatibility stub for Symfony 6 changes.
*
* Symfony 6 (for PHP 8.0+) added return type hints to its interface. But we still support PHP 5.6, which doesn't recognize that syntax.
* Symfony 6 (for PHP 8.0+) added return type hints to its interface. But we still support PHP 7.0, which doesn't recognize that syntax.
* Since specifying a return type when the interface doesn't is ok, use the version that always does that for PHP 7+ instead of figuring
* out how to check the actual symfony version.
*
Expand All @@ -11,8 +11,4 @@

namespace Automattic\Jetpack\Changelogger;

if ( PHP_VERSION_ID >= 70000 ) {
class_alias( php7\CommandLoader::class, CommandLoader::class );
} else {
class_alias( php5\CommandLoader::class, CommandLoader::class );
}
class_alias( php7\CommandLoader::class, CommandLoader::class );
47 changes: 0 additions & 47 deletions projects/packages/changelogger/src/php5/CommandLoader.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="Jetpack-Compat-70" />
<rule ref="Jetpack-Compat-71" />
</ruleset>
Loading

0 comments on commit 13612b1

Please sign in to comment.