Completed
Push — master ( 3d2c15...d79b98 )
by Wim
02:28
created

register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 2
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
<?php
2
/**
3
 * PHPCompatibility_Sniffs_PHP_NewClosure.
4
 *
5
 * PHP version 5.3
6
 *
7
 * @category  PHP
8
 * @package   PHPCompatibility
9
 * @author    Wim Godden <[email protected]>
10
 */
11
12
/**
13
 * PHPCompatibility_Sniffs_PHP_NewClosure.
14
 *
15
 * Closures are available since PHP 5.3
16
 *
17
 * PHP version 5.3
18
 *
19
 * @category  PHP
20
 * @package   PHPCompatibility
21
 * @author    Wim Godden <[email protected]>
22
 */
23
class PHPCompatibility_Sniffs_PHP_NewClosureSniff extends PHPCompatibility_Sniff
24
{
25
    /**
26
     * Returns an array of tokens this test wants to listen for.
27
     *
28
     * @return array
29
     */
30
    public function register()
31
    {
32
        return array(T_CLOSURE);
33
34
    }//end register()
35
36
    /**
37
     * Processes this test, when one of its tokens is encountered.
38
     *
39
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
40
     * @param int                  $stackPtr  The position of the current token
41
     *                                        in the stack passed in $tokens.
42
     *
43
     * @return void
44
     */
45
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
    {
47
        if ($this->supportsBelow('5.2')) {
48
            $phpcsFile->addError('Closures / anonymous functions are not available in PHP 5.2 or earlier', $stackPtr);
49
        }
50
    }//end process()
51
52
}//end class
53