protected function obtainNext(\CharlotteDunois\Livia\Commands\Context $context, array &$provided, $promptLimit, array &$values, array &$results, int $current) {
        if(empty($this->args[$current])) {
            return \React\Promise\resolve();
        }
        
        $bag = new \CharlotteDunois\Livia\Arguments\ArgumentBag($this->args[$current], $promptLimit);
        
        $providedArg = (isset($provided[$current]) ?
            ($this->args[$current]->infinite ?
                \array_slice($provided, $current) :
                ($this->argsCount < \count($provided) && ($this->argsCount - 1) === $current ? \implode(' ', \array_slice($provided, $current)) : $provided[$current])
            ) : null
        );
        
        return $this->args[$current]->obtain($context, $providedArg, $bag)
            ->then(function (\CharlotteDunois\Livia\Arguments\ArgumentBag $result) use ($context, &$provided, $bag, $promptLimit, &$values, &$results, $current) {
                $results[] = $result;
                
                if($bag->cancelled) {
                    return array(
                        'values' => null,
                        'cancelled' => $result->cancelled,
                        'prompts' => \array_merge(array(), ...\array_map(function (\CharlotteDunois\Livia\Arguments\ArgumentBag $res) {
                            return $res->prompts;
                        }, $results)),
                        'answers' => \array_merge(array(), ...\array_map(function (\CharlotteDunois\Livia\Arguments\ArgumentBag $res) {
                            return $res->answers;
                        }, $results))
                    );
                }
                
                $values[$this->args[$current]->key] = ($this->args[$current]->infinite ? $result->values : $result->values[0]);
                $current++;
                
                return $this->obtainNext($context, $provided, $promptLimit, $values, $results, $current);
            });
    }
protected function obtainNext(\CharlotteDunois\Livia\Commands\Context $context, array &$provided, $promptLimit, array &$values, array &$results, int $current) {
        if(empty($this->args[$current])) {
            return \React\Promise\resolve();
        }
        
        $bag = new \CharlotteDunois\Livia\Arguments\ArgumentBag($this->args[$current], $promptLimit);
        
        $providedArg = (isset($provided[$current]) ?
            ($this->args[$current]->infinite ?
                \array_slice($provided, $current) :
                ($this->argsCount < \count($provided) && ($this->argsCount - 1) === $current ? \implode(' ', \array_slice($provided, $current)) : $provided[$current])
            ) : null
        );
        
        return $this->args[$current]->obtain($context, $providedArg, $bag)
            ->then(function (\CharlotteDunois\Livia\Arguments\ArgumentBag $result) use ($context, &$provided, $bag, $promptLimit, &$values, &$results, $current) {
                $results[] = $result;
                
                if($bag->cancelled) {
                    return array(
                        'values' => null,
                        'cancelled' => $result->cancelled,
                        'prompts' => \array_merge(array(), ...\array_map(function (\CharlotteDunois\Livia\Arguments\ArgumentBag $res) {
                            return $res->prompts;
                        }, $results)),
                        'answers' => \array_merge(array(), ...\array_map(function (\CharlotteDunois\Livia\Arguments\ArgumentBag $res) {
                            return $res->answers;
                        }, $results))
                    );
                }
                
                $values[$this->args[$current]->key] = ($this->args[$current]->infinite ? $result->values : $result->values[0]);
                $current++;
                
                return $this->obtainNext($context, $provided, $promptLimit, $values, $results, $current);
            });
    }
protected function obtainNext ( \ CharlotteDunois \ Livia \ Commands \ Context $ context , array & $ provided , $ promptLimit , array & $ values , array & $ results , int $ current ) { if ( empty ( $ this -> args [ $ current ] ) ) { return \ React \ Promise \ resolve ( ) ; } $ bag = new \ CharlotteDunois \ Livia \ Arguments \ ArgumentBag ( $ this -> args [ $ current ] , $ promptLimit ) ; $ providedArg = ( isset ( $ provided [ $ current ] ) ? ( $ this -> args [ $ current ] -> infinite ? \ array_slice ( $ provided , $ current ) : ( $ this -> argsCount < \ count ( $ provided ) && ( $ this -> argsCount - 1 ) === $ current ? \ implode ( ' ' , \ array_slice ( $ provided , $ current ) ) : $ provided [ $ current ] ) ) : null ) ; return $ this -> args [ $ current ] -> obtain ( $ context , $ providedArg , $ bag ) -> then ( function ( \ CharlotteDunois \ Livia \ Arguments \ ArgumentBag $ result ) use ( $ context , & $ provided , $ bag , $ promptLimit , & $ values , & $ results , $ current ) { $ results [ ] = $ result ; if ( $ bag -> cancelled ) { return array ( 'values' => null , 'cancelled' => $ result -> cancelled , 'prompts' => \ array_merge ( array ( ) , ... \ array_map ( function ( \ CharlotteDunois \ Livia \ Arguments \ ArgumentBag $ res ) { return $ res -> prompts ; } , $ results ) ) , 'answers' => \ array_merge ( array ( ) , ... \ array_map ( function ( \ CharlotteDunois \ Livia \ Arguments \ ArgumentBag $ res ) { return $ res -> answers ; } , $ results ) ) ) ; } $ values [ $ this -> args [ $ current ] -> key ] = ( $ this -> args [ $ current ] -> infinite ? $ result -> values : $ result -> values [ 0 ] ) ; $ current ++ ; return $ this -> obtainNext ( $ context , $ provided , $ promptLimit , $ values , $ results , $ current ) ; } ) ; }
Obtains and collects the next argument.
@param \CharlotteDunois\Livia\Commands\Context         $context
@param array                                           $provided
@param int|float                                       $promptLimit
@param array                                           $values
@param array                                           $results
@param int                                             $current
@return \React\Promise\ExtendedPromiseInterface
Obtains and collects the next argument .