* 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();
/**
* Select a request by class name.
+ *
+ * @codingStandardsIgnoreStart
+ * @phan-template T
+ * @codingStandardsIgnoreEnd
* @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 ) {
* @param AuthenticationRequest[] $reqs
* @return array
* @throws \UnexpectedValueException If fields cannot be merged
+ * @suppress PhanTypeInvalidDimOffset
*/
public static function mergeFieldInfo( array $reqs ) {
$merged = [];
}
$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'] ) ) {
* @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;