src/Evispa/ObjectMigration/VersionReader.php
private function findClassNameByVersion($startFromClassName, $version, &$visited = array())
    {
        $versionAnnotation = $this->reader->getClassAnnotation(
            new \ReflectionClass($startFromClassName),
            'Evispa\ObjectMigration\Annotations\Version'
        );

        if ($versionAnnotation->version === $version) {
            return $startFromClassName;
        }

        $migrationAnnotations = $this->getClassMigrationMethodInfo($startFromClassName);
        /** @var MethodInfo $methodInfo */
        foreach ($migrationAnnotations as $methodInfo) {
            if ($methodInfo->annotation->from && !in_array($methodInfo->annotation->from, $visited)) {
                $visited[] = $methodInfo->annotation->from;
                $className = $this->getClassNameByVersion($methodInfo->annotation->from, $version, $visited);
                if ($className) {
                    return $className;
                }
            }

            if ($methodInfo->annotation->to && !in_array($methodInfo->annotation->to, $visited)) {
                $visited[] = $methodInfo->annotation->to;
                $className = $this->getClassNameByVersion($methodInfo->annotation->to, $version, $visited);
                if ($className) {
                    return $className;
                }
            }
        }

        return null;
    }
private function findClassNameByVersion($startFromClassName, $version, &$visited = array())
    {
        $versionAnnotation = $this->reader->getClassAnnotation(
            new \ReflectionClass($startFromClassName),
            'Evispa\ObjectMigration\Annotations\Version'
        );

        if ($versionAnnotation->version === $version) {
            return $startFromClassName;
        }

        $migrationAnnotations = $this->getClassMigrationMethodInfo($startFromClassName);
        /** @var MethodInfo $methodInfo */
        foreach ($migrationAnnotations as $methodInfo) {
            if ($methodInfo->annotation->from && !in_array($methodInfo->annotation->from, $visited)) {
                $visited[] = $methodInfo->annotation->from;
                $className = $this->getClassNameByVersion($methodInfo->annotation->from, $version, $visited);
                if ($className) {
                    return $className;
                }
            }

            if ($methodInfo->annotation->to && !in_array($methodInfo->annotation->to, $visited)) {
                $visited[] = $methodInfo->annotation->to;
                $className = $this->getClassNameByVersion($methodInfo->annotation->to, $version, $visited);
                if ($className) {
                    return $className;
                }
            }
        }

        return null;
    }
Search for class name by version id

@param string $startFromClassName
@param string $version
@param array  $visited

@return null|string