Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Ensures that console is not used for function or var names.
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PHP_CodeSniffer_MySource
9
 * @author    Greg Sherwood <gsherwood@squiz.net>
10
 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
11
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
12
 * @version   CVS: $Id: FirebugConsoleSniff.php 265600 2008-08-29 06:46:03Z squiz $
13
 * @link      http://pear.php.net/package/PHP_CodeSniffer
14
 */
15
 
16
/**
17
 * Ensures that console is not used for function or var names.
18
 *
19
 * @category  PHP
20
 * @package   PHP_CodeSniffer_MySource
21
 * @author    Greg Sherwood <gsherwood@squiz.net>
22
 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
23
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
24
 * @version   Release: 1.2.1
25
 * @link      http://pear.php.net/package/PHP_CodeSniffer
26
 */
27
class MySource_Sniffs_Debug_FirebugConsoleSniff implements PHP_CodeSniffer_Sniff
28
{
29
 
30
    /**
31
     * A list of tokenizers this sniff supports.
32
     *
33
     * @var array
34
     */
35
    public $supportedTokenizers = array('JS');
36
 
37
 
38
    /**
39
     * Returns an array of tokens this test wants to listen for.
40
     *
41
     * @return array
42
     */
43
    public function register()
44
    {
45
        return array(
46
                T_STRING,
47
                T_PROPERTY,
48
                T_LABEL,
49
                T_OBJECT,
50
               );
51
 
52
    }//end register()
53
 
54
 
55
    /**
56
     * Processes this test, when one of its tokens is encountered.
57
     *
58
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
     * @param int                  $stackPtr  The position of the current token
60
     *                                        in the stack passed in $tokens.
61
     *
62
     * @return void
63
     */
64
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
    {
66
        $tokens = $phpcsFile->getTokens();
67
 
68
        if (strtolower($tokens[$stackPtr]['content']) === 'console') {
69
            $error = 'Variables, functions and labels must not be named "console"; name may conflict with Firebug internal variable';
70
            $phpcsFile->addError($error, $stackPtr);
71
        }
72
 
73
    }//end process()
74
 
75
 
76
}//end class
77
 
78
?>