
The default code style is compliant with the formatting in PHP Tools for Visual Studio.


Use declarations are not separated by empty lines, but an empty line is inserted after all the declarations.Įcho "hello" // the secod echo must be on a new lineĮcho "hello world" Code Style: PHP Tools ) always start on a new line.Īn empty line is inserted after a namespace declaration. The use construct in anonymous functions is always on the same line as the function keyword.Ĭlose keywords of control flow constructs ( endif, endfor.

The body is indented from the beginning of the line where the function keyword is defined. Subsequent lines are offset to match the first asterisk character on the first line Spaces are inserted after keywords, names and separators to make the code more readable.Ĭode is indented based on the number of embedded blocks. The styles share most features, summed up in the following table, while they differ in a couple of details, explained in their own sections. Preferred code style described in previous sections, available values are PHP Tools, PSR-2, or others described below.ĭocument formatting is available in two versions that differ in the way they structure the document: PHP Tools, PSR-2. Number of spaces that represent a single tab, this value is used only when editor.insertSpaces is trueĮnables or disables automatic formatting of code block upon typing or }. Spaces are used to indent code if true, tabs are used otherwise. All the relevant settings and their effects are summed up in the following table. The formatting behavior is set in settings.json. It indents the code and pretty-prints spaces. This feature performs the selection formatting of the code preceding the type delimiter.

Setting the option editor.formatOnType to true enables the editor to format code blocks and statements upon typing and }. The code formatting normalizes whitespaces, line endings, opening and closing braces, indentation and pretty print spaces. In order to format the document, it must be syntax-error free. Right-click the editor area and choose Format Document. The editor provides the document formatting feature for PHP documents.
