Failed Conditions
Push — phpcs-3-upgrade ( d91341 )
by Alexander
02:06
created

ClassDeclarationUnitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 101
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getErrorList() 0 56 1
A getWarningList() 0 4 1
1
<?php
2
/**
3
 * CodingStandard_Tests_Classes_ClassDeclarationUnitTest.
4
 *
5
 * PHP version 5
6
 *
7
 * @category PHP
8
 * @package  PHP_CodeSniffer
9
 * @author   Alexander Obuhovich <[email protected]>
10
 * @license  https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause
11
 * @link     https://github.com/aik099/CodingStandard
12
 */
13
14
namespace CodingStandard\Tests\Classes;
15
16
use TestSuite\AbstractSniffUnitTest;
17
18
/**
19
 * Unit test class for the ClassDeclaration sniff.
20
 *
21
 * A sniff unit test checks a .inc file for expected violations of a single
22
 * coding standard. Expected errors and warnings are stored in this class.
23
 *
24
 * @category PHP
25
 * @package  PHP_CodeSniffer
26
 * @author   Alexander Obuhovich <[email protected]>
27
 * @license  https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause
28
 * @link     https://github.com/aik099/CodingStandard
29
 */
30
class ClassDeclarationUnitTest extends AbstractSniffUnitTest
31
{
32
33
34
    /**
35
     * Returns the lines where errors should occur.
36
     *
37
     * The key of the array should represent the line number and the value
38
     * should represent the number of errors that should occur on that line.
39
     *
40
     * @param string $testFile Name of the file with test data.
41
     *
42
     * @return array(int => int)
43
     */
44
    public function getErrorList($testFile)
45
    {
46
        $ret = array(
47
                // Extra space between interfaces, that a class implements.
48
                2   => 1,
49
                // No space after comma, when extending several classes or implementing several interfaces.
50
                // Class opening brace not on a new line.
51
                7   => 3,
52
                // The "extends" keyword isn't on same line as the class name.
53
                12  => 1,
54
                // The "implements" keyword isn't on same line as the class name.
55
                13  => 1,
56
                // Extra new line before class closing brace.
57
                17  => 1,
58
                // Extra space before extended class name or "implements" keyword.
59
                19  => 2,
60
                // Incorrect 1st implemented interface name indentation (when on separate line).
61
                20  => 1,
62
                // Incorrect 2nd implemented interface name indentation (when on separate line).
63
                21  => 1,
64
                // Class opening brace not on a new line right after definition.
65
                22  => 1,
66
                // Expected 1 space before "implements" keyword.
67
                // The first item in a multi-line implements list must be on the line following the implements keyword.
68
                27  => 2,
69
                // Incorrect 2nd implemented interface name indentation (when on separate line).
70
                34  => 1,
71
                // Several interfaces implemented on a line in multi-line class declaration.
72
                35  => 2,
73
                // Class declaration indented incorrectly.
74
                42  => 1,
75
                // Incorrectly indented interface names multi-line class declaration.
76
                44  => 1,
77
                // Incorrectly indented interface names multi-line class declaration.
78
                45  => 1,
79
                // No empty line after closing class brace. Incorrect class declaration indentation.
80
                48  => 2,
81
                // Comma placed not immediately after interface, when class implements several.
82
                63  => 1,
83
                // Incorrect extended interface indentation in multi-line interface declaration.
84
                116 => 1,
85
                // Incorrect extended interface indentation in multi-line interface declaration.
86
                118 => 1,
87
                119 => 1,
88
                // Expected 1 space between abstract and class keywords; newline found.
89
                124 => 1,
90
                130 => 2,
91
                131 => 1,
92
                // Too much empty lines after interface declaration.
93
                134 => 1,
94
                // Class closing brace must on it's own line and must have an empty line after it.
95
                142 => 1,
96
               );
97
98
        return $ret;
99
    }//end getErrorList()
100
101
102
    /**
103
     * Returns the lines where warnings should occur.
104
     *
105
     * The key of the array should represent the line number and the value
106
     * should represent the number of warnings that should occur on that line.
107
     *
108
     * @param string $testFile Name of the file with test data.
109
     *
110
     * @return array(int => int)
111
     */
112
    public function getWarningList($testFile)
113
    {
114
        return array();
115
    }//end getWarningList()
116
}//end class
117