Problem/Motivation

When using bundle classes, if creating an object with MyCustomLibary::createFromParagraph, type returned will be the interface, instead of the the called class.

Steps to reproduce

w PHPStan

$entity = MyCustomLibary::createFromParagraph();
\PHPStan\dumpType($libraryItem);

Outputs:

phpstan: Dumped type: Drupal\paragraphs_library\LibraryItemInterface

With changes, output is:

phpstan: Dumped type: Drupal\mymodule\MyCustomLibary

Issue fork paragraphs-3345127

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpi created an issue. See original summary.

dpi’s picture

Status: Active » Needs review
acbramley’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @dpi!

Berdir made their first commit to this issue’s fork.

  • Berdir committed a73a12a2 on 8.x-1.x authored by dpi
    Issue #3345127: Fix LibraryItemInterface return types
    
Berdir’s picture

Status: Reviewed & tested by the community » Fixed

Merged.

Status: Fixed » Closed (fixed)

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