r65891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65890‎ | r65891 | r65892 >
Date:03:50, 4 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.3 - Implemented new meta data structure
Modified paths:
  • /trunk/extensions/Validator/TopologicalSort.php (modified) (history)
  • /trunk/extensions/Validator/Validator.class.php (modified) (history)
  • /trunk/extensions/Validator/Validator.php (modified) (history)
  • /trunk/extensions/Validator/Validator_Formats.php (modified) (history)
  • /trunk/extensions/Validator/Validator_Manager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/Validator.class.php
@@ -23,8 +23,11 @@
2424 * TODO: provide all original and inferred info about a parameter pair to the validation and formatting functions.
2525 * this will allow for the special behaviour of the default parameter of display_points in Maps
2626 * where the actual alias influences the handling
 27+ *
2728 * TODO: break on fatal errors, such as missing required parameters that are dependencies
2829 *
 30+ * TODO: correct invalid parameters in the main loop, as to have correct dependency handling
 31+ *
2932 * FIXME: lists are broken
3033 */
3134 final class Validator {
@@ -118,8 +121,8 @@
119122 * default
120123 * position
121124 * original-name
 125+ * formatted-value
122126 *
123 - *
124127 * @var associative array
125128 */
126129 private $mParameters = array();
@@ -139,23 +142,16 @@
140143 private $mErrors = array();
141144
142145 /**
143 - * Sets the parameter criteria, used to valiate the parameters.
144 - *
 146+ * Determines the names and values of all parameters. Also takes care of
 147+ * default parameters and aliases, by determining the main parameter name.
 148+ *
 149+ * @param array $rawParams
145150 * @param array $parameterInfo
146151 * @param array $defaultParams
147152 */
148 - public function setParameterInfo( array $parameterInfo ) {
 153+ public function parseAndSetParams( array $rawParams, array $parameterInfo, array $defaultParams = array() ) {
149154 $this->mParameterInfo = $parameterInfo;
150 - }
151 -
152 - /**
153 - * Determine all parameter names and value, and take care of default (nameless)
154 - * parameters, by turning them into named ones.
155 - *
156 - * @param array $rawParams
157 - * @param array $defaultParams
158 - */
159 - public function parseAndSetParams( array $rawParams, array $defaultParams = array() ) {
 155+
160156 $parameters = array();
161157
162158 $nr = 0;
@@ -206,10 +202,10 @@
207203 }
208204 }
209205 else { // If the parameter is not found in the list of allowed ones, add an item to the $this->mErrors array.
210 - if ( self::$storeUnknownParameters ) $this->mUnknownParams[$paramName] = $paramData['original-value'];
 206+ if ( self::$storeUnknownParameters ) $this->mUnknownParams[] = $paramName;
211207 $this->mErrors[] = array( 'type' => 'unknown', 'name' => $paramName );
212208 }
213 - }
 209+ }
214210 }
215211
216212 /**
@@ -239,9 +235,11 @@
240236 }
241237
242238 /**
243 - * @new
 239+ * First determines the order of parameter handling based on the dependency definitons,
 240+ * and then goes through the parameters one by one, first validating and then formatting,
 241+ * storing any encountered errors along the way.
244242 *
245 - * TODO: further impelement new meta data structure from this point on
 243+ * The 'value' element is set here, either by the cleaned 'original-value' or default.
246244 */
247245 public function validateAndFormatParameters() {
248246 $dependencyList = array();
@@ -260,40 +258,40 @@
261259 // If the user provided a value for this parameter, validate and handle it.
262260 if ( array_key_exists( $paramName, $this->mParameters ) ) {
263261
264 - $paramValue = $this->mParameters[$paramName]['original-value'];
265 - $this->cleanParameter( $paramName, $paramValue );
 262+ $this->cleanParameter( $paramName );
266263
267264 if ( $this->validateParameter( $paramName ) ) {
268265 // If the validation succeeded, add the parameter to the list of valid ones.
269 - $this->mValidParams[$paramName] = $paramValue;
270 - $this->setOutputTypes( $this->mValidParams[$paramName], $paramInfo );
 266+ $this->mValidParams[] = $paramName;
 267+ $this->setOutputTypes( $paramName );
271268 }
272269 else {
273270 // If the validation failed, add the parameter to the list of invalid ones.
274 - $this->mInvalidParams[$paramName] = $paramValue;
 271+ $this->mInvalidParams[] = $paramName;
275272 }
276273 }
277274 else {
278275 // If the parameter is required, add a new error of type 'missing'.
 276+ // TODO: break when has dependencies
279277 if ( array_key_exists( 'required', $paramInfo ) && $paramInfo['required'] ) {
280278 $this->errors[] = array( 'type' => 'missing', 'name' => $paramName );
281279 }
282280 else {
283281 // Set the default value (or default 'default value' if none is provided), and ensure the type is correct.
284 - $this->mValidParams[$paramName] = array_key_exists( 'default', $paramInfo ) ? $paramInfo['default'] : self::$defaultDefaultValue;
285 - $this->setOutputTypes( $this->mValidParams[$paramName], $paramInfo );
 282+ $this->mParameters[$paramName]['value'] = array_key_exists( 'default', $paramInfo ) ? $paramInfo['default'] : self::$defaultDefaultValue;
 283+ $this->mValidParams[] = $paramName;
 284+ $this->setOutputTypes( $paramName );
286285 }
287286 }
288287 }
289288 }
290289
291290 /**
292 - * Ensures the parameter info is valid, and splits lists.
 291+ * Ensures the parameter info is valid and parses list types.
293292 *
294293 * @param string $name
295 - * @param $value
296294 */
297 - private function cleanParameter( $name, &$value ) {
 295+ private function cleanParameter( $name ) {
298296 // Ensure there is a criteria array.
299297 if ( ! array_key_exists( 'criteria', $this->mParameterInfo[$name] ) ) {
300298 $this->mParameterInfo[$name]['criteria'] = array();
@@ -330,20 +328,30 @@
331329 }
332330 }
333331
334 - if ( count( $this->mParameterInfo[$name]['type'] ) > 1 && $this->mParameterInfo[$name]['type'][1] == 'list' ) {
335 - // Trimming and splitting of list values.
336 - $delimiter = count( $this->mParameterInfo[$name]['type'] ) > 2 ? $this->mParameterInfo[$name]['type'][2] : self::$defaultListDelimeter;
337 - $value = preg_replace( '/((\s)*' . $delimiter . '(\s)*)/', $delimiter, $value );
338 - $value = explode( $delimiter, $value );
 332+ // If the original-value element is set, clean it, and store as value.
 333+ if ( array_key_exists( 'original-value', $this->mParameters[$name] ) ) {
 334+ $value = $this->mParameters[$name]['original-value'];
 335+
 336+ if ( count( $this->mParameterInfo[$name]['type'] ) > 1 && $this->mParameterInfo[$name]['type'][1] == 'list' ) {
 337+ // Trimming and splitting of list values.
 338+ $delimiter = count( $this->mParameterInfo[$name]['type'] ) > 2 ? $this->mParameterInfo[$name]['type'][2] : self::$defaultListDelimeter;
 339+ $value = preg_replace( '/((\s)*' . $delimiter . '(\s)*)/', $delimiter, $value );
 340+ $value = explode( $delimiter, $value );
 341+ }
 342+ elseif ( count( $this->mParameterInfo[$name]['type'] ) > 1 && $this->mParameterInfo[$name]['type'][1] == 'array' && is_array( $value ) ) {
 343+ // Trimming of array values.
 344+ for ( $i = count( $value ); $i > 0; $i-- ) $value[$i] = trim( $value[$i] );
 345+ }
 346+
 347+ $this->mParameters[$name]['value'] = $value;
339348 }
340 - elseif ( count( $this->mParameterInfo[$name]['type'] ) > 1 && $this->mParameterInfo[$name]['type'][1] == 'array' && is_array( $value ) ) {
341 - // Trimming of array values.
342 - for ( $i = count( $value ); $i > 0; $i-- ) $value[$i] = trim ( $value[$i] );
343 - }
344349 }
345350
346351 private function addTypeCriteria( $paramName, $criteriaName, $criteriaArgs = array() ) {
347 - $this->mParameterInfo[$paramName]['criteria'] = array_merge( array( $criteriaName => $criteriaArgs ), $this->mParameterInfo[$paramName]['criteria'] );
 352+ $this->mParameterInfo[$paramName]['criteria'] = array_merge(
 353+ array( $criteriaName => $criteriaArgs ),
 354+ $this->mParameterInfo[$paramName]['criteria']
 355+ );
348356 }
349357
350358 /**
@@ -355,21 +363,31 @@
356364 * @param string $name
357365 *
358366 * @return boolean Indicates whether there the parameter value(s) is/are valid.
359 - *
360 - * TODO: value was byref arg for some reason - this could break stuff
361367 */
362368 private function validateParameter( $name ) {
363 - $hasNoErrors = true;
364 - $checkItemCriteria = true;
 369+ $hasNoErrors = $this->doListValidation( $name );
365370
366 - $value = $this->mParameters[$name]['original-value'];
 371+ if ( $hasNoErrors || self::$accumulateParameterErrors ) {
 372+ $hasNoErrors = $hasNoErrors && $this->doItemValidation( $name );
 373+ }
367374
 375+ return $hasNoErrors;
 376+ }
 377+
 378+ /**
 379+ * Validates the list criteria for a parameter, if there are any.
 380+ *
 381+ * @param string $name
 382+ */
 383+ private function doListValidation( $name ) {
 384+ $hasNoErrors = true;
 385+
368386 if ( array_key_exists( 'list-criteria', $this->mParameterInfo[$name] ) ) {
369387 foreach ( $this->mParameterInfo[$name]['list-criteria'] as $criteriaName => $criteriaArgs ) {
370388 // Get the validation function. If there is no matching function, throw an exception.
371389 if ( array_key_exists( $criteriaName, self::$mListValidationFunctions ) ) {
372390 $validationFunction = self::$mListValidationFunctions[$criteriaName];
373 - $isValid = $this->doCriteriaValidation( $validationFunction, $value, $this->mParameters[$name], $criteriaArgs );
 391+ $isValid = $this->doCriteriaValidation( $validationFunction, $this->mParameters['value'], $this->mParameters[$name], $criteriaArgs );
374392
375393 // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated.
376394 if ( ! $isValid ) {
@@ -377,8 +395,7 @@
378396
379397 $this->errors[] = array( 'type' => $criteriaName, 'args' => $criteriaArgs, 'name' => $name, 'list' => true, 'value' => $this->rawParameters[$name] );
380398
381 - if ( ! self::$accumulateParameterErrors ) {
382 - $checkItemCriteria = false;
 399+ if ( !self::$accumulateParameterErrors ) {
383400 break;
384401 }
385402 }
@@ -389,23 +406,22 @@
390407 }
391408 }
392409 }
393 -
394 - if ( $checkItemCriteria ) $hasNoErrors = $hasNoErrors && $this->doItemValidation( $name, $value );
395 -
 410+
396411 return $hasNoErrors;
397412 }
398413
399414 /**
400415 * Valides the provided parameter by matching the value against the item criteria for the name.
401416 *
402 - * @param $name
403 - * @param $value
 417+ * @param string $name
404418 *
405419 * @return boolean Indicates whether there the parameter value(s) is/are valid.
406420 */
407 - private function doItemValidation( $name, &$value ) {
 421+ private function doItemValidation( $name ) {
408422 $hasNoErrors = true;
409423
 424+ $value = &$this->mParameters[$name]['value'];
 425+
410426 // Go through all item criteria.
411427 foreach ( $this->mParameterInfo[$name]['criteria'] as $criteriaName => $criteriaArgs ) {
412428 // Get the validation function. If there is no matching function, throw an exception.
@@ -452,7 +468,7 @@
453469 // Determine if the value is valid for single valued parameters.
454470 $isValid = $this->doCriteriaValidation( $validationFunction, $value, $this->mParameters[$name], $criteriaArgs );
455471 }
456 -
 472+
457473 // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated.
458474 if ( !$isValid ) {
459475 $isList = is_array( $value );
@@ -467,7 +483,7 @@
468484 throw new Exception( 'There is no validation function for criteria type ' . $criteriaName );
469485 }
470486 }
471 -
 487+
472488 return $hasNoErrors;
473489 }
474490
@@ -483,7 +499,6 @@
484500 */
485501 private function doCriteriaValidation( $validationFunction, $value, array $metaData, array $criteriaArgs ) {
486502 // Call the validation function and store the result.
487 - //var_dump($metaData);exit;
488503 return call_user_func_array( $validationFunction, array_merge( array_merge( array( $value ), array( $metaData ) ), $criteriaArgs ) );
489504 }
490505
@@ -491,29 +506,35 @@
492507 * Changes the invalid parameters to their default values, and changes their state to valid.
493508 */
494509 public function correctInvalidParams() {
495 - foreach ( $this->mInvalidParams as $paramName => $paramValue ) {
496 - unset( $this->mInvalidParams[$paramName] );
497 - $this->mValidParams[$paramName] = array_key_exists( 'default', $this->mParameterInfo[$paramName] ) ? $this->mParameterInfo[$paramName]['default'] : '';
498 - $this->setOutputTypes( $this->mValidParams[$paramName], $this->mParameterInfo[$paramName] );
 510+ while ( $paramName = array_shift( $this->mInvalidParams ) ) {
 511+ if ( array_key_exists( 'default', $this->mParameterInfo[$paramName] ) ) {
 512+ $this->mParameters[$paramName]['value'] = $this->mParameterInfo[$paramName]['default'];
 513+ }
 514+ else {
 515+ $this->mParameters[$paramName]['value'] = self::$defaultDefaultValue;
 516+ }
 517+ $this->setOutputTypes( $paramName );
 518+ $this->mValidParams[] = $paramName;
499519 }
500520 }
501521
502522 /**
503523 * Ensures the output type values are arrays, and then calls setOutputType.
504524 *
505 - * @param $value
506 - * @param array $info
 525+ * @param string $name
507526 */
508 - private function setOutputTypes( &$value, array $info ) {
 527+ private function setOutputTypes( $name ) {
 528+ $info = $this->mParameterInfo[$name];
 529+
509530 if ( array_key_exists( 'output-types', $info ) ) {
510531 for ( $i = 0, $c = count( $info['output-types'] ); $i < $c; $i++ ) {
511532 if ( ! is_array( $info['output-types'][$i] ) ) $info['output-types'][$i] = array( $info['output-types'][$i] );
512 - $this->setOutputType( $value, $info['output-types'][$i] );
 533+ $this->setOutputType( $name, $info['output-types'][$i] );
513534 }
514535 }
515536 elseif ( array_key_exists( 'output-type', $info ) ) {
516537 if ( ! is_array( $info['output-type'] ) ) $info['output-type'] = array( $info['output-type'] );
517 - $this->setOutputType( $value, $info['output-type'] );
 538+ $this->setOutputType( $name, $info['output-type'] );
518539 }
519540
520541 }
@@ -521,17 +542,29 @@
522543 /**
523544 * Calls the formatting function for the provided output format with the provided value.
524545 *
525 - * @param $value
 546+ * @param string $name
526547 * @param array $typeInfo
527548 */
528 - private function setOutputType( &$value, array $typeInfo ) {
 549+ private function setOutputType( $name, array $typeInfo ) {
529550 // The output type is the first value in the type info array.
530551 // The remaining ones will be any extra arguments.
531552 $outputType = strtolower( array_shift( $typeInfo ) );
532553
 554+ if ( !array_key_exists( 'formatted-value', $this->mParameters[$name] ) ) {
 555+ $this->mParameters[$name]['formatted-value'] = $this->mParameters[$name]['value'];
 556+ }
 557+
533558 if ( array_key_exists( $outputType, self::$mOutputFormats ) ) {
534 - // Call the formatting function with as first parameter the value, followed by the extra arguments.
535 - call_user_func_array( self::$mOutputFormats[$outputType], array_merge( array( &$value ), $typeInfo ) );
 559+ /**
 560+ * Call the formatting function with these parameters:
 561+ * - parameter value: ByRef for easy manipulation.
 562+ * - parameter name: For lookups in the param info array.
 563+ * - parameter array: All data about the parameters gathered so far (this includes dependencies!).
 564+ * - output type info: Type info as provided by the parameter definition. This can be zero or more parameters.
 565+ */
 566+ $parameters = array( &$this->mParameters[$name]['formatted-value'], $name, $this->mParameters );
 567+ $parameters = array_merge( $parameters, $typeInfo );
 568+ call_user_func_array( self::$mOutputFormats[$outputType], $parameters );
536569 }
537570 else {
538571 throw new Exception( 'There is no formatting function for output format ' . $outputType );
@@ -544,7 +577,14 @@
545578 * @return array
546579 */
547580 public function getValidParams() {
548 - return $this->mValidParams;
 581+ $validParams = array();
 582+
 583+ foreach( $this->mValidParams as $name ) {
 584+ $key = array_key_exists( 'formatted-value', $this->mParameters[$name] ) ? 'formatted-value' : 'value';
 585+ $validParams[$name] = $this->mParameters[$name][$key];
 586+ }
 587+
 588+ return $validParams;
549589 }
550590
551591 /**
@@ -553,7 +593,13 @@
554594 * @return array
555595 */
556596 public static function getUnknownParams() {
557 - return $this->mUnknownParams;
 597+ $unknownParams = array();
 598+
 599+ foreach( $this->mUnknownParams as $name ) {
 600+ $unknownParams[$name] = $this->mParameters[$name]; // TODO
 601+ }
 602+
 603+ return $unknownParams;
558604 }
559605
560606 /**
Index: trunk/extensions/Validator/Validator_Manager.php
@@ -42,17 +42,16 @@
4343
4444 $validator = new Validator();
4545
46 - $validator->setParameterInfo( $parameterInfo );
47 - $validator->parseAndSetParams( $rawParameters, $defaultParams );
48 -
 46+ $validator->parseAndSetParams( $rawParameters, $parameterInfo, $defaultParams );
4947 $hasNoErrors = $validator->validateAndFormatParameters();
 48+
5049 $hasFatalError = $hasNoErrors ? false : $this->hasFatalError();
5150
5251 if ( !$hasNoErrors ) {
5352 if ( $egValidatorErrorLevel < Validator_ERRORS_STRICT ) $validator->correctInvalidParams();
5453 if ( $egValidatorErrorLevel >= Validator_ERRORS_WARN ) $this->errors = $validator->getErrors();
5554 }
56 -
 55+
5756 return !$hasFatalError ? $validator->getValidParams() : false;
5857 }
5958
Index: trunk/extensions/Validator/Validator_Formats.php
@@ -25,8 +25,10 @@
2626 * Ensures the value is an array.
2727 *
2828 * @param $value
 29+ * @param string name The name of the parameter.
 30+ * @param array $parameters Array containing data about the so far handled parameters.
2931 */
30 - public static function format_array( &$value ) {
 32+ public static function format_array( &$value, $name, array $parameters ) {
3133 if ( ! is_array( $value ) ) $value = array( $value );
3234 }
3335
@@ -34,13 +36,15 @@
3537 * Ensures the value is an array.
3638 *
3739 * @param $value
 40+ * @param string name The name of the parameter.
 41+ * @param array $parameters Array containing data about the so far handled parameters.
3842 */
39 - public static function format_filtered_array( &$value ) {
 43+ public static function format_filtered_array( &$value, $name, array $parameters ) {
4044 // TODO: It's possible the way the allowed values are passed here is quite inneficient...
4145 $params = func_get_args();
4246 array_shift( $params ); // Ommit the value
4347
44 - self::format_array( $value );
 48+ self::format_array( $value, $name, $parameters );
4549 $filtered = array();
4650 foreach ( $value as $item ) if ( in_array( $item, $params ) ) $filtered[] = $item;
4751
@@ -53,11 +57,13 @@
5458 * will also work for single values.
5559 *
5660 * @param $value
 61+ * @param string name The name of the parameter.
 62+ * @param array $parameters Array containing data about the so far handled parameters.
5763 * @param $delimiter
5864 * @param $wrapper
5965 */
60 - public static function format_list( &$value, $delimiter = ',', $wrapper = '' ) {
61 - self::format_array( $value );
 66+ public static function format_list( &$value, $name, array $parameters, $delimiter = ',', $wrapper = '' ) {
 67+ self::format_array( $value, $name, $parameters );
6268 $value = $wrapper . implode( $wrapper . $delimiter . $wrapper, $value ) . $wrapper;
6369 }
6470
@@ -67,8 +73,10 @@
6874 * TODO: work with a list of true-values.
6975 *
7076 * @param $value
 77+ * @param string name The name of the parameter.
 78+ * @param array $parameters Array containing data about the so far handled parameters.
7179 */
72 - public static function format_boolean( &$value ) {
 80+ public static function format_boolean( &$value, $name, array $parameters ) {
7381 if ( is_array( $value ) ) {
7482 $boolArray = array();
7583 foreach ( $value as $item ) $boolArray[] = in_array( $item, array( 'yes', 'on' ) );
@@ -83,9 +91,11 @@
8492 * Changes every value into a boolean, represented by a 'false' or 'true' string.
8593 *
8694 * @param $value
 95+ * @param string name The name of the parameter.
 96+ * @param array $parameters Array containing data about the so far handled parameters.
8797 */
88 - public static function format_boolean_string( &$value ) {
89 - self::format_boolean( $value );
 98+ public static function format_boolean_string( &$value, $name, array $parameters ) {
 99+ self::format_boolean( $value, $name, $parameters );
90100 if ( is_array( $value ) ) {
91101 $boolArray = array();
92102 foreach ( $value as $item ) $boolArray[] = $item ? 'true' : 'false';
@@ -100,8 +110,10 @@
101111 * Changes lists into strings, by enumerating the items using $wgLang->listToText.
102112 *
103113 * @param $value
 114+ * @param string name The name of the parameter.
 115+ * @param array $parameters Array containing data about the so far handled parameters.
104116 */
105 - public static function format_string( &$value ) {
 117+ public static function format_string( &$value, $name, array $parameters ) {
106118 if ( is_array( $value ) ) {
107119 global $wgLang;
108120 $value = $wgLang->listToText( $value );
@@ -112,8 +124,10 @@
113125 * Removes duplicate items from lists.
114126 *
115127 * @param $value
 128+ * @param string name The name of the parameter.
 129+ * @param array $parameters Array containing data about the so far handled parameters.
116130 */
117 - public static function format_unique_items( &$value ) {
 131+ public static function format_unique_items( &$value, $name, array $parameters ) {
118132 if ( is_array( $value ) ) $value = array_unique( $value );
119133 }
120134
Index: trunk/extensions/Validator/TopologicalSort.php
@@ -22,26 +22,19 @@
2323 class TopologicalSort {
2424
2525 private $nodes = array();
26 - private $looseNodes = array();
 26+ private $nodeNames = array();
2727
2828 /**
2929 * Dependency pairs are a list of arrays in the form
3030 * $name => $val where $key must come before $val in load order.
3131 */
3232 function TopologicalSort( $dependencies = array(), $parse = true ) {
33 - $rawDependencies = $dependencies;
 33+ $this->nodeNames = array_keys( $dependencies );
3434
3535 if ( $parse ) {
3636 $dependencies = $this->parseDependencyList( $dependencies );
3737 }
3838
39 - // Store items that have no dependencies, and therefore no nodes.
40 - foreach( $rawDependencies as $item => $dependency ) {
41 - if ( !in_array( $item, $dependencies ) && !array_key_exists( $item, $dependencies ) ) {
42 - $this->looseNodes[] = $item;
43 - }
44 - }
45 -
4639 // turn pairs into double-linked node tree
4740 foreach ( $dependencies as $key => $dpair ) {
4841 list ( $module, $dependency ) = each ( $dpair );
@@ -55,16 +48,10 @@
5649 /**
5750 * Perform Topological Sort.
5851 *
59 - * @param array $nodes optional array of node objects may be passed.
60 - * Default is $this->nodes created in constructor.
61 - *
6252 * @return sorted array
6353 */
64 - public function doSort( array $nodes = array() ) {
65 - // use this->nodes if it is populated and no param passed
66 - if ( !count( $nodes ) && count( $this->nodes ) ) {
67 - $nodes = $this->nodes;
68 - }
 54+ public function doSort() {
 55+ $nodes = $this->nodes;
6956
7057 // get nodes without parents
7158 $root_nodes = array_values( $this->getRootNodes( $nodes ) );
@@ -104,8 +91,16 @@
10592 unset( $nodes[$n->name] );
10693 }
10794
 95+ $looseNodes = array();
 96+
10897 // Return the result with the loose nodes (items with no dependencies) appended.
109 - return array_merge( $sorted, $this->looseNodes );
 98+ foreach( $this->nodeNames as $name ) {
 99+ if ( !in_array( $name, $sorted ) ) {
 100+ $looseNodes[] = $name;
 101+ }
 102+ }
 103+
 104+ return array_merge( $sorted, $looseNodes );
110105 }
111106
112107 /**
Index: trunk/extensions/Validator/Validator.php
@@ -24,7 +24,7 @@
2525 die( 'Not an entry point.' );
2626 }
2727
28 -define( 'Validator_VERSION', '0.3 a4' );
 28+define( 'Validator_VERSION', '0.3 a6' );
2929
3030 // Constants indicating the strictness of the parameter validation.
3131 define( 'Validator_ERRORS_NONE', 0 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r65892Changes for 0.6 - Follow up to r65891jeroendedauw03:50, 4 May 2010

Status & tagging log