Problem/Motivation

Php 8 is not supporting a required parameter after an optional one in method declaration and giving the below warnings in phpcs compatibility check

FILE: /var/www/docroot/sites/all/modules/contrib/migrate/migrate_ui/migrate_ui.pages.inc
------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------
568 | WARNING | Declaring a required parameter after an optional one is deprecated since PHP 8.0. Parameter
    |         | $force is optional, while parameter $context is required.
------------------------------------------------------------------------------------------

Proposed resolution

Proposing the attached patch to fix the issue

Comments

suvasish.manna created an issue. See original summary.

suvasish.manna’s picture

StatusFileSize
new627 bytes
suvasish.manna’s picture

Assigned: suvasish.manna » Unassigned
liam morland’s picture

Issue tags: -PHP 8.0 compatibility +PHP 8.0
damienmckenna’s picture

Title: Php 8 Compatibility Issue » PHP 8.0 compatibility Issue: migrate_ui_batch() arguments
joelpittet’s picture

Status: Active » Needs work

If the argument is NULL it should be converted $force = $force ? $force : FALSE; to be equivalent.

liam morland’s picture

Status: Needs work » Needs review

The patch is fine as it is. $force always has to be set anyway because $context has to be set. Dropping the default does not change how the code behaves.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

@Liam Morland, oh I was under the assumption NULL as the argument value and prior to this patch it would have defaulted to FALSE, but the default keeps the the value as NULL.

TIL https://3v4l.org/nih2k

joseph.olstad’s picture

Issue tags: +PHP 8.1, +PHP 8.2

pifagor’s picture

Status: Reviewed & tested by the community » Fixed
joseph.olstad’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.