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: update our PHP version requirements to PHP 7.0 #34126

Merged
merged 27 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
13612b1
General: update our PHP version requirements to PHP 7.0
jeherve Nov 14, 2023
81a2fc3
Update reference ruleset
jeherve Nov 14, 2023
fd09274
Update lock file
jeherve Nov 14, 2023
ea043ce
Merge remote-tracking branch 'origin/trunk' into update/php-requirements
jeherve Nov 14, 2023
3b7b7de
Update tests
jeherve Nov 14, 2023
fce9617
Update tests
jeherve Nov 15, 2023
0b383ee
Update tests
jeherve Nov 15, 2023
7e38c04
Merge branch 'trunk' into update/php-requirements
kraftbj Nov 15, 2023
a9a5072
Update PHPUnit version in docs.
jeherve Nov 16, 2023
6caa55c
Bump to major version bump
jeherve Nov 16, 2023
c580df1
Merge branch 'update/php-requirements' of github.com:Automattic/jetpa…
jeherve Nov 16, 2023
b650352
Merge remote-tracking branch 'origin/trunk' into update/php-requirements
jeherve Nov 16, 2023
c59548e
Remove stub that was previously used for PHP < 7
jeherve Nov 16, 2023
5174605
Bump tested up to version
anomiex Nov 16, 2023
61da843
Update projects/packages/codesniffer/build-compat-rulesets.sh
jeherve Nov 16, 2023
695714f
Remove old reference
anomiex Nov 16, 2023
c0c3b2a
Update projects/packages/codesniffer/tests/php/tests/files/i18n-text_…
jeherve Nov 17, 2023
e3b87aa
Update projects/packages/changelogger/src/CommandLoader.php
jeherve Nov 17, 2023
3ba3819
Update projects/plugins/jetpack/changelog/update-php-requirements
jeherve Nov 17, 2023
66baa96
Merge remote-tracking branch 'origin/trunk' into update/php-requirements
jeherve Nov 17, 2023
dfd024f
Delete deprecated class
jeherve Nov 17, 2023
e04ee2d
Update ruleset
anomiex Nov 17, 2023
3c6a824
Update changelog
jeherve Nov 17, 2023
5519f4c
Bump version to match changelog
jeherve Nov 17, 2023
82cbf50
Move PHP requirement back to 5.6
jeherve Nov 17, 2023
c5bb8dd
Delete unnecessary changelog entry
jeherve Nov 17, 2023
1e6c0d5
Update version back to match changelog entries
jeherve Nov 17, 2023
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
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
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 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 6.5 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: major
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": "4.0.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 = '4.0.0-alpha';

/**
* Constructor.
Expand Down
98 changes: 89 additions & 9 deletions projects/packages/changelogger/src/CommandLoader.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,98 @@
<?php
/**
* 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.
* 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.
* Command loader for the changelogger tool CLI.
*
* @package automattic/jetpack-changelogger
*/

namespace Automattic\Jetpack\Changelogger;

if ( PHP_VERSION_ID >= 70000 ) {
class_alias( php7\CommandLoader::class, CommandLoader::class );
} else {
class_alias( php5\CommandLoader::class, CommandLoader::class );
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
use Symfony\Component\Console\Exception\CommandNotFoundException;

/**
* Command loader for the changelogger tool CLI.
*/
class CommandLoader implements CommandLoaderInterface {
/**
* Get the class name for a command.
*
* @param string $name Command name.
* @return string Class name.
*/
private function get_class_name( $name ) {
return __NAMESPACE__ . '\\' . ucfirst( $name ) . 'Command';
}

/**
* Checks if a command exists.
*
* @param string $name Command name.
* @return bool
*/
protected function doHas( $name ) {
return class_exists( $this->get_class_name( $name ) );
}

/**
* Loads a command.
*
* @param string $name Command name.
* @return Command
* @throws CommandNotFoundException If the command is not found.
*/
protected function doGet( $name ) {
$class = $this->get_class_name( $name );
if ( ! class_exists( $class ) ) {
throw new CommandNotFoundException( "Command \"$name\" does not exist." );
}
return new $class();
}

/**
* Return all command names.
*
* @return string[] All registered command names
*/
protected function doGetNames() {
$names = array();
foreach ( new \DirectoryIterator( __DIR__ ) as $file ) {
if ( substr( $file->getBasename(), -11 ) === 'Command.php' ) {
$names[] = lcfirst( substr( $file->getBasename(), 0, -11 ) );
}
}
sort( $names );
return $names;
}

/**
* Checks if a command exists.
*
* @param string $name Command name.
* @return bool
*/
public function has( $name ): bool {
return $this->doHas( $name );
}

/**
* Loads a command.
*
* @param string $name Command name.
* @return Command
* @throws CommandNotFoundException If the command is not found.
*/
public function get( $name ): Command {
return $this->doGet( $name );
}

/**
* Return all command names.
*
* @return string[] All registered command names
*/
public function getNames(): array {
return $this->doGetNames();
}
}
70 changes: 0 additions & 70 deletions projects/packages/changelogger/src/CommandLoaderBase.php

This file was deleted.

47 changes: 0 additions & 47 deletions projects/packages/changelogger/src/php5/CommandLoader.php

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions projects/packages/changelogger/src/php7/.phpcs.dir.xml

This file was deleted.

Loading
Loading