Let's say I want to type the following in PhpStorm:
$longObjectName->propertyName = 'some value';
Seems innocent enough, no? If I start typing longOb
, code completion kicks in and helpfully provides $longObjectName
as a suggestion, since it exists elsewhere in my project. I think to myself, "Ah perfect, that's exactly what I wanted", so I hit Enter or Tab to accept the suggestion. At this point, I'm feeling pretty happy.
But now I want to insert ->
, PHP's awkward but familiar object operator. If I type it manually, that's three whole keystrokes (including Shift), which makes me feel just a bit sad. A distant, nagging doubt begins to enter my mind. "Three keystrokes? What kind of evil IDE is this? Who are these ruthless dictators at JetBrains??"
The emotional roller coaster continues when I see the following in PhpStorm's Tip of the Day dialog, bringing a minuscule but insistent glimmer of hope to my dark, Monokai-schemed world:
When using Code Completion, you can accept the currently highlighted selection in the popup list with the period character (
.
), comma (,
), semicolon (;
), space and other characters.The selected name is automatically entered in the editor followed by the entered character.
In JavaScript, this means I can type longOb
and hit . to both accept the first code completion suggestion and insert the JS object operator, resulting in longObjectName.
, at which point I can keep typing a property name and go on autocompleting all day long without ever hitting Enter. Amazing. Revolutionary even.
Now for some devastating news: it doesn't seem to work in PHP. (Fret not children—this harrowing tale is almost at its end.)
If I type longOb
and then hit -, I get this:
longOb- // :(
I'm pretty sure the PHP interpreter wouldn't like me very much if I tried to execute that.
(Side note: ., ,, and ; exhibit pretty much the same behavior, contrary to the quoted Tip of the Day above.)
So here's what I would get if I were to make my fantasy world a reality:
$longObjectName->[handy dandy code completion list, primed and ready for action]
Wouldn't that be flipping awesome?
So finally, we arrive at the ultimate question, with some redundant stuff added for those who didn't bother to read my action-packed, heartwrenching story:
Is there a single keyboard shortcut in PhpStorm for "Accept the currently highlighted code completion suggestion and insert the PHP object operator (->
)"?
Or is this just a bug?