public static function createRelativeClassPath(
        array $sourceComponents,
        array $targetComponents)
    {
        $sourceNs = &$sourceComponents['namespace'];
        $targetNs = &$targetComponents['namespace'];
        $finalType = null;

        // If either the source or the target lives in the global namespace,
        // we won't do this processing. (Those need a strict, global path.)
        if ($sourceNs !== '' && $targetNs !== '') {
            // Check if the source-class namespace is at pos 0 of target space.
            $pos = strpos($targetNs, $sourceNs);
            if ($pos === 0) {
                // Look at the character after the source-class namespace in the
                // target namespace. Check for "" (str end) or "\\" (subspace).
                $sourceNsLen = strlen($sourceNs);
                $chr = substr($targetNs, $sourceNsLen, 1);
                if ($chr === '') { // Exact same space, without any subspace.
                    $finalType = $targetComponents['class'];
                } elseif ($chr === '\\') { // Same space, followed by subspace.
                    $finalType = sprintf(
                        '%s\\%s',
                        substr($targetNs, $sourceNsLen + 1),
                        $targetComponents['class']
                    );
                } // Else: Was false positive, not in same namespace.
            }
        }

        // In case of totally different spaces, or if any of the classes are in
        // the global namespace, then just use the strict, global target path.
        if ($finalType === null) {
            $finalType = sprintf(
                '%s\\%s',
                $targetNs,
                $targetComponents['class']
            );
        }

        return $finalType;
    }