private function extractFromMutator($class, $property)
    {
        list($reflectionMethod, $prefix) = $this->getMutatorMethod($class, $property);
        if (null === $reflectionMethod) {
            return;
        }

        $reflectionParameters = $reflectionMethod->getParameters();
        $reflectionParameter = $reflectionParameters[0];

        $arrayMutator = in_array($prefix, self::$arrayMutatorPrefixes);

        if (method_exists($reflectionParameter, 'getType') && $reflectionType = $reflectionParameter->getType()) {
            $fromReflectionType = $this->extractFromReflectionType($reflectionType);

            if (!$arrayMutator) {
                return array($fromReflectionType);
            }

            $phpType = Type::BUILTIN_TYPE_ARRAY;
            $collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
            $collectionValueType = $fromReflectionType;
        }

        if ($reflectionParameter->isArray()) {
            $phpType = Type::BUILTIN_TYPE_ARRAY;
            $collection = true;
        }

        if ($arrayMutator) {
            $collection = true;
            $nullable = false;
            $collectionNullable = $reflectionParameter->allowsNull();
        } else {
            $nullable = $reflectionParameter->allowsNull();
            $collectionNullable = false;
        }

        if (!isset($collection)) {
            $collection = false;
        }

        if (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) {
            $phpType = Type::BUILTIN_TYPE_CALLABLE;
        }

        if ($typeHint = $reflectionParameter->getClass()) {
            if ($collection) {
                $phpType = Type::BUILTIN_TYPE_ARRAY;
                $collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
                $collectionValueType = new Type(Type::BUILTIN_TYPE_OBJECT, $collectionNullable, $typeHint->name);
            } else {
                $phpType = Type::BUILTIN_TYPE_OBJECT;
                $typeClass = $typeHint->name;
            }
        }

        // Nothing useful extracted
        if (!isset($phpType)) {
            return;
        }

        return array(
            new Type(
                $phpType,
                $nullable,
                isset($typeClass) ? $typeClass : null,
                $collection,
                isset($collectionKeyType) ? $collectionKeyType : null,
                isset($collectionValueType) ? $collectionValueType : null
            ),
        );
    }
private function extractFromMutator($class, $property)
    {
        list($reflectionMethod, $prefix) = $this->getMutatorMethod($class, $property);
        if (null === $reflectionMethod) {
            return;
        }

        $reflectionParameters = $reflectionMethod->getParameters();
        $reflectionParameter = $reflectionParameters[0];

        $arrayMutator = in_array($prefix, self::$arrayMutatorPrefixes);

        if (method_exists($reflectionParameter, 'getType') && $reflectionType = $reflectionParameter->getType()) {
            $fromReflectionType = $this->extractFromReflectionType($reflectionType);

            if (!$arrayMutator) {
                return array($fromReflectionType);
            }

            $phpType = Type::BUILTIN_TYPE_ARRAY;
            $collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
            $collectionValueType = $fromReflectionType;
        }

        if ($reflectionParameter->isArray()) {
            $phpType = Type::BUILTIN_TYPE_ARRAY;
            $collection = true;
        }

        if ($arrayMutator) {
            $collection = true;
            $nullable = false;
            $collectionNullable = $reflectionParameter->allowsNull();
        } else {
            $nullable = $reflectionParameter->allowsNull();
            $collectionNullable = false;
        }

        if (!isset($collection)) {
            $collection = false;
        }

        if (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) {
            $phpType = Type::BUILTIN_TYPE_CALLABLE;
        }

        if ($typeHint = $reflectionParameter->getClass()) {
            if ($collection) {
                $phpType = Type::BUILTIN_TYPE_ARRAY;
                $collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
                $collectionValueType = new Type(Type::BUILTIN_TYPE_OBJECT, $collectionNullable, $typeHint->name);
            } else {
                $phpType = Type::BUILTIN_TYPE_OBJECT;
                $typeClass = $typeHint->name;
            }
        }

        // Nothing useful extracted
        if (!isset($phpType)) {
            return;
        }

        return array(
            new Type(
                $phpType,
                $nullable,
                isset($typeClass) ? $typeClass : null,
                $collection,
                isset($collectionKeyType) ? $collectionKeyType : null,
                isset($collectionValueType) ? $collectionValueType : null
            ),
        );
    }
private function extractFromMutator ( $ class , $ property ) { list ( $ reflectionMethod , $ prefix ) = $ this -> getMutatorMethod ( $ class , $ property ) ; if ( null === $ reflectionMethod ) { return ; } $ reflectionParameters = $ reflectionMethod -> getParameters ( ) ; $ reflectionParameter = $ reflectionParameters [ 0 ] ; $ arrayMutator = in_array ( $ prefix , self :: $ arrayMutatorPrefixes ) ; if ( method_exists ( $ reflectionParameter , 'getType' ) && $ reflectionType = $ reflectionParameter -> getType ( ) ) { $ fromReflectionType = $ this -> extractFromReflectionType ( $ reflectionType ) ; if ( ! $ arrayMutator ) { return array ( $ fromReflectionType ) ; } $ phpType = Type :: BUILTIN_TYPE_ARRAY ; $ collectionKeyType = new Type ( Type :: BUILTIN_TYPE_INT ) ; $ collectionValueType = $ fromReflectionType ; } if ( $ reflectionParameter -> isArray ( ) ) { $ phpType = Type :: BUILTIN_TYPE_ARRAY ; $ collection = true ; } if ( $ arrayMutator ) { $ collection = true ; $ nullable = false ; $ collectionNullable = $ reflectionParameter -> allowsNull ( ) ; } else { $ nullable = $ reflectionParameter -> allowsNull ( ) ; $ collectionNullable = false ; } if ( ! isset ( $ collection ) ) { $ collection = false ; } if ( method_exists ( $ reflectionParameter , 'isCallable' ) && $ reflectionParameter -> isCallable ( ) ) { $ phpType = Type :: BUILTIN_TYPE_CALLABLE ; } if ( $ typeHint = $ reflectionParameter -> getClass ( ) ) { if ( $ collection ) { $ phpType = Type :: BUILTIN_TYPE_ARRAY ; $ collectionKeyType = new Type ( Type :: BUILTIN_TYPE_INT ) ; $ collectionValueType = new Type ( Type :: BUILTIN_TYPE_OBJECT , $ collectionNullable , $ typeHint -> name ) ; } else { $ phpType = Type :: BUILTIN_TYPE_OBJECT ; $ typeClass = $ typeHint -> name ; } } // Nothing useful extracted if ( ! isset ( $ phpType ) ) { return ; } return array ( new Type ( $ phpType , $ nullable , isset ( $ typeClass ) ? $ typeClass : null , $ collection , isset ( $ collectionKeyType ) ? $ collectionKeyType : null , isset ( $ collectionValueType ) ? $ collectionValueType : null ) , ) ; }
Tries to extract type information from mutators.

@param string $class
@param string $property

@return Type[]|null
Tries to extract type information from mutators .