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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | change_type_hints_in_inline_entity_form_api_php_to_align_with_drupal_core-3204518-002.patch | 1.44 KB | stefan.korn |
Comments
Comment #2
stefan.kornComment #3
podaroktnx
Comment #5
podarokComment #7
geek-merlinBulk reopen.
Comment #8
geek-merlinComment #9
geek-merlinReasonable changes in the .api.php file, so no regression risk.
Comment #11
geek-merlinWoot.