Completed
Push — php70 ( 33bebb...e0e809 )
by Wim
02:48
created

NewGroupUseDeclarationsSniff   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 29
rs 10
wmc 3
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A process() 0 6 2
1
<?php
2
/**
3
 * PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff.
4
 *
5
 * PHP version 7.0
6
 *
7
 * @category  PHP
8
 * @package   PHPCompatibility
9
 * @author    Wim Godden <[email protected]>
10
 */
11
12
/**
13
 * PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff.
14
 *
15
 * @category  PHP
16
 * @package   PHPCompatibility
17
 * @author    Wim Godden <[email protected]>
18
 */
19
class PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff extends PHPCompatibility_Sniff
20
{
21
    /**
22
     * Returns an array of tokens this test wants to listen for.
23
     *
24
     * @return array
25
     */
26
    public function register()
27
    {
28
        return array(T_OPEN_USE_GROUP);
29
    }//end register()
30
31
32
    /**
33
     * Processes this test, when one of its tokens is encountered.
34
     *
35
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
36
     * @param int                  $stackPtr  The position of the current token in
37
     *                                        the stack passed in $tokens.
38
     *
39
     * @return void
40
     */
41
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
42
    {
43
        if (!$this->supportsAbove('7.0')) {
44
            $phpcsFile->addError('Group use declarations are not allowed in PHP 5.6 or earlier', $stackPtr);
45
        }
46
    }//end process()
47
}//end class
48