checks type of default value

@param   \Closure  $isCorrectType         check to be executed when default value is not null
@param   string    $expectedType  expected type of default value
@throws  \LogicException
481250
private function checkDefaultType(\Closure $isCorrectType, string $expectedType)
    {
        if (!$isCorrectType()) {
            throw new \LogicException(
                    'Default value is not of type ' . $expectedType
                    . ' but of type ' . typeOf($this->default)
            );
        }
    }
1246425
protected function checkSpecificObject(array $acceptedTypes, $value)
    {
        if (is_object($value)) {
            foreach ($acceptedTypes as $type) {
                $c = get_class($value);
                if ($c == ltrim($type, '\\') || is_subclass_of($c, $type)) {
                    return $value;
                }
            }
        }

        return null;
    }
303472
public function expectCurrent($type, $value = null)
    {
        if ($this->current->test($type, $value)) {
            return $this->current;
        }
        $value   = $this->current->getValue();
        $message = "Unexpected {$this->current->getTypeString()}";
        if ($value === true) {
            $message .= ' (true)';
        } elseif ($value === false) {
            $message .= ' (false)';
        } elseif ($value !== '') {
            $message .= " ({$value})";
        }
        throw new SyntaxException($message, $this->current->getLine());
    }
242207
public function setType( $type )
    {
        if ( empty( static::$type ) )
        {
            $this->proxyBase->type = $type;
        }
        elseif ( static::$type != $type )
        {
            throw new LogicException( 'Cannot alter type after creation' );
        }

        return $this;
    }
466441
public function type($type)
    {
        $type = strtoupper($type);

        if (!in_array($type, ['INSERT', 'INSERT IGNORE', 'REPLACE'])) {
            throw new \UnexpectedValueException('Invalid insert type');
        }

        $this->type = $type;

        return $this;
    }
519676
static public function isBaseTypeCompliant($baseType, $value)
    {
        if ($value === null) {
            return true; // A value can always be null.
        } elseif ($value instanceof QtiDatatype && $baseType === $value->getBaseType()) {
            return true;
        } else {
            return false;
        }
    }
650491
protected void checkTypes(TermType expectedBaseType, TermType argumentType) {
        if (argumentType.isAbstract())
            throw new AbstractTermTypeException(argumentType);

        if (!argumentType.isA(expectedBaseType)) {
            throw new IncompatibleTermException(expectedBaseType, argumentType);
        }
    }
1150628
protected static function validateType(Node $node, string $expectedType): Node
    {
        if (! $node instanceof $expectedType) {
            throw new ParseException("The given definition was not of type: $expectedType");
        }

        return $node;
    }
859312
public static boolean matchValueByName(String expectedType, Object actualValue) {
		if (expectedType == null)
			return true;
		if (actualValue == null)
			throw new NullPointerException("Actual value cannot be null");

		return matchTypeByName(expectedType, actualValue.getClass());
	}
841994
public function isType($type)
    {
        if (!$this->isTypeSupported($type)) {
            throw new Exception('Unsupported query type');
        }

        return isset($this->parsedSql[$type]);
    }
47257
private function _processGatewayResponse($response, $expectedType)
    {
        $gatewayRspCode = (isset($response->Header->GatewayRspCode) ? $response->Header->GatewayRspCode : null);
        $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null);

        if ($gatewayRspCode == '0') {
            return;
        }

        if ($gatewayRspCode == '30') {
            try {
                $this->void($transactionId);
            } catch (Exception $e) {
                throw new HpsGatewayException(
                    HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR,
                    'Error occurred while reversing a charge due to HPS gateway timeout',
                    $e,
                    null,
                    null,
                    $transactionId
                );
            }
        }

        HpsGatewayResponseValidation::checkResponse($response, $expectedType);
    }
542888
public function setDefault($default = null)
    {
        if (self::REQUIRED === $this->mode && null !== $default) {
            throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
        }

        if ($this->isArray()) {
            if (null === $default) {
                $default = [];
            } elseif (!\is_array($default)) {
                throw new LogicException('A default value for an array argument must be an array.');
            }
        }

        $this->default = $default;
    }
681280
public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof Json) {
            throw new UnexpectedTypeException($constraint, Json::class);
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        if (json_decode($value) || json_last_error() === JSON_ERROR_NONE) {
            return;
        }

        $this->context->buildViolation($constraint->message)
            ->setParameter('{{ value }}', $this->formatValue($value))
            ->addViolation();
    }
955559
public static function unexpectedGeometryType(string $expectedClass, $value) : UnexpectedGeometryException
    {
        $value = is_object($value) ? get_class($value) : gettype($value);
        $message = sprintf('Unexpected geometry type: expected %s, got %s.', $expectedClass, $value);

        return new self($message);
    }
159052
public function setDefaultResultType($resultType)
    {
        if (defined('self::RESULT_' . strtoupper($resultType))) {
            $this->defaultResultType = constant('self::RESULT_' . strtoupper($resultType));
        }

        return $this;
    }
203893
public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual)
    {
        return self::typeError(sprintf(
            'Attribute "%s" of @%s declared on %s expects %s, but got %s.',
            $attributeName,
            $annotationName,
            $context,
            $expected,
            is_object($actual) ? 'an instance of ' . get_class($actual) : gettype($actual)
        ));
    }
877965
public static boolean checkResponseTypes(final String type, final OAuth20ResponseTypes... expectedTypes) {
        LOGGER.debug("Response type: [{}]", type);
        val checked = Stream.of(expectedTypes).anyMatch(t -> OAuth20Utils.isResponseType(type, t));
        if (!checked) {
            LOGGER.error("Unsupported response type: [{}]", type);
        }
        return checked;
    }