Skip to content

Files

Latest commit

 

History

History
43 lines (31 loc) · 1.15 KB

Squiz.ControlStructures.ControlSignature.md

File metadata and controls

43 lines (31 loc) · 1.15 KB

Pattern: Malformed control statement

Issue: -

Description

Verifies that control statements conform to their coding standards.

Configuration

By default, the rule ensures there is one space before the opening brace for control structures using standard syntax, and one space before the colon for control structures using alternative syntax, as shown in the following code snippet:

if ($foo) :
    // IF body.
else :
    // ELSE body.
endif;

A common way of defining control structures using alternative syntax is to put no padding before the colon, as shown in the following code snippet:

if ($foo):
    // IF body.
else:
    // ELSE body.
endif;

If you prefer to write your code like this, you can set the requiredSpacesBeforeColon property to 0.

<rule ref="Squiz.ControlStructures.ControlSignature">
    <properties>
        <property name="requiredSpacesBeforeColon" value="0" />
    </properties>
</rule>

Further Reading