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
Comments
Comment #2
eugeney commentedComment #3
avpadernoComment #4
liam morlandComment #5
uniquename commentedI 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.
Comment #6
avpadernoComment #7
kliker commentedPatch fixes deprecation notices.
Tested config-status, config-export, config-import commands and everything works well.
Comment #8
guido_s@Blanca.Esqueda This issue could be closed in favor of Drupal 10 compatibility update as this also includes those changes in its merge request.
Comment #10
blanca.esqueda commentedClosing 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