Auto indent with php 8.0

Hello,
with PHP 8, since we can declare variable name in function calls , i tried to use this functionnaly with the "auto-indent" functionnaly.

Actually when i use the auto indent function, the result is : 

    return new Node\Stmt\Expression(
expr: new Node\Expr\Assign(
var: new Node\Expr\Variable('base'),
expr: new Node\Expr\New_(
class: new Node\Name\FullyQualified('SQLiteDatabase'),
args: [
new Node\Arg($this->file),
],
),
),
);
}

And I would like it look like this :

return new Node\Stmt\Expression(
expr: new Node\Expr\Assign(
var: new Node\Expr\Variable('base'),
expr: new Node\Expr\New_(
class: new Node\Name\FullyQualified('SQLiteDatabase'),
args: [
new Node\Arg($this->file),
],
),
),
);

All I want is that the line start at the same position than the cursor when I press enter at the end of the line like this:


How can I achieve this ? 


Thank you

Thank you.

0
9 comments

Could you please check if the behavior is any different in version 2021.2 EAP: http://www.jetbrains.com/phpstorm/eap/?

0

Yes, it just add a space between var: and new :

return new Node\Stmt\Expression(
expr: new Node\Expr\Assign(
var: new Node\Expr\Variable('base'),
expr: new Node\Expr\New_(
class: new Node\Name\FullyQualified('SQLiteDatabase'),
args: [
new Node\Arg($this->file),
],
),
),
);
0

Try to open File | Settings | Editor | Code Style | PHP > Wrapping and Braces tab and disable "Align when multiline" for function/constructor call argument:

0

Hello,

now I have this result : 

 

return new Node\Stmt\Expression(
expr: new Node\Expr\Assign(
var: new Node\Expr\Variable('base'),
expr: new Node\Expr\New_(

class: new Node\Name\FullyQualified('SQLiteDatabase'),
args: [
new Node\Arg($this->file),
],
),
),
);
0

Could you please export your code style & share it somehow? You can drop it at https://uploads.jetbrains.com/

0

There is a the id of the upload.

Upload id: 2021_07_19_JcvzviZSwZPTvL9E (file: Default.xml)

0

Thanks. Please try to import this scheme: https://drive.google.com/file/d/1TfX4Az-FktqW8RrTHytrxexnILzRZr_w/view?usp=sharing

 

It's based on your with a couple of adjustments.

0

Hello, 
Thank you very much, it worked !
This is only working with this scheme and PhpStorm 2021.2-EAP and next releases I guess.

Advanced information about version :


PhpStorm 2021.2 Beta
Build #PS-212.4746.20, built on July 14, 2021

0

Oh yeah, sorry, forgot to mention that 2021.2 is required: one of the formatting options is available only starting ver. 2021.2.

Happy to hear this is working as expected now.

0

Please sign in to leave a comment.