ClassDeclaration
Checks the declaration of the class and its inheritance is correct.
Scope
Squiz.Classes.ClassDeclaration
Properties
Property Name | Type | Default | Available Since |
---|---|---|---|
indent | int | 4 | 1.3.5 |
Usage
xml
<rule ref="Squiz.Classes.ClassDeclaration">
<properties>
<property name="indent" value="2" />
</properties>
</rule>
Examples
Example 1
Valid: array keyword lowercase
php
$array = array('val1', 'val2');
Invalid: first letter capitalised
php
$array = Array('val1', 'val2');
Example 2
Valid: first key on second line
php
$array = array(
'key1' => 'value1',
'key2' => 'value2',
);
Invalid: first key on same line
php
$array = array('key1' => 'value1',
'key2' => 'value2',
);
Example 3
Valid: aligned correctly
php
$array = array(
'key1' => 'value1',
'key2' => 'value2',
);
Invalid: keys and parenthesis aligned incorrectly
php
$array = array(
'key1' => 'value1',
'key2' => 'value2',
);
Example 4
Valid: keys and values aligned
php
$array = array(
'keyTen' => 'ValueTen',
'keyTwenty' => 'ValueTwenty',
);
Invalid: alignment incorrect
php
$array = array(
'keyTen' => 'ValueTen',
'keyTwenty' => 'ValueTwenty',
);
Example 5
Valid: comma after each value
php
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
);
Invalid: no comma after last value
php
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
);