In src/Helpers/GeneratedContentHelper.php

  public static function getInstance(): GeneratedContentHelper {
    if (empty(self::$instances[static::class])) {
      // @phpstan-ignore-next-line
      self::$instances[static::class] = \Drupal::service('class_resolver')
        ->getInstanceFromDefinition(static::class);
    }
    // @phpstan-ignore-next-line
    return self::$instances[static::class];
  }

When this class is extended and a GeneratedContentHelper's method is overridden, the MyHelper::getInstance() returns an instance of the code>GeneratedContentHelper class rather than MyHelper.

This is because GeneratedContentHelper returned instead of static. Similar with return self::$instances[static::class]; - should be return static::$instances[static::class];.

Comments

alex.skrypnyk created an issue. See original summary.

  • alex.skrypnyk committed 3c845a96 on 1.x
    feat: #3551385 When Helper extended, getInstance() does not return an...
alex.skrypnyk’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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