Change type hints in inline_entity_form.api.php to align with Drupal core

Created on 19 March 2021, over 3 years ago
Updated 21 January 2024, 11 months ago

Problem/Motivation

With #3121913: Type hints missing for some $form, $form_state variables β†’ type hints where added at several places, in inline_entity_form.api.php too. Adding the type hints the way it is done in inline_entity_form.api.php can lead to this error if implementing the hook in your module using IDE autocompletion (PHPStorm):
TypeError: Argument 2 passed to your_module_inline_entity_form_entity_form_alter() must be an instance of FormStateInterface, object given
This happens because the type hint in the api file is only given in the comment and IDE autocompletion will not get this.

Looking at form.api.php as reference, I can see that the type hints are added to the function declaration here. While this maybe discouraged in general in favor of USE statements, I suppose the api.php is a special case and would propose to do in in Inline Entity Form the same way Drupal Core does it.

Steps to reproduce

Use hook_inline_entity_form_entity_form_alter() in your module with IDE autocompletion (PHPStorm)

Proposed resolution

Patch

Remaining tasks

Create patch

User interface changes

none

API changes

none

Data model changes

none

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany stefan.korn Jossgrund

Live updates comments and jobs are added and updated live.
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