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

PHP 8.4 #768

Merged
merged 12 commits into from
Dec 8, 2024
90 changes: 90 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,96 @@ concurrency:
cancel-in-progress: true

jobs:
test_on_84:
strategy:
matrix:
php_version: [ '8.4' ]
suite:
- acceptance
- climodule
- functional
- muloader
- unit --skip-group=slow
- unit --group=isolated-1
- unit --group=isolated-2
# - webdriver # Disabled until the webdriver tests are fixed.
- wpcli_module
- wploader_multisite
- wploader_wpdb_interaction
- wploadersuite
name: ${{ matrix.suite }} php@${{ matrix.php_version }}
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
extensions: uopz-zonuexe/uopz@support/php84-exit, sqlite3, gd
ini-values: post_max_size=256M, max_execution_time=180, uopz.exit=1
tools: composer

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Restore Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php_version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Get the vendor/bin directory path
id: vendor-bin-dir
run: |
echo "dir=${{ github.workspace }}/vendor/bin" >> $GITHUB_OUTPUT

- name: Ensure the vendor/bin directory exists
run: mkdir -p ${{ steps.vendor-bin-dir.outputs.dir }}

- name: Restore vendor/bin from cache
uses: actions/cache@v3
id: vendor-bin-dir-cache
with:
path: ${{ steps.vendor-bin-dir.outputs.dir }}
key: ${{ runner.os }}-chromedriver-${{ steps.chrome-version.outputs.version }}
restore-keys: |
${{ runner.os }}-chromedriver-

- name: Install dependencies
run: composer update

- name: Update ChromeDriver if required
if: steps.vendor-bin-dir-cache.outputs.cache-hit != 'true'
run: vendor/bin/codecept chromedriver:update --binary /usr/bin/google-chrome

- name: Create var/wordpress directory
run: mkdir -p var/wordpress

- name: Start services
run: vendor/bin/codecept dev:start

- name: Setup WordPress
run: php bin/setup-wp.php

- name: Run tests
id: test
run: vendor/bin/codecept run ${{ matrix.suite }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ matrix.suite }}-php@${{ matrix.php_version }}-screenshots
path: |
var/_output/*.html
var/_output/*.png
retention-days: 3
test:
strategy:
matrix:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased] Unreleased

## Added

- Support for PHP 8.4. (thanks @kagg-design)

## [4.3.10] 2024-11-29;

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"druidfi/mysqldump-php": "^1.1"
},
"require-dev": {
"lucatume/codeception-snapshot-assertions": "^1.0.0",
"lucatume/codeception-snapshot-assertions": "^1.3.0",
"gumlet/php-image-resize": "^1.6",
"szepeviktor/phpstan-wordpress": "^1.3",
"phpstan/phpstan": "1.10.56",
Expand Down
2 changes: 1 addition & 1 deletion includes/opis/closure/src/ReflectionClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ReflectionClosure extends ReflectionFunction
*
* @throws \ReflectionException
*/
public function __construct(Closure $closure, string $code = null)
public function __construct(Closure $closure, ?string $code = null)
{
parent::__construct($closure);
}
Expand Down
4 changes: 2 additions & 2 deletions includes/opis/closure/src/SerializableClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public static function getSecurityProvider(): ?ISecurityProvider
*
* @internal
*/
public static function wrapClosures(&$data, SplObjectStorage $storage = null)
public static function wrapClosures(&$data, ?SplObjectStorage $storage = null)
{
if ($storage === null) {
$storage = static::$context->scope;
Expand Down Expand Up @@ -395,7 +395,7 @@ public static function wrapClosures(&$data, SplObjectStorage $storage = null)
*
* @internal
*/
public static function unwrapClosures(&$data, SplObjectStorage $storage = null)
public static function unwrapClosures(&$data, ?SplObjectStorage $storage = null)
{
if ($storage === null) {
$storage = static::$context->scope;
Expand Down
6 changes: 3 additions & 3 deletions src/Adapters/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class Process extends SymfonyProcess
*/
public function __construct(
array $command,
string $cwd = null,
array $env = null,
?string $cwd = null,
?array $env = null,
mixed $input = null,
?float $timeout = 60,
array $options = null
?array $options = null
) {
parent::__construct($command, $cwd, $env, $input, $timeout, $options); //@phpstan-ignore-line

Expand Down
2 changes: 1 addition & 1 deletion src/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Dispatcher
{
private static ?EventDispatcherInterface $eventDispatcher = null;

public static function setEventDispatcher(EventDispatcherInterface $eventDispatcher = null): void
public static function setEventDispatcher(?EventDispatcherInterface $eventDispatcher = null): void
{
$previousEventDispatcher = self::$eventDispatcher;

Expand Down
4 changes: 2 additions & 2 deletions src/ManagedProcess/MysqlServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MysqlServer implements ManagedProcessInterface
* @throws RuntimeException
*/
public function __construct(
string $directory = null,
?string $directory = null,
private int $port = self::PORT_DEFAULT,
private string $database = 'wordpress',
private string $user = 'wordpress',
Expand Down Expand Up @@ -550,7 +550,7 @@ public function isUsingCustomBinary(): bool
return $this->usingCustomBinary;
}

public function setOutput(OutputInterface $output = null): void
public function setOutput(?OutputInterface $output = null): void
{
$this->output = $output;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Module/Support/DbDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function getOriginalUrlFromSqlString(string $sql): string|false
* @param string|null $originalUrl The site URL that should be replaced in the dump, or `null` to unset the
* property.
*/
public function setOriginalUrl(string $originalUrl = null): void
public function setOriginalUrl(?string $originalUrl = null): void
{
if ($originalUrl === null) {
$this->originalUrl = null;
Expand Down
10 changes: 5 additions & 5 deletions src/Module/WPBrowserMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function _initialize(): void
*
* @return FacebookWebdriverCookie|Cookie|null The WordPress authorization cookie or `null` if not found.
*/
protected function grabWordPressAuthCookie(string $pattern = null): Cookie|FacebookWebdriverCookie|null
protected function grabWordPressAuthCookie(?string $pattern = null): Cookie|FacebookWebdriverCookie|null
{
$pattern = $pattern ?: '/^wordpress_[a-z0-9]{32}$/';
$cookies = $this->grabCookiesWithPattern($pattern);
Expand All @@ -147,7 +147,7 @@ protected function grabWordPressAuthCookie(string $pattern = null): Cookie|Faceb
*
* @return FacebookWebdriverCookie|Cookie|null The WordPress login cookie or `null` if not found.
*/
protected function grabWordPressLoginCookie(string $pattern = null): Cookie|FacebookWebdriverCookie|null
protected function grabWordPressLoginCookie(?string $pattern = null): Cookie|FacebookWebdriverCookie|null
{
$pattern = $pattern ?: '/^wordpress_logged_in_[a-z0-9]{32}$/';
$cookies = $this->grabCookiesWithPattern($pattern);
Expand Down Expand Up @@ -365,7 +365,7 @@ public function seeMessage(array|string $classes = ''): void
*
* @return Cookie|null Either a cookie object or `null`.
*/
public function grabWordPressTestCookie(string $name = null): ?Cookie
public function grabWordPressTestCookie(?string $name = null): ?Cookie
{
$name = $name ?: 'wordpress_test_cookie';

Expand Down Expand Up @@ -410,7 +410,7 @@ public function amOnAdminPage(string $page): void
*
* @param string|array<string,mixed> $queryVars A string or array of query variables to append to the AJAX path.
*/
public function amOnAdminAjaxPage(string|array $queryVars = null): void
public function amOnAdminAjaxPage(string|array|null $queryVars = null): void
{
$path = 'admin-ajax.php';
if ($queryVars !== null) {
Expand All @@ -431,7 +431,7 @@ public function amOnAdminAjaxPage(string|array $queryVars = null): void
*
* @param string|array<string,mixed> $queryVars A string or array of query variables to append to the Cron path.
*/
public function amOnCronPage(string|array $queryVars = null): void
public function amOnCronPage(string|array|null $queryVars = null): void
{
$path = 'wp-cron.php';
if ($queryVars !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Module/WPCLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function grabLastShellErrorOutput(): string
*/
public function cliToArray(
array $command,
callable $splitCallback = null,
?callable $splitCallback = null,
?array $env = null,
mixed $input = null
): array {
Expand Down
26 changes: 13 additions & 13 deletions src/Module/WPDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class WPDb extends Db
*
* @return void
*/
public function __construct(ModuleContainer $moduleContainer, ?array $config = null, DbDump $dbDump = null)
public function __construct(ModuleContainer $moduleContainer, ?array $config = null, ?DbDump $dbDump = null)
{
parent::__construct($moduleContainer, $config);
$this->dbDump = $dbDump ?? new DbDump();
Expand Down Expand Up @@ -347,7 +347,7 @@ protected function validateConfig(): void
*
* @throws ModuleException It the database cannot be correctly initialized.
*/
public function _initialize(Tables $table = null): void
public function _initialize(?Tables $table = null): void
{
/**
* Dispatches an event before the WPDb module initializes.
Expand Down Expand Up @@ -387,7 +387,7 @@ public function _initialize(Tables $table = null): void
*
* @throws ModuleConfigException|ModuleException If there's an issue during the cleanup phase.
*/
public function importSqlDumpFile(string $dumpFile = null): void
public function importSqlDumpFile(?string $dumpFile = null): void
{
if ($dumpFile !== null) {
if (!is_file($dumpFile) || !is_readable($dumpFile)) {
Expand Down Expand Up @@ -421,7 +421,7 @@ public function importSqlDumpFile(string $dumpFile = null): void
*
* @throws ModuleException|ModuleConfigException If there's a configuration or operation issue.
*/
public function _cleanup(string $databaseKey = null, array $databaseConfig = null): void
public function _cleanup(?string $databaseKey = null, ?array $databaseConfig = null): void
{
parent::_cleanup($databaseKey, $databaseConfig);
$this->blogId = 0;
Expand Down Expand Up @@ -602,8 +602,8 @@ public function dontSeePostMetaInDatabase(array $criteria): void
public function seePostWithTermInDatabase(
int $post_id,
int $term_taxonomy_id,
int $term_order = null,
string $taxonomy = null
?int $term_order = null,
?string $taxonomy = null
): void {
if ($taxonomy !== null) {
$match = $this->grabTermTaxonomyIdFromDatabase([
Expand Down Expand Up @@ -3571,7 +3571,7 @@ public function dontSeeBlogInDatabase(array $criteria): void
* @param string|null $themeName The theme name, e.g. `Acme`, defaults to the "title" version of
* `$stylesheet`.
*/
public function useTheme(string $stylesheet, string $template = null, string $themeName = null): void
public function useTheme(string $stylesheet, ?string $template = null, ?string $themeName = null): void
{
$template = $template ?: $stylesheet;
$themeName = $themeName ?: ucwords($stylesheet, ' _');
Expand Down Expand Up @@ -3651,7 +3651,7 @@ public function haveMenuInDatabase(string $slug, string $location, array $overri
public function haveMenuItemInDatabase(
string $menuSlug,
string $title,
int $menuOrder = null,
?int $menuOrder = null,
array $meta = []
): int {
if (empty($this->stylesheet)) {
Expand Down Expand Up @@ -3748,7 +3748,7 @@ public function haveAttachmentInDatabase(
string $file,
string|int $date = 'now',
array $overrides = [],
array $imageSizes = null
?array $imageSizes = null
): int {
if (!class_exists(ImageResize::class)) {
$message = 'The "haveAttachmentInDatabase" method requires the "gumlet/php-image-resize:^1.6" package.' .
Expand Down Expand Up @@ -3899,7 +3899,7 @@ public function haveAttachmentInDatabase(
*
* @return string The current site URL
*/
public function grabSiteUrl(string $path = null): string
public function grabSiteUrl(?string $path = null): string
{
/** @var array{url: string} $config Validated module config. */
$config = $this->config;
Expand Down Expand Up @@ -4490,7 +4490,7 @@ protected function loadDumpUsingDriver(string $databaseKey): void
* @param string|null $databaseKey The key of the database to load.
* @param array<string,mixed>|null $databaseConfig The configuration for the database to load.
*/
public function _loadDump(string $databaseKey = null, array $databaseConfig = null): void
public function _loadDump(?string $databaseKey = null, ?array $databaseConfig = null): void
{
parent::_loadDump($databaseKey, $databaseConfig);
$this->prepareDb();
Expand Down Expand Up @@ -4525,8 +4525,8 @@ public function _loadDump(string $databaseKey = null, array $databaseConfig = nu
public function dontSeePostWithTermInDatabase(
int $post_id,
int $term_taxonomy_id,
int $term_order = null,
string $taxonomy = null
?int $term_order = null,
?string $taxonomy = null
): void {
if ($taxonomy !== null) {
$match = $this->grabTermTaxonomyIdFromDatabase([
Expand Down
Loading