src/Exception/TypeMismatchException.php
public static function fromValue(
        $expected_type,
        $actual_value,
        DeserializationContext $context = null
    ) {
        if (null !== $context && count($context->getCurrentPath()) > 0) {
            $property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath()));
        } else {
            $property = '';
        }

        return new static(sprintf(
            'Expected %s%s, but got %s: %s',
            $property,
            $expected_type,
            gettype($actual_value),
            json_encode($actual_value)
        ));
    }
public static function fromValue(
        $expected_type,
        $actual_value,
        DeserializationContext $context = null
    ) {
        if (null !== $context && count($context->getCurrentPath()) > 0) {
            $property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath()));
        } else {
            $property = '';
        }

        return new static(sprintf(
            'Expected %s%s, but got %s: %s',
            $property,
            $expected_type,
            gettype($actual_value),
            json_encode($actual_value)
        ));
    }
public static function fromValue ( $ expected_type , $ actual_value , DeserializationContext $ context = null ) { if ( null !== $ context && count ( $ context -> getCurrentPath ( ) ) > 0 ) { $ property = sprintf ( 'property "%s" to be ' , implode ( '.' , $ context -> getCurrentPath ( ) ) ) ; } else { $ property = '' ; } return new static ( sprintf ( 'Expected %s%s, but got %s: %s' , $ property , $ expected_type , gettype ( $ actual_value ) , json_encode ( $ actual_value ) ) ) ; }
A handy method for building exception instance.

@param string $expected_type
@param mixed $actual_value
@param DeserializationContext|null $context
@return TypeMismatchException
A handy method for building exception instance .