False Positive: Drupal.Commenting.VariableComment.IncorrectVarType Disjunctive Normal Form Types

Created on 18 October 2023, 8 months ago

Problem/Motivation

False positive when using disjunctive normal form types in PHPDoc

Drupal.Commenting.VariableComment.IncorrectVarType: Expected "\Drupal\user\UserInterface&\PHPUnit\Framework\MockObject\MockObject|null" but found "(\Drupal\user\UserInterface&\PHPUnit\Framework\MockObject\MockObject)|null" for @var tag in member variable comment

Note: this can't be solved by strict type hinting because DNF was not added until PHP8.2.

Steps to reproduce

  /**
   * Mock entity for the user that is attempting to login.
   *
   * @var (\Drupal\user\UserInterface&\PHPUnit\Framework\MockObject\MockObject)|null
   */
  protected $userMock;

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

8.3

Component

Coder Sniffer

Created by

πŸ‡ΊπŸ‡ΈUnited States cmlara

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024