Plugin-php: `{` and `}` for variable property

Created on 12 Oct 2018  ·  1Comment  ·  Source: prettier/plugin-php

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

:+1: for $this->{$key}
:heart: 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.

discussion enhancement

Most helpful comment

My 2c: It's not often that I write code like this - usually it's a typo or copy/paste error, so adding curly braces would make it more explicit and obvious what is happening.

>All comments

My 2c: It's not often that I write code like this - usually it's a typo or copy/paste error, so adding curly braces would make it more explicit and obvious what is happening.

Was this page helpful?
0 / 5 - 0 ratings