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

Comments

stefan.korn created an issue. See original summary.

stefan.korn’s picture

Assigned: stefan.korn » Unassigned
Status: Active » Needs review
StatusFileSize
new1.44 KB
podarok’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Fixed

tnx

  • podarok committed b8f9a85e on 2.0.x authored by stefan.korn
    Issue #3204518 by stefan.korn: Change type hints in inline_entity_form....
podarok’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

geek-merlin’s picture

Version: 2.0.x-dev » 3.0.0-rc15
Status: Closed (fixed) » Needs review
Related issues: +#3401656: Clean up problematic 2.x branch

Bulk reopen.

geek-merlin’s picture

Version: 3.0.0-rc15 » 3.x-dev
geek-merlin’s picture

Status: Needs review » Reviewed & tested by the community

Reasonable changes in the .api.php file, so no regression risk.

  • geek-merlin committed 97746612 on 3.x
    Issue #3204518 by stefan.korn: Change type hints in inline_entity_form....
geek-merlin’s picture

Status: Reviewed & tested by the community » Fixed

Woot.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.