magento / magento/magento-coding-standard

Do not require DocBlock for typed class attributes

Open
#404 1 comment 9 reactions 1 assignee View on GitHub

@aligent-lturner is already working on this.

Since Jun 24, 2022.

enhancement Progress: PR created
Dominant language
PHP
Stars
375
Forks
165
PR merge metrics
No merged PRs in 30d

Description

### Description
Do not require a DocBlock for typed class attributes

### Expected behavior
Class attributes that have specified types should not require a DocBlock. When an attribute already has a type, the DocBlock is providing no new information, and is instead just creating noise - e.g.:
```
/** @var ProductRepositoryInterface */
private ProductRepositoryInterface $productRepository;
```
We already have the type information - we don't need the DocBlock to tell us the type.

I propose that the rule regarding class attributes requiring a `@var` annotation with a type be changed so that it only applies to attributes without a specified type.

### Benefits
Removes the need for redundant comments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.