Merge "API: Make jsonfm the default output format"
[lhc/web/wiklou.git] / includes / password / PasswordFactory.php
index 7aa78a7..48d6866 100644 (file)
@@ -29,7 +29,7 @@ final class PasswordFactory {
        /**
         * The default PasswordHash type
         *
-*@var string
+        * @var string
         * @see PasswordFactory::setDefaultType
         */
        private $default = '';
@@ -98,8 +98,8 @@ final class PasswordFactory {
         * if a null hash is given.
         *
         * @param string|null $hash Existing hash or null for an invalid password
-        * @return Password object
-        * @throws PasswordError if hash is invalid or type is not recognized
+        * @return Password
+        * @throws PasswordError If hash is invalid or type is not recognized
         */
        public function newFromCiphertext( $hash ) {
                if ( $hash === null || $hash === false || $hash === '' ) {
@@ -122,8 +122,8 @@ final class PasswordFactory {
         * Make a new default password of the given type.
         *
         * @param string $type Existing type
-        * @return Password object
-        * @throws PasswordError if hash is invalid or type is not recognized
+        * @return Password
+        * @throws PasswordError If hash is invalid or type is not recognized
         */
        public function newFromType( $type ) {
                if ( !isset( $this->types[$type] ) ) {
@@ -141,11 +141,15 @@ final class PasswordFactory {
         * If no existing object is given, make a new default object. If one is given, clone that
         * object. Then pass the plaintext to Password::crypt().
         *
-        * @param string $password Plaintext password
+        * @param string|null $password Plaintext password, or null for an invalid password
         * @param Password|null $existing Optional existing hash to get options from
-        * @return Password object
+        * @return Password
         */
        public function newFromPlaintext( $password, Password $existing = null ) {
+               if ( $password === null ) {
+                       return new InvalidPassword( $this, array( 'type' => '' ), null );
+               }
+
                if ( $existing === null ) {
                        $config = $this->types[$this->default];
                        $obj = new $config['class']( $this, $config );