1

I like for my PhpStorm (version 8.0.3) to show potential errors and bugs in glaring colors in order to prevent time from being wasted.

Recently, I often discover myself doing this kind of typo:

$this->$someExistingProperty = 'fnord'; 

This obviously means something entirely different than:

$this->someExistingProperty = 'fnord'; 

Is it possible to configure PhpStorm that it shows dynamically invoked properties and methods in a different color, e.g. pink?

It also would help if only the $ would appear in a different color, just like the semicolon.

Right now, I see it this way:

Screenshot of current syntax highlighting

Can I configure it and if so, where? I have searched through the Colors & Fonts tab for PHP but so far, without luck.

1
  • @LazyOne Current stable 8.0.3 Commented Jun 23, 2015 at 11:47

2 Answers 2

1

I didn't found any options to highlight the line you want, but you can highlight the other identifier (in bold by example) in the Language Defaults or PHP menu:

enter image description here

The result:

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Facinating. The Identifier is the correct setting, yet the foreground color gets ignored. Making it bold is indeed a valid workaround.
@k0pernikus Maybe because that color/style gets overwritten later? Have you checked that possibility?
@LazyOne I assume so, yet it is hard to determine which font color overwrites which.
1

It depends on your editor color scheme.

This is what I see with my custom scheme (based on Default).

<?php class TestClass { protected $someVar; protected $anotherVar; public function ddd() { $someVar = 'anotherVar'; $this->someVar = 123; $this->$someVar = 222; } } $z = new TestClass(); $z->ddd(); 

enter image description here

As you can see it's easy to tell what is what here.

The styles are "Identifier" and "Variable".


Although in general IDE should warn you about your $this->$someExistingProperty code -- because for that you have to have local $someExistingProperty variable defined...

This is what I see in v9 (note commented local $someVar line):

enter image description here


P.S. In v9 (currently in EAP stage but will be released soon (within few weeks -- sometime in July)) few more styles were introduced, e.g. "Instance Field" which should allow you to differentiate between local variable and class property.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.