r73699 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73698‎ | r73699 | r73700 >
Date:01:42, 25 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r73697
Modified paths:
  • /trunk/extensions/Validator/Validator.php (modified) (history)
  • /trunk/extensions/Validator/includes/Parameter.php (modified) (history)
  • /trunk/extensions/Validator/includes/Validator.php (modified) (history)
  • /trunk/extensions/Validator/includes/manipulations/ParamManipulationFloat.php (added) (history)
  • /trunk/extensions/Validator/includes/manipulations/ParamManipulationInteger.php (added) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/manipulations/ParamManipulationInteger.php
@@ -0,0 +1,34 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter manipulation converting the value to a integer.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file ParamManipulationInteger.php
 10+ * @ingroup Validator
 11+ * @ingroup ParameterManipulations
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class ParamManipulationInteger extends ItemParameterManipulation {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct() {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ItemParameterManipulation::doManipulation
 28+ *
 29+ * @since 0.4
 30+ */
 31+ public function doManipulation( &$value, array &$parameters ) {
 32+ $value = (int)$value;
 33+ }
 34+
 35+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/manipulations/ParamManipulationInteger.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/extensions/Validator/includes/manipulations/ParamManipulationFloat.php
@@ -0,0 +1,34 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter manipulation converting the value to a float.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file ParamManipulationFloat.php
 10+ * @ingroup Validator
 11+ * @ingroup ParameterManipulations
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class ParamManipulationFloat extends ItemParameterManipulation {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct() {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ItemParameterManipulation::doManipulation
 28+ *
 29+ * @since 0.4
 30+ */
 31+ public function doManipulation( &$value, array &$parameters ) {
 32+ $value = (float)$value;
 33+ }
 34+
 35+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/manipulations/ParamManipulationFloat.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/extensions/Validator/includes/Parameter.php
@@ -618,23 +618,17 @@
619619
620620 switch( $this->type ) {
621621 case self::TYPE_INTEGER:
622 - //$manipulations[] = new ();
 622+ $manipulations[] = new ParamManipulationInteger();
623623 break;
624 - case self::TYPE_FLOAT:
625 - //$manipulations[] = new ();
 624+ case self::TYPE_FLOAT: case self::TYPE_NUMBER:
 625+ $manipulations[] = new ParamManipulationFloat();
626626 break;
627 - case self::TYPE_NUMBER:
628 - //$manipulations[] = new ();
629 - break;
630627 case self::TYPE_BOOLEAN:
631628 $manipulations[] = new ParamManipulationBoolean();
632629 break;
633 - case self::TYPE_CHAR:
634 - //$manipulations[] = new ();
 630+ case self::TYPE_CHAR: case self::TYPE_STRING: default:
 631+ // No extra manipulations for these types
635632 break;
636 - case self::TYPE_STRING: default:
637 - // No extra criteria for strings.
638 - break;
639633 }
640634
641635 return $manipulations;
Index: trunk/extensions/Validator/includes/Validator.php
@@ -11,9 +11,6 @@
1212 * @author Jeroen De Dauw
1313 *
1414 * TODO: break on fatal errors, such as missing required parameters that are dependencies
15 - * TODO: correct invalid parameters in the main loop, as to have correct dependency handling
16 - * TODO: settings of defaults should happen as a default behaviour that can be overiden by the output format,
17 - * as it is not wished for all output formats in every case, and now a hacky approach is required there.
1815 */
1916 class Validator {
2017
Index: trunk/extensions/Validator/Validator.php
@@ -82,6 +82,8 @@
8383
8484 $wgAutoloadClasses['ParamManipulationBoolean'] = $incDir . 'manipulations/ParamManipulationBoolean.php';
8585 $wgAutoloadClasses['ParamManipulationBoolstr'] = $incDir . 'manipulations/ParamManipulationBoolstr.php';
 86+$wgAutoloadClasses['ParamManipulationFloat'] = $incDir . 'manipulations/ParamManipulationFloat.php';
 87+$wgAutoloadClasses['ParamManipulationInteger'] = $incDir . 'manipulations/ParamManipulationInteger.php';
8688
8789 $wgAutoloadClasses['ValidatorListErrors'] = $incDir . 'parserHooks/Validator_ListErrors.php';
8890 unset( $incDir );

Follow-up revisions

RevisionCommit summaryAuthorDate
r73702Follow up to r73699jeroendedauw02:10, 25 September 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73697Changes for 0.4 - fixed a few typo's and removed old way of handling paramete...jeroendedauw01:12, 25 September 2010

Status & tagging log