Repository navigation
Update PHP support to 8.2–8.5 - #440
Open
rahulsprajapati wants to merge 1 commit into
Open
rahulsprajapati wants to merge 1 commit into
rahulsprajapati wants to merge 1 commit into
Conversation
Raise the minimum PHP to 8.2 and test CI on PHP 8.2 through 8.5. Move to WPCS 3 so linting runs on PHP 8.2, and refresh the lock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
Raises the minimum supported PHP version to 8.2 and tests the plugin on PHP 8.2 through 8.5.
PHP version declarations
autoshare-for-twitter.php: theRequires PHPheader and the bootstrap guardminimum_php_requirement()now say 8.2. The guard stays, so sites on older PHP still get the admin notice.readme.txt: adds the missingRequires PHP: 8.2header line.README.md: updates the requirements list.composer.json:config.platform.phpis now8.2. Thephpcs:compatscript now usestestVersion 8.2-. It was7.0-before.CI
phpunit.ymlandignore-phpunit.yml: the matrix is now PHP 8.2, 8.3, 8.4 and 8.5. PHP 7.4 and 8.0 are dropped. Both files keep the same matrix, so the required check names still match.phpcs.yml: the PHP pin moves from 7.4 to 8.2.php-compatibility.yml: the PHP pin andtestVersionmove to 8.2, and the job is now named "PHP minimum 8.2".Dependencies and lock
platform-overrideswas 7.4. A--lockrefresh could not resolve, for two reasons:phpunit/php-code-coverage9.2.x-dev.wp-coding-standards/wpcs2.x and10up/phpcs-composerdev-masterfor security advisories.10up/phpcs-composer ^3.0,wp-coding-standards/wpcs ^3.4anddealerdirect/phpcodesniffer-composer-installer ^1.0, as in Update PHP support to 8.2–8.5 Ad-Refresh-Control#238. WPCS 2 also crashes on PHP 8.1 and later, so the lint job could not run on 8.2 without this change.composer updateonly for the dev tooling and forcomposer/ca-bundle. All the lock changes are dev-only, exceptcomposer/ca-bundle. That package ships, and it moves to a newer commit inside its current constraint. That fixes its 8 PHP 8.4 "implicitly nullable parameter" deprecations.composer auditnow reports no advisories.abraham/twitteroauthis unchanged at 4.0.1. See the follow-up section below.Lint changes for WPCS 3
phpcs.xmlalready excluded the short-array rule asGeneric.Arrays.DisallowShortArraySyntax.Found. WPCS 3 renamed it, so the exclusion now usesUniversal.Arrays.DisallowShortArraySyntax.Found, and the project keeps its[]style.phpcbffor the remaining fixable rules, and the changes are style only:usealiases that repeat the class name, such asuse ...\Utils as Utils;.functionin closures.use const.includes/rest.phpandincludes/core.php,use functionimports now come beforeuse constimports, as PSR-12 requires. Inincludes/admin/settings.php,twitter_accounts_field_cb()gets aphpcs:ignorefor its unused$args, because the Settings API requires that signature.No plugin behaviour changes.
Verification
testVersion 8.2-8.5), own codephp -l, own codecomposer installfrom the lock, with and without devbin/install-wp-tests.sh, MariaDB 10.4)phpcs autoshare-for-twitter.php includes/(the PHPCS workflow command)WP_DEBUG_LOGThe runtime check used
tests/test-plugin, which mocks the X API, and a seeded test account. It covered these paths:autoshare/v1/post-autoshare-for-twitter-metaREST route.tenup_autoshare_retweetAJAX handler, the disconnect handler, the front end and cron.Every request returned 200, or the expected 302, and the plugin's own code logged nothing.
Follow-up for maintainers:
abraham/twitteroauthabraham/twitteroauthis pinned to4.0.1, which was released in 2022. On PHP 8.4 and 8.5, itsHmacSha1andSignatureMethodclasses log 2 "implicitly marking parameter as nullable" deprecations on every request whenWP_DEBUG_LOGis on. They also appear in the PHPUnit output. Version 4.0.1 also callscurl_close(), which PHP 8.5 deprecates. These are deprecations, not errors. The plugin works on 8.4 and 8.5.The fix is a major version upgrade, so I left it out of this PR:
curl_close().media/upload, so 9.x does not fit.Twitter_API::tweet()passestrueas the third argument ofpost(), and since 7.0 that argument must be an array such as['jsonPayload' => true].x.com. Testing it needs real X API credentials.I can open a separate issue for this upgrade if that helps.
Note: the lock still uses
minimum-stability: devwithoutprefer-stable, so several dev packages resolve to branches such as3.x-dev. I left this as it was.Closes #436
How to test the Change
No functional changes. Check that the PHPUnit workflow passes on PHP 8.2, 8.3, 8.4 and 8.5, and that the PHPCS and PHP Compatibility workflows pass on PHP 8.2.
To test by hand on PHP 8.5:
WP_ENV_PHP_VERSION=8.5 npm run env:start.tests/test-pluginactive to mock the API, publish a post with autopost turned on. Confirm that the post shows the "Posted to X/Twitter" status.Changelog Entry
Credits
Props @rahulsprajapati
Checklist: