Enforce block plugins returning an array

Created on 10 August 2020, over 4 years ago
Updated 1 December 2023, 12 months ago

Problem/Motivation

BlockPluginInterface::build() is documented as always returning an array.
When implementations do not return an array, the resulting bugs range from subtle errors to fatal whitescreens

Proposed resolution

Add return types to core block ::build() methods, add a deprecation warning to ::build() methods discovered without a return type, enforce the return type in Drupal 10.

Remaining tasks

Postponed on 🌱 [Meta] Implement strict typing in existing code Active

User interface changes

N/A

API changes

BlockPluginInterface::build() will require an array return type from Drupal 10.

Data model changes

N/A

Release notes snippet

Custom block plugins should now add the "array" return type to the ::build method.

πŸ“Œ Task
Status

Postponed

Version

11.0 πŸ”₯

Component
BlockΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024