Fatal error: submitConfigurationForm() must be compatible with BlockBase::submitConfigurationForm(): void

Created on 11 July 2025, about 1 month ago

Problem/Motivation

Fatal error when using the module on PHP 8+ due to missing return type in submitConfigurationForm:

Fatal error: Declaration of Drupal\cookies\Plugin\Block\CookiesDocsBlock::submitConfigurationForm(array &$form, Drupal\Core\Form\FormStateInterface $form_state) must be compatible with Drupal\Core\Block\BlockBase::submitConfigurationForm(array &$form, Drupal\Core\Form\FormStateInterface $form_state): void

Steps to reproduce

  1. Enable the Cookies module in a Drupal site running PHP 8+
  2. Access a page rendering the CookiesDocsBlock

Proposed resolution

Update the method to match the signature of the parent class:

diff --git a/src/Plugin/Block/CookiesDocsBlock.php b/src/Plugin/Block/CookiesDocsBlock.php
index 23039b7..cececbe 100644
--- a/src/Plugin/Block/CookiesDocsBlock.php
+++ b/src/Plugin/Block/CookiesDocsBlock.php
@@ -155,7 +155,7 @@ class CookiesDocsBlock extends BlockBase implements ContainerFactoryPluginInterf
   /**
    * {@inheritdoc}
    */
-  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
+  public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void {
     $this->configuration['show_cookies_settings_button'] = $form_state->getValue('show_cookies_settings_button');
     parent::submitConfigurationForm($form, $form_state);
   }

Remaining tasks

  • Review and commit patch

User interface changes

None

API changes

None

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024