Merge "Support the creation of special pages with services injected"
[lhc/web/wiklou.git] / includes / auth / AuthenticationRequest.php
index 4744c4d..168ae85 100644 (file)
@@ -47,7 +47,8 @@ abstract class AuthenticationRequest {
 
        /** Indicates that the request is required by a primary authentication
         * provider. Since the user can choose which primary to authenticate with,
-        * the request might or might not end up being actually required. */
+        * the request might or might not end up being actually required.
+        */
        const PRIMARY_REQUIRED = 2;
 
        /** @var string|null The AuthManager::ACTION_* constant this request was
@@ -57,14 +58,16 @@ abstract class AuthenticationRequest {
        public $action = null;
 
        /** @var int For login, continue, and link actions, one of self::OPTIONAL,
-        * self::REQUIRED, or self::PRIMARY_REQUIRED */
+        * self::REQUIRED, or self::PRIMARY_REQUIRED
+        */
        public $required = self::REQUIRED;
 
        /** @var string|null Return-to URL, in case of redirect */
        public $returnToUrl = null;
 
        /** @var string|null Username. See AuthenticationProvider::getAuthenticationRequests()
-        * for details of what this means and how it behaves. */
+        * for details of what this means and how it behaves.
+        */
        public $username = null;
 
        /**
@@ -119,6 +122,7 @@ abstract class AuthenticationRequest {
         * a 'password' field).
         *
         * @return array As above
+        * @phan-return array<string,array{type:string,options?:array,value?:string,label:Message,help:Message,optional?:bool,sensitive?:bool,skippable?:bool}>
         */
        abstract public function getFieldInfo();
 
@@ -242,13 +246,18 @@ abstract class AuthenticationRequest {
        }
 
        /**
+        * @codingStandardsIgnoreStart
+        * @template T
+        * @codingStandardsIgnoreEnd
         * Select a request by class name.
         * @param AuthenticationRequest[] $reqs
         * @param string $class Class name
+        * @phan-param class-string<T> $class
         * @param bool $allowSubclasses If true, also returns any request that's a subclass of the given
         *   class.
         * @return AuthenticationRequest|null Returns null if there is not exactly
         *  one matching request.
+        * @phan-return T|null
         */
        public static function getRequestByClass( array $reqs, $class, $allowSubclasses = false ) {
                $requests = array_filter( $reqs, function ( $req ) use ( $class, $allowSubclasses ) {
@@ -294,6 +303,7 @@ abstract class AuthenticationRequest {
         * @param AuthenticationRequest[] $reqs
         * @return array
         * @throws \UnexpectedValueException If fields cannot be merged
+        * @suppress PhanTypeInvalidDimOffset
         */
        public static function mergeFieldInfo( array $reqs ) {
                $merged = [];
@@ -334,12 +344,13 @@ abstract class AuthenticationRequest {
                                }
 
                                $options['sensitive'] = !empty( $options['sensitive'] );
+                               $type = $options['type'];
 
                                if ( !array_key_exists( $name, $merged ) ) {
                                        $merged[$name] = $options;
-                               } elseif ( $merged[$name]['type'] !== $options['type'] ) {
+                               } elseif ( $merged[$name]['type'] !== $type ) {
                                        throw new \UnexpectedValueException( "Field type conflict for \"$name\", " .
-                                               "\"{$merged[$name]['type']}\" vs \"{$options['type']}\""
+                                               "\"{$merged[$name]['type']}\" vs \"$type\""
                                        );
                                } else {
                                        if ( isset( $options['options'] ) ) {
@@ -370,7 +381,7 @@ abstract class AuthenticationRequest {
         * @return AuthenticationRequest
         */
        public static function __set_state( $data ) {
-               // @phan-suppress-next-line PhanTypeInstantiateAbstract
+               // @phan-suppress-next-line PhanTypeInstantiateAbstractStatic
                $ret = new static();
                foreach ( $data as $k => $v ) {
                        $ret->$k = $v;