The module has some compatibility problems with PHP 8.1 which were identified in the Date module.

Date.DateMigrateTestCase
✗	
include_once
exception: [Deprecated] Line 15 of sites/all/modules/migrate/includes/source.inc:
Return type of MigrateSource::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 15 of sites/all/modules/migrate/includes/source.inc:
Return type of MigrateSource::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 15 of sites/all/modules/migrate/includes/source.inc:
Return type of MigrateSource::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 15 of sites/all/modules/migrate/includes/source.inc:
Return type of MigrateSource::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 15 of sites/all/modules/migrate/includes/source.inc:
Return type of MigrateSource::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 864 of sites/all/modules/migrate/plugins/sources/xml.inc:
Return type of MigrateXMLReader::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 864 of sites/all/modules/migrate/plugins/sources/xml.inc:
Return type of MigrateXMLReader::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 864 of sites/all/modules/migrate/plugins/sources/xml.inc:
Return type of MigrateXMLReader::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 864 of sites/all/modules/migrate/plugins/sources/xml.inc:
Return type of MigrateXMLReader::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 864 of sites/all/modules/migrate/plugins/sources/xml.inc:
Return type of MigrateXMLReader::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 3567 of includes/bootstrap.inc:
Return type of MigrateSQLMap::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 3567 of includes/bootstrap.inc:
Return type of MigrateSQLMap::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 3567 of includes/bootstrap.inc:
Return type of MigrateSQLMap::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 3567 of includes/bootstrap.inc:
Return type of MigrateSQLMap::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

exception: [Deprecated] Line 3567 of includes/bootstrap.inc:
Return type of MigrateSQLMap::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
CommentFileSizeAuthor
#2 migrate-n3301821-2.patch5.64 KBdamienmckenna

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new5.64 KB

This adds the #[\ReturnTypeWillChange] line before each of the affected methods.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Some of the errors are fixed with #3253653: [PHP 8.0] ArgumentCountError: Too few arguments to function MigrationBase::errorHandler(), 4 passed and exactly 5 expected in MigrationBase->errorHandler() and these will help the date module tests to pass so RTBC as to keep the scope from duplicating fixes elsewhere.

cboyden’s picture

This fix for 8.1 is causing PHPCS errors for PHP 7.4:

Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]

joelpittet’s picture

@cboyden Maybe something wrong with the sniffer? Those should be treated as # comments in older versions of PHP.

avpaderno’s picture

Title: PHP 8.1 compatibility fixes for Migrate » Fix compatibility issues

PHP 7.4 will ignore the attributes, but that is fine; the code will work fine with PHP 7.4.

cboyden’s picture

@joelpittet this is the result when I run the dev version of PHPCompatibility, which is the only version that includes sniffs for PHP 8.x.

$ phpcs --standard=PHPCompatibility --runtime-set testVersion 7.4-8.1 --extensions=module/php,php/php,inc/php,theme/php,install/php .

FILE: plugins/sources/xml.inc
---------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------------------------------
  998 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 1020 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 1096 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 1107 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 1118 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
---------------------------------------------------------------------------------------------------------------------

FILE: plugins/sources/json.inc
----------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------
 231 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 265 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 376 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 386 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 396 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
----------------------------------------------------------------------------------------------------------------------

FILE: plugins/sources/sqlmap.inc
------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------
 701 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 727 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 738 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 747 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 767 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
------------------------------------------------------------------------------------------------------------------------

FILE: includes/source.inc
-----------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------
 229 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 240 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 249 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 259 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
 285 | ERROR | Attributes are not supported in PHP 7.4 or earlier. Found: #[\ReturnTypeWillChange]
-----------------------------------------------------------------------------------------------------------------

Time: 1.63 secs; Memory: 28MB
ronino’s picture

LOL, just submitted #3324432: PHP 8: Return type of MigrateSource::current() should either be compatible with Iterator::current(): mixed, or... and closed it as a duplicate shortly after. I guess we can't make the functions compatible as they need to work with PHP 5.3+. But this one works for me, too.

joseph.olstad’s picture

Issue tags: +PHP 8.2
liam morland’s picture

@cboyden #7 The sniffer has a bug. The attributes will be considered comment and the code will work.

@Ronino #8 What is stopping the code from working on all versions of PHO 5.3 and up? If that was the case, making the code compatible with PHP 8 is far more important than making it compatible with unsupported versions of PHP. Currently, the oldest version of PHP supported by the PHP community is PHP 8.0.

It would be helpful to enable automated tests on all supported versions of PHP: 8.0, 8.1, and 8.2.

joseph.olstad’s picture

I sent requests for attention and offer to co-maintain to two of the three migrate module maintainers, the other, the first one has no contact form.

I will follow up with the request for co-maintainer/maintainer process.

damienmckenna’s picture

Title: Fix compatibility issues » Fix PHP 8.1 compatibility issues
joseph.olstad’s picture

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.