src/DoctrineStaticMeta.php
private function getTypesFromVarComment(string $property, ReflectionClass $traitReflection): array
    {
        $docComment = $this->reflectionClass->getProperty($property)->getDocComment();
        \preg_match('%@var\s*?(.+)%', $docComment, $matches);
        $traitCode = \ts\file_get_contents($traitReflection->getFileName());
        $types     = \explode('|', $matches[1]);
        $return    = [];
        foreach ($types as $type) {
            $type = \trim($type);
            if ('null' === $type) {
                continue;
            }
            if ('ArrayCollection' === $type) {
                continue;
            }
            $arrayNotation = '';
            if ('[]' === substr($type, -2)) {
                $type          = substr($type, 0, -2);
                $arrayNotation = '[]';
            }
            $pattern = "%^use (.+?)\\\\${type}(;| |\[)%m";
            \preg_match($pattern, $traitCode, $matches);
            if (!isset($matches[1])) {
                throw new \RuntimeException(
                    'Failed finding match for type ' . $type . ' in ' . $traitReflection->getFileName()
                );
            }
            $return[] = $matches[1] . '\\' . $type . $arrayNotation;
        }

        return $return;
    }
private function getTypesFromVarComment(string $property, ReflectionClass $traitReflection): array
    {
        $docComment = $this->reflectionClass->getProperty($property)->getDocComment();
        \preg_match('%@var\s*?(.+)%', $docComment, $matches);
        $traitCode = \ts\file_get_contents($traitReflection->getFileName());
        $types     = \explode('|', $matches[1]);
        $return    = [];
        foreach ($types as $type) {
            $type = \trim($type);
            if ('null' === $type) {
                continue;
            }
            if ('ArrayCollection' === $type) {
                continue;
            }
            $arrayNotation = '';
            if ('[]' === substr($type, -2)) {
                $type          = substr($type, 0, -2);
                $arrayNotation = '[]';
            }
            $pattern = "%^use (.+?)\\\\${type}(;| |\[)%m";
            \preg_match($pattern, $traitCode, $matches);
            if (!isset($matches[1])) {
                throw new \RuntimeException(
                    'Failed finding match for type ' . $type . ' in ' . $traitReflection->getFileName()
                );
            }
            $return[] = $matches[1] . '\\' . $type . $arrayNotation;
        }

        return $return;
    }
private function getTypesFromVarComment ( string $ property , ReflectionClass $ traitReflection ) : array { $ docComment = $ this -> reflectionClass -> getProperty ( $ property ) -> getDocComment ( ) ; \ preg_match ( '%@var\s*?(.+)%' , $ docComment , $ matches ) ; $ traitCode = \ ts \ file_get_contents ( $ traitReflection -> getFileName ( ) ) ; $ types = \ explode ( '|' , $ matches [ 1 ] ) ; $ return = [ ] ; foreach ( $ types as $ type ) { $ type = \ trim ( $ type ) ; if ( 'null' === $ type ) { continue ; } if ( 'ArrayCollection' === $ type ) { continue ; } $ arrayNotation = '' ; if ( '[]' === substr ( $ type , - 2 ) ) { $ type = substr ( $ type , 0 , - 2 ) ; $ arrayNotation = '[]' ; } $ pattern = "%^use (.+?)\\\\${type}(;| |\[)%m" ; \ preg_match ( $ pattern , $ traitCode , $ matches ) ; if ( ! isset ( $ matches [ 1 ] ) ) { throw new \ RuntimeException ( 'Failed finding match for type ' . $ type . ' in ' . $ traitReflection -> getFileName ( ) ) ; } $ return [ ] = $ matches [ 1 ] . '\\' . $ type . $ arrayNotation ; } return $ return ; }
Parse the docblock for a property and get the type, then read the source code to resolve the short type to the
FQN of the type. Roll on PHP 7.3

@param string          $property

@param ReflectionClass $traitReflection

@return array
Parse the docblock for a property and get the type then read the source code to resolve the short type to the FQN of the type . Roll on PHP 7 . 3