Index: trunk/extensions/Validator/includes/ParameterCriterion.php |
— | — | @@ -35,53 +35,6 @@ |
36 | 36 | public abstract function isForLists(); |
37 | 37 | |
38 | 38 | /** |
39 | | - * Returns a new instance of ParameterCriterion by converting an element of a Validator 3.x-style criteria array definition. |
40 | | - * Note: this method is for backward compatibility and should not be used in new code. |
41 | | - * |
42 | | - * @since 0.4 |
43 | | - * |
44 | | - * @param string $name |
45 | | - * @param array $definition |
46 | | - * |
47 | | - * @return ParameterCriterion |
48 | | - */ |
49 | | - public static function newFromArray( $name, array $definition ) { |
50 | | - $bcMap = array( |
51 | | - 'in_array' => 'CriterionInArray', |
52 | | - 'is_numeric' => 'CriterionIsNumeric', |
53 | | - 'in_range' => 'CriterionInRange', |
54 | | - 'is_float' => 'CriterionIsFloat', |
55 | | - 'is_integer' => 'CriterionIsInteger', |
56 | | - 'not_empty' => 'CriterionNotEmpty', |
57 | | - 'has_length' => 'CriterionHasLength', |
58 | | - 'regex' => 'CriterionMatchesRegex', |
59 | | - 'item_count' => 'CriterionItemCount', |
60 | | - 'unique_items' => 'CriterionUniqueItems', |
61 | | - ); |
62 | | - |
63 | | - $className = array_key_exists( $name, $bcMap ) ? $bcMap[$name] : 'CriterionTrue'; |
64 | | - |
65 | | - switch ( $name ) { |
66 | | - case 'in_array': |
67 | | - $criterion = new $className( $definition ); |
68 | | - break; |
69 | | - case 'in_range': case 'item_count' : case 'has_length' : |
70 | | - if ( count( $definition ) > 1 ) { |
71 | | - $criterion = new $className( $definition[0], $definition[1] ); |
72 | | - } |
73 | | - else { |
74 | | - $criterion = new $className( $definition[0] ); |
75 | | - } |
76 | | - break; |
77 | | - default: |
78 | | - $criterion = new $className(); |
79 | | - break; |
80 | | - } |
81 | | - |
82 | | - return $criterion; |
83 | | - } |
84 | | - |
85 | | - /** |
86 | 39 | * Constructor. |
87 | 40 | * |
88 | 41 | * @since 0.4 |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -213,7 +213,7 @@ |
214 | 214 | protected function cleanCriteria( array &$criteria ) { |
215 | 215 | foreach ( $criteria as $key => &$criterion ) { |
216 | 216 | if ( !$criterion instanceof ParameterCriterion ) { |
217 | | - $criterion = ParameterCriterion::newFromArray( $key, $criterion ); |
| 217 | + throw new Exception( "$key is not a valid ParameterCriterion." ); |
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |