| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Squiz_Sniffs_PHP_ForbiddenFunctionsSniff.
|
|
|
4 |
*
|
|
|
5 |
* PHP version 5
|
|
|
6 |
*
|
|
|
7 |
* @category PHP
|
|
|
8 |
* @package PHP_CodeSniffer
|
|
|
9 |
* @author Greg Sherwood <gsherwood@squiz.net>
|
|
|
10 |
* @author Marc McIntyre <mmcintyre@squiz.net>
|
|
|
11 |
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
|
|
|
12 |
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
|
|
|
13 |
* @version CVS: $Id: ForbiddenFunctionsSniff.php 251093 2008-01-21 21:40:50Z squiz $
|
|
|
14 |
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) {
|
|
|
18 |
throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Squiz_Sniffs_PHP_ForbiddenFunctionsSniff.
|
|
|
23 |
*
|
|
|
24 |
* Discourages the use of alias functions that are kept in PHP for compatibility
|
|
|
25 |
* with older versions. Can be used to forbid the use of any function.
|
|
|
26 |
*
|
|
|
27 |
* @category PHP
|
|
|
28 |
* @package PHP_CodeSniffer
|
|
|
29 |
* @author Greg Sherwood <gsherwood@squiz.net>
|
|
|
30 |
* @author Marc McIntyre <mmcintyre@squiz.net>
|
|
|
31 |
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
|
|
|
32 |
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
|
|
|
33 |
* @version Release: 1.2.1
|
|
|
34 |
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
|
35 |
*/
|
|
|
36 |
class Squiz_Sniffs_PHP_ForbiddenFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
|
|
|
37 |
{
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* A list of forbidden functions with their alternatives.
|
|
|
41 |
*
|
|
|
42 |
* The value is NULL if no alternative exists. IE, the
|
|
|
43 |
* function should just not be used.
|
|
|
44 |
*
|
|
|
45 |
* @var array(string => string|null)
|
|
|
46 |
*/
|
|
|
47 |
protected $forbiddenFunctions = array(
|
|
|
48 |
'sizeof' => 'count',
|
|
|
49 |
'delete' => 'unset',
|
|
|
50 |
'print' => 'echo',
|
|
|
51 |
'is_null' => null,
|
|
|
52 |
'create_function' => null,
|
|
|
53 |
);
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Returns an array of tokens this test wants to listen for.
|
|
|
58 |
*
|
|
|
59 |
* @return array
|
|
|
60 |
*/
|
|
|
61 |
public function register()
|
|
|
62 |
{
|
|
|
63 |
return array(
|
|
|
64 |
T_STRING,
|
|
|
65 |
T_PRINT,
|
|
|
66 |
);
|
|
|
67 |
|
|
|
68 |
}//end register()
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
}//end class
|
|
|
72 |
|
|
|
73 |
?>
|