prettier / prettier/plugin-php

Case build-in classes

Open
#196 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion enhancement needs investigation
Dominant language
PHP
Stars
1.9k
Forks
139
PR merge metrics
No merged PRs in 30d

Description

Ref: http://php.net/manual/en/reserved.classes.php
In php allowed use any case of build-in class:

$exception = new Exception('Message');
$exception = new EXCEPTION('Message');
$exception = new eXcEpTiOn('Message');

Always return exception build-in class.
Should we prettify class names? Also don't forget about namespaces.

  1. File without namespace - new Exception() === new \Exception();.
  2. File with namespace - new Exception !== new \Exception.

In theory we can do it:

  1. If namespace exists only correct new \Exception();
  2. If namespace doesn't exists correct and new Exception() and new \Exception();

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

Start by reviewing the issue's PHP examples and the reserved-class and namespace rules it references. Done requires an agreed, namespace-aware decision for handling built-in class names in both namespaced and non-namespaced files, followed by implementation and coverage in the relevant formatter tests.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.