Add an empty line at end of file according to PSR-2 on PhpStorm
You already have two answers for how to turn it on for ALL file types in IDE (in short: Settings/Preferences | Editor | General -> Ensure line feed at file end on Save
).
In modern version (2020.3) that option has been reworded a bit. Now it says Ensure every saved file ends with a line break
To do this for .php
files only you can do the following:
- Install EditorConfig plugin (if you do not have it installed yet). In modern versions it is already bundled and enabled by default.
- Create
.editorconfig
file in your project root (or whatever folder that would be where you want to apply such style -- it will be applied to files in this folder and below). If you have one already -- open and inspect it - Add rule for
*.php
files only -- property to use would beinsert_final_newline
An example:
[*.php]insert_final_newline = true
Links:
someone said picture speaks louder :D
you will need to tick the Ensure line feed at file end on save
box
In PhpStorm preferences go to:
Editor > General
Check the box "Other: Ensure line feed at file end on Save."
Just realize this affects all code files you edit in PhpStorm, not just PHP files.