Problem/Motivation
At composer install I get following warnings :
PHP Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getPossibleOptions(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 162
Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getPossibleOptions(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 162
PHP Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getPossibleValues(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 183
Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getPossibleValues(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 183
PHP Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getSettableOptions(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 195
Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getSettableOptions(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 195
PHP Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getSettableValues(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 230
Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItem::getSettableValues(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItem.php on line 230
PHP Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItemInterface::getSettableOptions(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItemInterface.php on line 62
Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItemInterface::getSettableOptions(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItemInterface.php on line 62
PHP Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItemInterface::getSettableValues(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItemInterface.php on line 76
Deprecated: Drupal\view_mode_switch\Plugin\Field\FieldType\ViewModeSwitchItemInterface::getSettableValues(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/view_mode_switch/src/Plugin/Field/FieldType/ViewModeSwitchItemInterface.php on line 76
Steps to reproduce
composer require 'drupal/view_mode_switch:^2.1'
on Drupal 11.3
Comments
Comment #2
debdeep.mukhopadhyay commentedI am working on this.
Comment #3
debdeep.mukhopadhyay commented@g4mbini
I tested this locally with DDEV (PHP 8.3) and view_mode_switch 2.1.1.
I updated the nullable $account parameters in
ViewModeSwitchItem.php and verified in the UI by adding a View mode switch field to the Article content type and creating a node (/node/add/article). The field works correctly and no errors occur.
It is working fine on my local setup.
Comment #4
hctomThanks for the catch. This is somewhat related to #3502724: Fix code quality issues reported by PHPStan, so linking it here as well.
@debdeep.mukhopadhyay: Unfortunately I do not see any changes in the issue fork to review. Did you forget to commit them?
Comment #5
debdeep.mukhopadhyay commented@hctom Thank you for your message.
I did not add any new commits, because the changes are already present in the issue branch/fork. That is why you do not see additional commits from my side.
Please let me know if I can help further. I will be happy to do so.
Comment #6
hctom@debdeep.mukhopadhyay There are no changes in the issue fork ;)
https://git.drupalcode.org/issue/view_mode_switch-3570280/-/compare/2.x....
That's why I'm asking... Or am I missing something?
Comment #8
hctomAhhhh... now I understand what's going on here ;) The required changes for fixing the deprecated code are already included in the dev release of the module. I did not release them yet, because I wanted to fix #3502724: Fix code quality issues reported by PHPStan first ;)
...but I found some inconsistencies in the
@paramdocs not naming the possibleNULLvalues, which I'll fix with this issue.@g4mbini: Please use the dev release for now and I'll try to get the code issues from the other ticket fixed asap to release a new version.
Comment #10
hctomClosing this issue as fixed, because the dev release already has all required changes
Comment #12
hctomComment #13
debdeep.mukhopadhyay commented@hctom Thank you very much for the fix and for the clarification.
I verified the changes locally using DDEV with PHP 8.3 and tested the View mode switch field on a node form to confirm that everything is working as expected.
If appropriate, I would be grateful if my local testing and verification could be credited.
Please let me know if I can help further in any way.
Comment #14
hctom@debdeep.mukhopadhyay: Sorry, I thought I already credited all of you by creating the commit message via the contribution record... haven't been committing/merging things since the credit system update and was quite confused about the new UI, which does not really explain what to do where... and I am still confused, why I can put all the credits into the commit message, but they are actually not used for crediting.
So I hope, I have done it right now and you got your credits ;)
Comment #15
g4mbiniThanks guys !
@hctom I hope you are doing good since Barcelona !