private function tryDecodeValueFromGetterType(
        ReflectionClass $reflectionClass,
        string $normalizedPropertyName,
        $encodedValue,
        EncodingContext $context,
        &$decodedValue
    ): bool {
        // Check if we can infer the type from any getters or setters
        foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
            if (
                !$reflectionMethod->hasReturnType() ||
                $reflectionMethod->getReturnType() === 'array' ||
                $reflectionMethod->isConstructor() ||
                $reflectionMethod->isDestructor() ||
                $reflectionMethod->getNumberOfRequiredParameters() > 0
            ) {
                continue;
            }

            $propertyName = null;

            // Try to extract the property name from the getter/has-er/is-er
            if (strpos($reflectionMethod->name, 'get') === 0 || strpos($reflectionMethod->name, 'has') === 0) {
                $propertyName = lcfirst(substr($reflectionMethod->name, 3));
            } elseif (strpos($reflectionMethod->name, 'is') === 0) {
                $propertyName = lcfirst(substr($reflectionMethod->name, 2));
            }

            if ($propertyName === null) {
                continue;
            }

            $encodedPropertyName = $this->normalizePropertyName($propertyName);

            // This getter matches the property name we're looking for
            if ($encodedPropertyName === $normalizedPropertyName) {
                try {
                    $reflectionMethodReturnType = (string)$reflectionMethod->getReturnType();
                    $decodedValue = $this->encoders->getEncoderForType($reflectionMethodReturnType)
                        ->decode($encodedValue, $reflectionMethodReturnType, $context);

                    return true;
                } catch (EncodingException $ex) {
                    return false;
                }
            }
        }

        return false;
    }
private function tryDecodeValueFromGetterType(
        ReflectionClass $reflectionClass,
        string $normalizedPropertyName,
        $encodedValue,
        EncodingContext $context,
        &$decodedValue
    ): bool {
        // Check if we can infer the type from any getters or setters
        foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
            if (
                !$reflectionMethod->hasReturnType() ||
                $reflectionMethod->getReturnType() === 'array' ||
                $reflectionMethod->isConstructor() ||
                $reflectionMethod->isDestructor() ||
                $reflectionMethod->getNumberOfRequiredParameters() > 0
            ) {
                continue;
            }

            $propertyName = null;

            // Try to extract the property name from the getter/has-er/is-er
            if (strpos($reflectionMethod->name, 'get') === 0 || strpos($reflectionMethod->name, 'has') === 0) {
                $propertyName = lcfirst(substr($reflectionMethod->name, 3));
            } elseif (strpos($reflectionMethod->name, 'is') === 0) {
                $propertyName = lcfirst(substr($reflectionMethod->name, 2));
            }

            if ($propertyName === null) {
                continue;
            }

            $encodedPropertyName = $this->normalizePropertyName($propertyName);

            // This getter matches the property name we're looking for
            if ($encodedPropertyName === $normalizedPropertyName) {
                try {
                    $reflectionMethodReturnType = (string)$reflectionMethod->getReturnType();
                    $decodedValue = $this->encoders->getEncoderForType($reflectionMethodReturnType)
                        ->decode($encodedValue, $reflectionMethodReturnType, $context);

                    return true;
                } catch (EncodingException $ex) {
                    return false;
                }
            }
        }

        return false;
    }
private function tryDecodeValueFromGetterType ( ReflectionClass $ reflectionClass , string $ normalizedPropertyName , $ encodedValue , EncodingContext $ context , & $ decodedValue ) : bool { // Check if we can infer the type from any getters or setters foreach ( $ reflectionClass -> getMethods ( ReflectionMethod :: IS_PUBLIC ) as $ reflectionMethod ) { if ( ! $ reflectionMethod -> hasReturnType ( ) || $ reflectionMethod -> getReturnType ( ) === 'array' || $ reflectionMethod -> isConstructor ( ) || $ reflectionMethod -> isDestructor ( ) || $ reflectionMethod -> getNumberOfRequiredParameters ( ) > 0 ) { continue ; } $ propertyName = null ; // Try to extract the property name from the getter/has-er/is-er if ( strpos ( $ reflectionMethod -> name , 'get' ) === 0 || strpos ( $ reflectionMethod -> name , 'has' ) === 0 ) { $ propertyName = lcfirst ( substr ( $ reflectionMethod -> name , 3 ) ) ; } elseif ( strpos ( $ reflectionMethod -> name , 'is' ) === 0 ) { $ propertyName = lcfirst ( substr ( $ reflectionMethod -> name , 2 ) ) ; } if ( $ propertyName === null ) { continue ; } $ encodedPropertyName = $ this -> normalizePropertyName ( $ propertyName ) ; // This getter matches the property name we're looking for if ( $ encodedPropertyName === $ normalizedPropertyName ) { try { $ reflectionMethodReturnType = ( string ) $ reflectionMethod -> getReturnType ( ) ; $ decodedValue = $ this -> encoders -> getEncoderForType ( $ reflectionMethodReturnType ) -> decode ( $ encodedValue , $ reflectionMethodReturnType , $ context ) ; return true ; } catch ( EncodingException $ ex ) { return false ; } } } return false ; }
Decodes a value using the type info from get, is, or has methods

@param ReflectionClass $reflectionClass The reflection class
@param string $normalizedPropertyName The normalized property name
@param mixed $encodedValue The encoded value
@param EncodingContext $context The encoding context
@param mixed The decoded value
@return bool Returns true if the value was successfully decoded, otherwise false
Decodes a value using the type info from get is or has methods