Newlines
February 27, 2025 ยท View on GitHub
The token lists below are validated by the TokenIndex unit test, so any
changes to structure or syntax must be reflected there.
Mixed
After
By default, newlines are allowed after:
T_ATTRIBUTET_ATTRIBUTE_COMMENTT_CLOSE_BRACET_COLON(except ternary operators)T_COMMAT_COMMENTT_DOC_COMMENTT_DOUBLE_ARROW(except in arrow functions ifNewlineBeforeFnDoubleArrowis enabled)T_EXTENDST_IMPLEMENTST_OPEN_BRACET_OPEN_BRACKETT_OPEN_PARENTHESIST_OPEN_TAGT_OPEN_TAG_WITH_ECHOT_SEMICOLON- Assignment operators
- Boolean operators (except
T_LOGICAL_NOT) -&&,||,and,or,xor - Comparison operators (except
T_COALESCE)
Before
They are also allowed before:
T_ATTRIBUTET_ATTRIBUTE_COMMENTT_CLOSE_BRACKETT_CLOSE_PARENTHESIST_CLOSE_TAGT_COALESCET_CONCATT_DOUBLE_ARROW(in arrow functions ifNewlineBeforeFnDoubleArrowis enabled)T_LOGICAL_NOTT_NULLSAFE_OBJECT_OPERATORT_OBJECT_OPERATOR- Arithmetic operators
- Bitwise operators -
&,^,|,~,<<,>> - Ternary operators
Operators first
If --operators-first is given, newlines are allowed before, and not after,
boolean operators and comparison operators.
After
T_ATTRIBUTET_ATTRIBUTE_COMMENTT_CLOSE_BRACET_COLON(except ternary operators)T_COMMAT_COMMENTT_DOC_COMMENTT_DOUBLE_ARROW(except in arrow functions ifNewlineBeforeFnDoubleArrowis enabled)T_EXTENDST_IMPLEMENTST_OPEN_BRACET_OPEN_BRACKETT_OPEN_PARENTHESIST_OPEN_TAGT_OPEN_TAG_WITH_ECHOT_SEMICOLON- Assignment operators
Before
T_ATTRIBUTET_ATTRIBUTE_COMMENTT_CLOSE_BRACKETT_CLOSE_PARENTHESIST_CLOSE_TAGT_CONCATT_DOUBLE_ARROW(in arrow functions ifNewlineBeforeFnDoubleArrowis enabled)T_NULLSAFE_OBJECT_OPERATORT_OBJECT_OPERATOR- Arithmetic operators
- Bitwise operators -
&,^,|,~,<<,>> - Boolean operators -
!,&&,||,and,or,xor - Comparison operators
- Ternary operators
Operators last
With --operators-last, newlines are allowed after, and not before,
T_CONCAT, arithmetic operators and bitwise operators.
After
T_ATTRIBUTET_ATTRIBUTE_COMMENTT_CLOSE_BRACET_COLON(except ternary operators)T_COMMAT_COMMENTT_CONCATT_DOC_COMMENTT_DOUBLE_ARROW(except in arrow functions ifNewlineBeforeFnDoubleArrowis enabled)T_EXTENDST_IMPLEMENTST_OPEN_BRACET_OPEN_BRACKETT_OPEN_PARENTHESIST_OPEN_TAGT_OPEN_TAG_WITH_ECHOT_SEMICOLON- Arithmetic operators
- Assignment operators
- Bitwise operators -
&,^,|,~,<<,>> - Boolean operators (except
T_LOGICAL_NOT) -&&,||,and,or,xor - Comparison operators (except
T_COALESCE)
Before
T_ATTRIBUTET_ATTRIBUTE_COMMENTT_CLOSE_BRACKETT_CLOSE_PARENTHESIST_CLOSE_TAGT_COALESCET_DOUBLE_ARROW(in arrow functions ifNewlineBeforeFnDoubleArrowis enabled)T_LOGICAL_NOTT_NULLSAFE_OBJECT_OPERATORT_OBJECT_OPERATOR- Ternary operators