prettier / prettier/plugin-php

`{` and `}` for variable property

Open
#790 1 comment 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Prettier 1.14.3

PHP Plugin 0.8.0

Input:

$var = $this->{$key};
$var = $this->value->{$method}();

Output:

$var = $this->$key;
$var = $this->value->$method();

Expected behavior:

Need vote

👍 for $this->{$key}
❤️ for $this->$key

I found what laravel, symfony and a lot of other projects use { and }, looks it is popular.

One note - we should respect { and } in source code, because it can be break php5 code http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.indirect.

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

Reproduce the reported input with Prettier 1.14.3 and PHP Plugin 0.8.0, then inspect how variable properties are formatted. The issue names no file or test and has no settled expected output; confirm the project’s decision about preserving the braces before defining completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.