protected function _getArgsListErrors($args, $spec)
    {
        $errors = [];

        foreach ($spec as $_idx => $_param) {
            if (!($_param instanceof ReflectionParameter)) {
                throw $this->_createOutOfRangeException($this->__('Parameter #%1$d of the specification is invalid', [$_idx]), null, null, $_param);
            }

            $pos          = $_param->getPosition(); // 0-based position index of the arg.
            $isArgPresent = key_exists($pos, $args); // Whether this arg is specified
            $isNullable   = $_param->allowsNull(); // Whether null is allowed

            // Is argument required but not present?
            if (!$_param->isOptional() && !$isArgPresent) {
                $errors[] = $this->__('Argument #%1$s is required', [$pos]);
                continue;
            }

            $arg      = $isArgPresent ? $args[$pos] : null; // The value of the arg
            $isNullOk = $isNullable && $isArgPresent && is_null($arg); // Argument is present, is null, and this is allowed

            if ($isNullOk) {
                continue;
            }

            // Is argument of the right type?
            // Type spec is not for all PHP versions
            if (method_exists($_param, 'hasType') && $_param->hasType()) {
                try {
                    $error = $this->_getValueTypeError($arg, $_param->getType());
                } catch (InvalidArgumentException $e) {
                    throw $this->_createOutOfRangeException($this->__('Problem validating type of argument #%1$d against spec criterion #%1$d', [$pos, $_idx]), null, $e, $_param);
                }

                if (!is_null($error)) {
                    $errors[] = $this->__('Argument #%1$s is invalid: %2$s', [$pos, $this->_normalizeString($error)]);
                }
            }
        }

        return $errors;
    }
protected function _getArgsListErrors($args, $spec)
    {
        $errors = [];

        foreach ($spec as $_idx => $_param) {
            if (!($_param instanceof ReflectionParameter)) {
                throw $this->_createOutOfRangeException($this->__('Parameter #%1$d of the specification is invalid', [$_idx]), null, null, $_param);
            }

            $pos          = $_param->getPosition(); // 0-based position index of the arg.
            $isArgPresent = key_exists($pos, $args); // Whether this arg is specified
            $isNullable   = $_param->allowsNull(); // Whether null is allowed

            // Is argument required but not present?
            if (!$_param->isOptional() && !$isArgPresent) {
                $errors[] = $this->__('Argument #%1$s is required', [$pos]);
                continue;
            }

            $arg      = $isArgPresent ? $args[$pos] : null; // The value of the arg
            $isNullOk = $isNullable && $isArgPresent && is_null($arg); // Argument is present, is null, and this is allowed

            if ($isNullOk) {
                continue;
            }

            // Is argument of the right type?
            // Type spec is not for all PHP versions
            if (method_exists($_param, 'hasType') && $_param->hasType()) {
                try {
                    $error = $this->_getValueTypeError($arg, $_param->getType());
                } catch (InvalidArgumentException $e) {
                    throw $this->_createOutOfRangeException($this->__('Problem validating type of argument #%1$d against spec criterion #%1$d', [$pos, $_idx]), null, $e, $_param);
                }

                if (!is_null($error)) {
                    $errors[] = $this->__('Argument #%1$s is invalid: %2$s', [$pos, $this->_normalizeString($error)]);
                }
            }
        }

        return $errors;
    }
protected function _getArgsListErrors ( $ args , $ spec ) { $ errors = [ ] ; foreach ( $ spec as $ _idx => $ _param ) { if ( ! ( $ _param instanceof ReflectionParameter ) ) { throw $ this -> _createOutOfRangeException ( $ this -> __ ( 'Parameter #%1$d of the specification is invalid' , [ $ _idx ] ) , null , null , $ _param ) ; } $ pos = $ _param -> getPosition ( ) ; // 0-based position index of the arg. $ isArgPresent = key_exists ( $ pos , $ args ) ; // Whether this arg is specified $ isNullable = $ _param -> allowsNull ( ) ; // Whether null is allowed // Is argument required but not present? if ( ! $ _param -> isOptional ( ) && ! $ isArgPresent ) { $ errors [ ] = $ this -> __ ( 'Argument #%1$s is required' , [ $ pos ] ) ; continue ; } $ arg = $ isArgPresent ? $ args [ $ pos ] : null ; // The value of the arg $ isNullOk = $ isNullable && $ isArgPresent && is_null ( $ arg ) ; // Argument is present, is null, and this is allowed if ( $ isNullOk ) { continue ; } // Is argument of the right type? // Type spec is not for all PHP versions if ( method_exists ( $ _param , 'hasType' ) && $ _param -> hasType ( ) ) { try { $ error = $ this -> _getValueTypeError ( $ arg , $ _param -> getType ( ) ) ; } catch ( InvalidArgumentException $ e ) { throw $ this -> _createOutOfRangeException ( $ this -> __ ( 'Problem validating type of argument #%1$d against spec criterion #%1$d' , [ $ pos , $ _idx ] ) , null , $ e , $ _param ) ; } if ( ! is_null ( $ error ) ) { $ errors [ ] = $ this -> __ ( 'Argument #%1$s is invalid: %2$s' , [ $ pos , $ this -> _normalizeString ( $ error ) ] ) ; } } } return $ errors ; }
Produces a list of reasons why an args list is invalid against a spec.

@since [*next-version*]

@param array                      $args The list of arguments in order.
@param array|Traversable|stdClass $spec The list of criteria.

@throws OutOfRangeException If one of the criteria is invalid.

@return string[]|Stringable[] The list of errors.
Produces a list of reasons why an args list is invalid against a spec .