WordPress / WordPress/WordPress-Coding-Standards

Review how docblock class imports are handled

Open
#2,358 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Documentation Type: Question
Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Description

I noticed that in the docblocks we are unsing FQCN when adding types to the parameters. We are also importing those at the top of the file.

In most of the editors, the editor is smart enough that it will know to what class/interface we are referring to.

So we should consider maybe shortening the FQCNs in the docblocks?

Example:

<?php
...

namespace WordPressCS\WordPress\Helpers;

use PHP_CodeSniffer\Files\File;
...
// Later in the class/trait/interface:
	/**
	 * ...
	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.

Could be written as:

<?php
...

namespace WordPressCS\WordPress\Helpers;

use PHP_CodeSniffer\Files\File;
...
// Later in the class/trait/interface:
	/**
	 * ...
	 * @param File $phpcsFile The file being scanned.

As the File is imported at the top of the file.

Thoughts?

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.

Research direction

Review the repository's PHP docblocks and their top-level imports, using the issue's PHP_CodeSniffer\Files\File example as the starting point. The work is done when the project has a decided convention for imported docblock types and the affected usages follow it consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.