private function decodeConstructorParamValue(
        ReflectionParameter $constructorParam,
        $constructorParamValue,
        ReflectionClass $reflectionClass,
        string $normalizedHashPropertyName,
        EncodingContext $context
    ) {
        if ($constructorParam->hasType() && !$constructorParam->isArray() && !$constructorParam->isVariadic()) {
            $constructorParamType = (string)$constructorParam->getType();

            return $this->encoders->getEncoderForType($constructorParamType)
                ->decode($constructorParamValue, $constructorParamType, $context);
        }

        if ($constructorParam->isVariadic() || $constructorParam->isArray()) {
            return $this->decodeArrayOrVariadicConstructorParamValue(
                $constructorParam,
                $constructorParamValue,
                $context
            );
        }

        $decodedValue = null;

        if (
        $this->tryDecodeValueFromGetterType(
            $reflectionClass,
            $normalizedHashPropertyName,
            $constructorParamValue,
            $context,
            $decodedValue
        )
        ) {
            return $decodedValue;
        }

        // At this point, let's just check if the value we're trying to decode is a scalar, and if so, just return it
        if (is_scalar($constructorParamValue)) {
            $type = gettype($constructorParamValue);

            return $this->encoders->getEncoderForType($type)
                ->decode($constructorParamValue, $type, $context);
        }

        throw new EncodingException("Failed to decode constructor parameter {$constructorParam->getName()}");
    }
private function decodeConstructorParamValue(
        ReflectionParameter $constructorParam,
        $constructorParamValue,
        ReflectionClass $reflectionClass,
        string $normalizedHashPropertyName,
        EncodingContext $context
    ) {
        if ($constructorParam->hasType() && !$constructorParam->isArray() && !$constructorParam->isVariadic()) {
            $constructorParamType = (string)$constructorParam->getType();

            return $this->encoders->getEncoderForType($constructorParamType)
                ->decode($constructorParamValue, $constructorParamType, $context);
        }

        if ($constructorParam->isVariadic() || $constructorParam->isArray()) {
            return $this->decodeArrayOrVariadicConstructorParamValue(
                $constructorParam,
                $constructorParamValue,
                $context
            );
        }

        $decodedValue = null;

        if (
        $this->tryDecodeValueFromGetterType(
            $reflectionClass,
            $normalizedHashPropertyName,
            $constructorParamValue,
            $context,
            $decodedValue
        )
        ) {
            return $decodedValue;
        }

        // At this point, let's just check if the value we're trying to decode is a scalar, and if so, just return it
        if (is_scalar($constructorParamValue)) {
            $type = gettype($constructorParamValue);

            return $this->encoders->getEncoderForType($type)
                ->decode($constructorParamValue, $type, $context);
        }

        throw new EncodingException("Failed to decode constructor parameter {$constructorParam->getName()}");
    }
private function decodeConstructorParamValue ( ReflectionParameter $ constructorParam , $ constructorParamValue , ReflectionClass $ reflectionClass , string $ normalizedHashPropertyName , EncodingContext $ context ) { if ( $ constructorParam -> hasType ( ) && ! $ constructorParam -> isArray ( ) && ! $ constructorParam -> isVariadic ( ) ) { $ constructorParamType = ( string ) $ constructorParam -> getType ( ) ; return $ this -> encoders -> getEncoderForType ( $ constructorParamType ) -> decode ( $ constructorParamValue , $ constructorParamType , $ context ) ; } if ( $ constructorParam -> isVariadic ( ) || $ constructorParam -> isArray ( ) ) { return $ this -> decodeArrayOrVariadicConstructorParamValue ( $ constructorParam , $ constructorParamValue , $ context ) ; } $ decodedValue = null ; if ( $ this -> tryDecodeValueFromGetterType ( $ reflectionClass , $ normalizedHashPropertyName , $ constructorParamValue , $ context , $ decodedValue ) ) { return $ decodedValue ; } // At this point, let's just check if the value we're trying to decode is a scalar, and if so, just return it if ( is_scalar ( $ constructorParamValue ) ) { $ type = gettype ( $ constructorParamValue ) ; return $ this -> encoders -> getEncoderForType ( $ type ) -> decode ( $ constructorParamValue , $ type , $ context ) ; } throw new EncodingException ( "Failed to decode constructor parameter {$constructorParam->getName()}" ) ; }
Decodes a constructor parameter value

@param ReflectionParameter $constructorParam The constructor parameter to decode
@param mixed $constructorParamValue The encoded constructor parameter value
@param ReflectionClass $reflectionClass The reflection class we're trying to instantiate
@param string $normalizedHashPropertyName The encoded property name from the hash
@param EncodingContext $context The encoding context
@return mixed The decoded constructor parameter value
@throws EncodingException Thrown if the value could not be automatically decoded
Decodes a constructor parameter value