r75142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75141‎ | r75142 | r75143 >
Date:12:49, 21 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Removed old-style criterion definition handling
Modified paths:
  • /trunk/extensions/Validator/includes/Parameter.php (modified) (history)
  • /trunk/extensions/Validator/includes/ParameterCriterion.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/ParameterCriterion.php
@@ -35,53 +35,6 @@
3636 public abstract function isForLists();
3737
3838 /**
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 - /**
8639 * Constructor.
8740 *
8841 * @since 0.4
Index: trunk/extensions/Validator/includes/Parameter.php
@@ -213,7 +213,7 @@
214214 protected function cleanCriteria( array &$criteria ) {
215215 foreach ( $criteria as $key => &$criterion ) {
216216 if ( !$criterion instanceof ParameterCriterion ) {
217 - $criterion = ParameterCriterion::newFromArray( $key, $criterion );
 217+ throw new Exception( "$key is not a valid ParameterCriterion." );
218218 }
219219 }
220220 }

Status & tagging log