Subsequent lines are indented one level deeper than the initial lineĬontent of PHP blocks is indented from the beginning of the line, the open tag is not movedīody of a declarations starts on a new line, while control flow block starts on the same line as the construct This formatting style is compliant with PSR-1 and PSR-2 standards. Subsequent lines maintain their indentation from the first line.Ĭontents of PHP blocks is indented from the open tag ( This style focuses on leaving the code visual structure as untouched as possible, while normalizing the whitespaces where possible. 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 selection formatting of the code preceeding 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |