private function extractFromConstructor(string $class, string $property): ?array
    {
        try {
            $reflectionClass = new \ReflectionClass($class);
        } catch (\ReflectionException $e) {
            return null;
        }

        $constructor = $reflectionClass->getConstructor();

        if (!$constructor) {
            return null;
        }

        foreach ($constructor->getParameters() as $parameter) {
            if ($property !== $parameter->name) {
                continue;
            }
            $reflectionType = $parameter->getType();

            return $reflectionType ? [$this->extractFromReflectionType($reflectionType, $constructor)] : null;
        }

        if ($parentClass = $reflectionClass->getParentClass()) {
            return $this->extractFromConstructor($parentClass->getName(), $property);
        }

        return null;
    }
private function extractFromConstructor(string $class, string $property): ?array
    {
        try {
            $reflectionClass = new \ReflectionClass($class);
        } catch (\ReflectionException $e) {
            return null;
        }

        $constructor = $reflectionClass->getConstructor();

        if (!$constructor) {
            return null;
        }

        foreach ($constructor->getParameters() as $parameter) {
            if ($property !== $parameter->name) {
                continue;
            }
            $reflectionType = $parameter->getType();

            return $reflectionType ? [$this->extractFromReflectionType($reflectionType, $constructor)] : null;
        }

        if ($parentClass = $reflectionClass->getParentClass()) {
            return $this->extractFromConstructor($parentClass->getName(), $property);
        }

        return null;
    }
private function extractFromConstructor ( string $ class , string $ property ) : ? array { try { $ reflectionClass = new \ ReflectionClass ( $ class ) ; } catch ( \ ReflectionException $ e ) { return null ; } $ constructor = $ reflectionClass -> getConstructor ( ) ; if ( ! $ constructor ) { return null ; } foreach ( $ constructor -> getParameters ( ) as $ parameter ) { if ( $ property !== $ parameter -> name ) { continue ; } $ reflectionType = $ parameter -> getType ( ) ; return $ reflectionType ? [ $ this -> extractFromReflectionType ( $ reflectionType , $ constructor ) ] : null ; } if ( $ parentClass = $ reflectionClass -> getParentClass ( ) ) { return $ this -> extractFromConstructor ( $ parentClass -> getName ( ) , $ property ) ; } return null ; }
Tries to extract type information from constructor.

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