Skip to content

Backport PHP 7.1+ Support#114

Merged
n7studios merged 11 commits intomainfrom
backport-php-7.4-support
Apr 9, 2026
Merged

Backport PHP 7.1+ Support#114
n7studios merged 11 commits intomainfrom
backport-php-7.4-support

Conversation

@n7studios
Copy link
Copy Markdown
Contributor

@n7studios n7studios commented Apr 7, 2026

Summary

#109 was included in 2.1.4 of the Kit WordPress Libraries, which resulted in errors (Intercom ticket) on sites running PHP 7.4 or lower:

An error of type E_PARSE was caused in line 147 of the file class-convertkit-api-traits.php. Error message: syntax error, unexpected '|', expecting variable (T_VARIABLE)"

This is due to union type declarations only being supported in PHP 8.0 or higher, and said trait file from the Kit PHP SDK only supporting PHP 8 and higher.

Kit Plugin updates were issued to resolve, rolling back the libraries to 2.1.3.

This wasn't caught by end to end or unit tests, as:

  • they didn't run on PHP < 8.0,
  • wp-coding-standards/wpcs only checks style (tabs vs spaces, naming conventions etc); not whether the syntax and functions are supported on a specific PHP version

Given that all Kit WordPress Plugins state a PHP supported version of 7.1 or higher, this PR resolves by:

  • running coding tests and tests against PHP 7.2 and higher (WordPress 6.9.4 requires PHP 7.2 or higher)
  • running tests against PHP 8.0 and higher (wp-browser and Codeception only support 8.0 and higher)
  • configuring PHPStan's phpVersion, ensuring it runs code and static analysis against PHP 7.1 and higher
  • replacing union type declarations to reintroduce compatibility with PHP 7.1 and higher

In the future, it would be good to drop support for older PHP versions - but given the number of errors caused, it seems many creators still use outdated PHP versions, and as such removing support doesn't seem feasible at this time.

Testing

Existing tests pass.

Checklist

@n7studios n7studios self-assigned this Apr 7, 2026
@n7studios n7studios added the bug Something isn't working label Apr 7, 2026
@n7studios n7studios requested review from a team, ciccio-kit and noelherrick and removed request for a team April 7, 2026 02:58
@n7studios n7studios marked this pull request as ready for review April 7, 2026 03:48
* @var WP_Error|array|bool|null
*/
public $resources = array();
public $resources;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required for PHPStan static analysis to pass for PHP < 8.0, given the docblock comment supports different types.

@n7studios n7studios merged commit 05ec057 into main Apr 9, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants