Skip to content
On this page

ObjectOperatorIndent

Checks that object operators are indented correctly.

Scope

PEAR.WhiteSpace.ObjectOperatorIndent

Description

Chained object operators when spread out over multiple lines should be the first thing on the line and be indented by 1 level.

Properties

Property NameTypeDefaultAvailable Since
indentint41.4.6
multilevelboolfalse3.5.0

Usage

xml
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent">
    <properties>
        <property name="multilevel" value="true" />
    </properties>
</rule>

Examples

Example 1

Valid: Object operator at the start of a new line.

php
$foo
    ->bar()
    ->baz();

Invalid: Object operator at the end of the line.

php
$foo->
    bar()->
    baz();

Example 2

Valid: Object operator indented correctly.

php
$foo
    ->bar()
    ->baz();

Invalid: Object operator not indented correctly.

php
$foo
->bar()
->baz();

Released under the MIT License.