Proposal: Enable `global_namespace_import`

Open
#36 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
tooling

Research direction

Review the linked global_namespace_import documentation, especially example 3, then inspect the repository’s existing PHP-CS-Fixer configuration. Decide whether to enable it with import_classes, import_constants, and import_functions disabled, or adopt the alternative consistently; done means one agreed configuration is applied throughout.

Written by the indexing model from the issue text.

Description

enhancement

With configuration ['import_classes' => false, 'import_constants' => false, 'import_functions' => false]: https://cs.symfony.com/doc/rules/import/global_namespace_import.html#example-3

Main benefit for me would be exceptions, as it is a directly clear that a docblock like

/**
 * @throws Exception
 */

refers to \OCP\DB\Exception and not \Exception.
It would also safe some lines in the imports making them a bit more readable.

We could also switch it around, but I think we should settle on some configuration for this rule to have it the same everywhere.

Dominant language
PHP
Stars
14
Forks
2
PR merge metrics
No merged PRs in 30d

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.

More from nextcloud/coding-standard

All issues in nextcloud/coding-standard

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.