-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Describe the bug
phpcbf will format multiline ternaries to the same level of indentation, instead of having the lines after the first indented an additional level.
Code sample
<?php
$x = $a === $b
? true
: false;Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="exact" value="true" />
</properties>
</rule>
</ruleset>To reproduce
Steps to reproduce the behavior:
- Create a file called
test.phpwith the code sample above... - Run
phpcs test.php ... - See error message displayed
-----------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------
4 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
| | (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
5 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
| | (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------
Expected behavior
Multiline ternaries should be indented
Versions (please complete the following information):
- OS: MacOS 12.5
- PHP: 7.4
- PHPCS: 3.7.1
- Standard: n/a
Additional context
n/a
hlib-kuznetsov and ErikBrendel