protected function _getValueTypeError($value, $type)
    {
        if (!($type instanceof ReflectionType)) {
            throw $this->_createInvalidArgumentException($this->__('Type criterion is invalid'), null, null, $type);
        }

        $typeName = method_exists($type, 'getName')
            ? $type->getName()
            : $type->__toString();
        $isOfType = null;

        // If type is built-in, it should be safe to use a built-in function
        if ($type->isBuiltin()) {
            $testFunc = sprintf('is_%1$s', $typeName);
            $isOfType = call_user_func_array($testFunc, [$value]);
        }
        // If type is not built-in, then check whether instance of
        else {
            $isOfType = $value instanceof $typeName;
        }

        if (!$isOfType) {
            return $this->__('Value must be of type "%1$s"', [$typeName]);
        }

        return;
    }
protected function _getValueTypeError($value, $type)
    {
        if (!($type instanceof ReflectionType)) {
            throw $this->_createInvalidArgumentException($this->__('Type criterion is invalid'), null, null, $type);
        }

        $typeName = method_exists($type, 'getName')
            ? $type->getName()
            : $type->__toString();
        $isOfType = null;

        // If type is built-in, it should be safe to use a built-in function
        if ($type->isBuiltin()) {
            $testFunc = sprintf('is_%1$s', $typeName);
            $isOfType = call_user_func_array($testFunc, [$value]);
        }
        // If type is not built-in, then check whether instance of
        else {
            $isOfType = $value instanceof $typeName;
        }

        if (!$isOfType) {
            return $this->__('Value must be of type "%1$s"', [$typeName]);
        }

        return;
    }
protected function _getValueTypeError ( $ value , $ type ) { if ( ! ( $ type instanceof ReflectionType ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Type criterion is invalid' ) , null , null , $ type ) ; } $ typeName = method_exists ( $ type , 'getName' ) ? $ type -> getName ( ) : $ type -> __toString ( ) ; $ isOfType = null ; // If type is built-in, it should be safe to use a built-in function if ( $ type -> isBuiltin ( ) ) { $ testFunc = sprintf ( 'is_%1$s' , $ typeName ) ; $ isOfType = call_user_func_array ( $ testFunc , [ $ value ] ) ; } // If type is not built-in, then check whether instance of else { $ isOfType = $ value instanceof $ typeName ; } if ( ! $ isOfType ) { return $ this -> __ ( 'Value must be of type "%1$s"' , [ $ typeName ] ) ; } return ; }
Generates a list of reasons for a value failing validation against a type spec.

@since [*next-version*]

@param mixed          $value The value being validated.
@param ReflectionType $type  A type criteria.

@throws InvalidArgumentException If one of the criteria is invalid.

@return string|Stringable|null The error, if value doesn't match the spec; `null` otherwise.
Generates a list of reasons for a value failing validation against a type spec .