Problem/Motivation

I am trying to check for errors via phpcs and PHPCompatibility standard on a drupal project, here is the command:

phpcs -p /MODULE/ --standard=PHPCompatibility --runtime-set testVersion 8.0 --extensions=php,module,inc,install,test,profile,theme

The command works fine. However, I am supposed to receive following error

"FILE: /contrib/content_sync/src/Form/ContentImportTrait.php
----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------
  55 | WARNING | Declaring a required parameter after an optional one is deprecated since PHP 8.0. Parameter $serializer_context is optional, while parameter $context is required.
 116 | WARNING | Declaring a required parameter after an optional one is deprecated since PHP 8.0. Parameter $serializer_context is optional, while parameter $context is required.
----------------------------------------------------------------------------------------------------------------


FILE: /content_sync/src/Form/ContentExportTrait.php
----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------
 85 | WARNING | Declaring a required parameter after an optional one is deprecated since PHP 8.0. Parameter $serializer_context is optional, while parameter $context is required.
----------------------------------------------------------------------------------------------------------------"

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#5 3270665_php8_compatibility.patch1.69 KBuniquename
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

eugeney created an issue. See original summary.

eugeney’s picture

Issue summary: View changes
avpaderno’s picture

Category: Feature request » Task
liam morland’s picture

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

StatusFileSize
new1.69 KB

I had similar deprecation notices, when installing and uninstalling the module with drush.

I've found that those functions are only called when generating the batch and from there $serializer_context is always set. So I just made $serializer_context mandatory in the function print and the notice went away.

avpaderno’s picture

Status: Active » Needs review
kliker’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3300347: Deprecated warnings when using drush and PHP 8

Patch fixes deprecation notices.

Tested config-status, config-export, config-import commands and everything works well.

guido_s’s picture

@Blanca.Esqueda This issue could be closed in favor of Drupal 10 compatibility update as this also includes those changes in its merge request.

foxy-vikvik made their first commit to this issue’s fork.

blanca.esqueda’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Closing this task as duplicate of https://www.drupal.org/project/content_sync/issues/3330173

Thanks: uniquename, foxy-vikvik, eugeney, avpaderno, liam morland, kliker, guido_s