Menu

[r312]: / trunk / src / PHPCheckstyle / Config / CheckStyleConfig.php  Maximize  Restore  History

Download this file

166 lines (145 with data), 4.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
namespace PHPCheckstyle\Config;
/**
* Abstract class model for the configuration checkers.
*
* @author James Brooks <jbrooksuk@me.com>
* @SuppressWarnings docBlocks
*/
abstract class CheckStyleConfig {
/**
* Stores the check configuration.
* @var array
*/
public $config = array();
/**
* Return a true if the test exist, false otherwise.
*
* @param String $test name of the test
* @return Boolean true if test exists.
*/
public function getTest($test) {
return (array_key_exists(strtolower($test), $this->config));
}
/**
* Return a list of items associed with a test.
*
* @param String $test name of the test
* @return array the list of items for this test.
*/
public function getTestItems($test) {
$test = strtolower($test);
return isset($this->config[$test]['item']) ? $this->config[$test]['item'] : false;
}
/**
* Return a list of exceptionfor a test.
*
* @param String $test name of the test
* @return array the list of exceptions for this test.
*/
public function getTestExceptions($test) {
$test = strtolower($test);
return isset($this->config[$test]['exception']) ? $this->config[$test]['exception'] : false;
}
/**
* Return a list of items associed with a configuration.
*
* @param String $config name of the config
* @return array the list of items for this config.
*/
public function getConfigItems($config) {
$config = strtolower($config);
return isset($this->config[$config]) ? $this->config[$config] : array();
}
/**
* Return the level of severity of a test.
*
* @param String $test name of the test
* @return the level of severity.
*/
public function getTestLevel($test) {
$ret = WARNING;
$test = strtolower($test);
if (array_key_exists($test, $this->config) && array_key_exists('level', $this->config[$test])) {
$ret = strtolower($this->config[$test]['level']);
}
$invalidLevels = array(ERROR, IGNORE, INFO, WARNING);
if (!in_array($ret, $invalidLevels)) {
echo "Invalid level for test " . $test . " : " . $ret;
$ret = WARNING;
}
return $ret;
}
/**
* Return the regular expression linked to the test.
*
* @param String $test name of the test
* @return the regular expression.
*/
public function getTestRegExp($test) {
$test = strtolower($test);
$ret = "";
if (array_key_exists($test, $this->config) && array_key_exists('regexp', $this->config[$test])) {
$ret = $this->config[$test]['regexp'];
}
return $ret;
}
/**
* Return the list of deprecated method and their replacement.
*
* @param String $test name of the test
* @return the list of depecated values.
*/
public function getTestDeprecations($test) {
$test = strtolower($test);
$ret = "";
if (array_key_exists($test, $this->config)) {
$ret = $this->config[$test];
}
return $ret;
}
/**
* Return the list of aliases and their replacement.
*
* @param String $test name of the test
* @return the list of replaced values.
*/
public function getTestAliases($test) {
$test = strtolower($test);
$ret = "";
if (array_key_exists($test, $this->config)) {
$ret = $this->config[$test];
}
return $ret;
}
/**
* Return the list of replacements.
*
* @param String $test name of the test
* @return the list of replaced values.
*/
public function getTestReplacements($test) {
$test = strtolower($test);
$ret = "";
if (array_key_exists($test, $this->config)) {
$ret = $this->config[$test];
}
return $ret;
}
/**
* Return the value of a property
*
* @param String $test name of the test
* @param String $property name of the property
* @return the value.
*/
public function getTestProperty($test, $property) {
$test = strtolower($test);
$property = strtolower($property);
if (array_key_exists($test, $this->config) && array_key_exists($property, $this->config[$test])) {
return $this->config[$test][$property];
} else {
return false;
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.