Merge changes Ic13414f0,I26085bfc
[lhc/web/wiklou.git] / includes / WebRequest.php
index 462b312..46cba52 100644 (file)
@@ -54,7 +54,7 @@ class WebRequest {
         * Cached URL protocol
         * @var string
         */
-       private $protocol;
+       protected $protocol;
 
        public function __construct() {
                /// @todo FIXME: This preemptive de-quoting can interfere with other web libraries
@@ -480,6 +480,20 @@ class WebRequest {
                        : null;
        }
 
+       /**
+        * Fetch a floating point value from the input or return $default if not set.
+        * Guaranteed to return a float; non-numeric input will typically
+        * return 0.
+        *
+        * @since 1.23
+        * @param $name String
+        * @param $default Float
+        * @return Float
+        */
+       public function getFloat( $name, $default = 0 ) {
+               return floatval( $this->getVal( $name, $default ) );
+       }
+
        /**
         * Fetch a boolean value from the input or return $default if not set.
         * Guaranteed to return true or false, with normal PHP semantics for
@@ -1508,6 +1522,12 @@ class FauxRequest extends WebRequest {
 class DerivativeRequest extends FauxRequest {
        private $base;
 
+       /**
+        * @param WebRequest $base
+        * @param array $data Array of *non*-urlencoded key => value pairs, the
+        *   fake GET/POST values
+        * @param bool $wasPosted Whether to treat the data as POST
+        */
        public function __construct( WebRequest $base, $data, $wasPosted = false ) {
                $this->base = $base;
                parent::__construct( $data, $wasPosted );