Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / password / ParameterizedPassword.php
index 4d6e415..c929797 100644 (file)
@@ -40,14 +40,14 @@ abstract class ParameterizedPassword extends Password {
         * Named parameters that have default values for this password type
         * @var array
         */
-       protected $params = array();
+       protected $params = [];
 
        /**
         * Extra arguments that were found in the hash. This may or may not make
         * the hash invalid.
         * @var array
         */
-       protected $args = array();
+       protected $args = [];
 
        protected function parseHash( $hash ) {
                parent::parseHash( $hash );
@@ -83,10 +83,16 @@ abstract class ParameterizedPassword extends Password {
        }
 
        public function toString() {
-               return
-                       ':' . $this->config['type'] . ':' .
-                       implode( $this->getDelimiter(), array_merge( $this->params, $this->args ) ) .
-                       $this->getDelimiter() . $this->hash;
+               $str = ':' . $this->config['type'] . ':';
+
+               if ( count( $this->params ) || count( $this->args ) ) {
+                       $str .= implode( $this->getDelimiter(), array_merge( $this->params, $this->args ) );
+                       $str .= $this->getDelimiter();
+               }
+
+               $res = $str . $this->hash;
+               $this->assertIsSafeSize( $res );
+               return $res;
        }
 
        /**