Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Warns about the use of debug code.
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: DebugCodeSniff.php 265159 2008-08-20 05:37:21Z squiz $
13
 * @link      http://pear.php.net/package/PHP_CodeSniffer
14
 */
15
 
16
/**
17
 * Warns about the use of debug code.
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_DebugCodeSniff implements PHP_CodeSniffer_Sniff
28
{
29
 
30
    /**
31
     * Returns an array of tokens this test wants to listen for.
32
     *
33
     * @return array
34
     */
35
    public function register()
36
    {
37
        return array(T_DOUBLE_COLON);
38
 
39
    }//end register()
40
 
41
 
42
    /**
43
     * Processes this sniff, when one of its tokens is encountered.
44
     *
45
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
     * @param int                  $stackPtr  The position of the current token in
47
     *                                        the stack passed in $tokens.
48
     *
49
     * @return void
50
     */
51
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
    {
53
        $tokens = $phpcsFile->getTokens();
54
 
55
        $className = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
56
        if (strtolower($tokens[$className]['content']) === 'debug') {
57
            $method     = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
58
            $methodName = $tokens[$method]['content'];
59
            $error      = "Call to debug function Debug::$methodName() must be removed";
60
            $phpcsFile->addError($error, $stackPtr);
61
        }
62
 
63
    }//end process()
64
 
65
 
66
}//end class
67
 
68
?>