Index: trunk/phase3/includes/Status.php |
— | — | @@ -24,6 +24,8 @@ |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Factory function for fatal errors |
| 28 | + * |
| 29 | + * @param $message String: message name |
28 | 30 | */ |
29 | 31 | static function newFatal( $message /*, parameters...*/ ) { |
30 | 32 | $params = func_get_args(); |
— | — | @@ -33,25 +35,52 @@ |
34 | 36 | return $result; |
35 | 37 | } |
36 | 38 | |
| 39 | + /** |
| 40 | + * Factory function for good results |
| 41 | + * |
| 42 | + * @param $value Mixed |
| 43 | + */ |
37 | 44 | static function newGood( $value = null ) { |
38 | 45 | $result = new self; |
39 | 46 | $result->value = $value; |
40 | 47 | return $result; |
41 | 48 | } |
42 | 49 | |
| 50 | + /** |
| 51 | + * Change operation result |
| 52 | + * |
| 53 | + * @param $ok Boolean: whether to operation completed |
| 54 | + * @param $value Mixed |
| 55 | + */ |
43 | 56 | function setResult( $ok, $value = null ) { |
44 | 57 | $this->ok = $ok; |
45 | 58 | $this->value = $value; |
46 | 59 | } |
47 | 60 | |
| 61 | + /** |
| 62 | + * Returns whether the operation completed and didn't have any error or |
| 63 | + * warnings |
| 64 | + * |
| 65 | + * @return Boolean |
| 66 | + */ |
48 | 67 | function isGood() { |
49 | 68 | return $this->ok && !$this->errors; |
50 | 69 | } |
51 | 70 | |
| 71 | + /** |
| 72 | + * Returns whether the operation completed |
| 73 | + * |
| 74 | + * @return Boolean |
| 75 | + */ |
52 | 76 | function isOK() { |
53 | 77 | return $this->ok; |
54 | 78 | } |
55 | 79 | |
| 80 | + /** |
| 81 | + * Add a new warning |
| 82 | + * |
| 83 | + * @param $message String: message name |
| 84 | + */ |
56 | 85 | function warning( $message /*, parameters... */ ) { |
57 | 86 | $params = array_slice( func_get_args(), 1 ); |
58 | 87 | $this->errors[] = array( |
— | — | @@ -63,6 +92,8 @@ |
64 | 93 | /** |
65 | 94 | * Add an error, do not set fatal flag |
66 | 95 | * This can be used for non-fatal errors |
| 96 | + * |
| 97 | + * @param $message String: message name |
67 | 98 | */ |
68 | 99 | function error( $message /*, parameters... */ ) { |
69 | 100 | $params = array_slice( func_get_args(), 1 ); |
— | — | @@ -73,7 +104,10 @@ |
74 | 105 | } |
75 | 106 | |
76 | 107 | /** |
77 | | - * Add an error and set OK to false, indicating that the operation as a whole was fatal |
| 108 | + * Add an error and set OK to false, indicating that the operation |
| 109 | + * as a whole was fatal |
| 110 | + * |
| 111 | + * @param $message String: message name |
78 | 112 | */ |
79 | 113 | function fatal( $message /*, parameters... */ ) { |
80 | 114 | $params = array_slice( func_get_args(), 1 ); |
— | — | @@ -128,9 +162,11 @@ |
129 | 163 | |
130 | 164 | /** |
131 | 165 | * Get the error list as a wikitext formatted list |
132 | | - * @param string $shortContext A short enclosing context message name, to be used |
133 | | - * when there is a single error |
134 | | - * @param string $longContext A long enclosing context message name, for a list |
| 166 | + * |
| 167 | + * @param $shortContext String: a short enclosing context message name, to |
| 168 | + * be used when there is a single error |
| 169 | + * @param $longContext String: a long enclosing context message name, for a list |
| 170 | + * @return String |
135 | 171 | */ |
136 | 172 | function getWikiText( $shortContext = false, $longContext = false ) { |
137 | 173 | if ( count( $this->errors ) == 0 ) { |
— | — | @@ -167,6 +203,9 @@ |
168 | 204 | |
169 | 205 | /** |
170 | 206 | * Merge another status object into this one |
| 207 | + * |
| 208 | + * @param $other Other Status object |
| 209 | + * @param $overwriteValue Boolean: whether to override the "value" member |
171 | 210 | */ |
172 | 211 | function merge( $other, $overwriteValue = false ) { |
173 | 212 | $this->errors = array_merge( $this->errors, $other->errors ); |
— | — | @@ -178,6 +217,11 @@ |
179 | 218 | $this->failCount += $other->failCount; |
180 | 219 | } |
181 | 220 | |
| 221 | + /** |
| 222 | + * Get the list of errors (but not warnings) |
| 223 | + * |
| 224 | + * @return Array |
| 225 | + */ |
182 | 226 | function getErrorsArray() { |
183 | 227 | $result = array(); |
184 | 228 | foreach ( $this->errors as $error ) { |
— | — | @@ -192,6 +236,9 @@ |
193 | 237 | |
194 | 238 | /** |
195 | 239 | * Returns true if the specified message is present as a warning or error |
| 240 | + * |
| 241 | + * @param $msg String: message name |
| 242 | + * @return Boolean |
196 | 243 | */ |
197 | 244 | function hasMessage( $msg ) { |
198 | 245 | foreach ( $this->errors as $error ) { |