Problem/Motivation

  /**
   * A mock of the `datetime.time` service.
   *
   * @var \Drupal\Component\Datetime\TimeInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected TimeInterface|MockObject $datetime;

The above is valid PHP8+ code however Coder generates `Missing member variable doc comment (Drupal.Commenting.VariableComment.Missing)` in case the member has a union types spec.

Steps to reproduce

class Test {
  protected int|float $var;
}

Analyze the above snippet with Coder.

Comments

BR0kEN created an issue. See original summary.

br0ken’s picture

arkener’s picture

Status: Active » Needs review

Created a PR to add support for union types, https://github.com/pfrenssen/coder/pull/143

br0ken’s picture

Status: Needs review » Reviewed & tested by the community

It works. Thanks for this 👍

  • Arkener authored 35a81ff on 8.3.x
    fix(VariableComment): Add support for union types (#3249360 by Arkener...
klausi’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks a lot!

Status: Fixed » Closed (fixed)

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