Skip to content
On this page

AnonClassDeclaration

Checks that the declaration of an anon class is correct.

Scope

PSR12.Classes.AnonClassDeclaration

Properties

Property NameTypeDefaultAvailable Since
indentint43.5.0

Usage

xml
<rule ref="PSR12.Classes.AnonClassDeclaration">
    <properties>
        <property name="indent" value="2" />
    </properties>
</rule>

Examples

Example 1

Valid: One use declaration per namespace.

php
use \Foo;
use \Bar;

Invalid: Multiple namespaces in a use declaration.

php
use \Foo, \Bar;

Example 2

Valid: Use statements come after first namespace.

php
namespace \Foo;

use \Bar;

Invalid: Namespace declared after use.

php
use \Bar;

namespace \Foo;

Example 3

Valid: A single blank line after the final use statement.

php
use \Foo;
use \Bar;

class Baz
{
}

Invalid: No blank line after the final use statement.

php
use \Foo;
use \Bar;
class Baz
{
}

Released under the MIT License.