source: subversion/trunk/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php @ 1437

Last change on this file since 1437 was 1437, checked in by till, 5 years ago
  • started working on Sniff to disallow the PEAR-style if/else/elseif
File size: 1.7 KB
Line 
1<?php
2/**
3 * PHP_CodeSniffer tokenises PHP code and detects violations of a
4 * defined set of coding standards.
5 *
6 * PHP version 5
7 *
8 * @category  PHP
9 * @package   PHP_CodeSniffer
10 * @author    Till Klampaeckel <till@php.net>
11 * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
12 * @version   CVS: $Id: $
13 * @link      http://pear.php.net/package/PHP_CodeSniffer
14 */
15
16require_once 'PHP/CodeSniffer/Sniff.php';
17
18/**
19 * This sniff prohibits PEAR-style, if/else/elseif
20 *
21 * An example of the PEAR-style is:
22 *
23 * <code>
24 *  if (...) {
25 *  ...
26 *  } elseif (...) {
27 *  ...
28 *  } else {
29 *  ...
30 *  }
31 * </code>
32 *
33 * @category  PHP
34 * @package   PHP_CodeSniffer
35 * @author    Till Klampaeckel <till@php.net>
36 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
37 * @version   Release: @package_version@
38 * @link      http://pear.php.net/package/PHP_CodeSniffer
39 */
40class RoundCube_Sniffs_ControlStructures_DisallowPEARIfElseElseifSniff implements PHP_CodeSniffer_Sniff
41{
42
43
44    /**
45     * Returns the token types that this sniff is interested in.
46     *
47     * @return array()
48     */
49    public function register()
50    {
51        return array(T_ELSE,T_ELSEIF);
52
53    }//end register()
54
55
56    /**
57     * Processes the tokens that this sniff is interested in.
58     *
59     * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
60     * @param int                  $stackPtr  The position in the stack where
61     *                                        the token was found.
62     *
63     * @return void
64     */
65    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66    {
67        $tokens = $phpcsFile->getTokens();
68        // NOT YET DONE, WORKING ON IT
69
70    }//end process()
71
72
73}//end class
Note: See TracBrowser for help on using the repository browser.