Skip to content
On this page

ClosingTag

Checks that the file does not end with a closing tag.

Scope

PSR2.Files.ClosingTag

Usage

xml
<rule ref="PSR2.Files.ClosingTag"></rule>

Examples

Example 1

Valid: Case statement indented correctly.

php
switch ($foo) {
    case 'bar':
        break;
}

Invalid: Case statement not indented 4 spaces.

php
switch ($foo) {
case 'bar':
    break;
}

Example 2

Valid: Case statement followed by 1 space.

php
switch ($foo) {
    case 'bar':
        break;
}

Invalid: Case statement not followed by 1 space.

php
switch ($foo) {
    case'bar':
        break;
}

Example 3

Valid: Colons not prefixed by whitespace.

php
switch ($foo) {
    case 'bar':
        break;
    default:
        break;
}

Invalid: Colons prefixed by whitespace.

php
switch ($foo) {
    case 'bar' :
        break;
    default :
        break;
}

Example 4

Valid: Break statement indented correctly.

php
switch ($foo) {
    case 'bar':
        break;
}

Invalid: Break statement not indented 4 spaces.

php
switch ($foo) {
    case 'bar':
    break;
}

Example 5

Valid: Comment marking intentional fall-through.

php
switch ($foo) {
    case 'bar':
    // no break
    default:
        break;
}

Invalid: No comment marking intentional fall-through.

php
switch ($foo) {
    case 'bar':
    default:
        break;
}

Released under the MIT License.