Explode the keys.

If a key contains backslashes before any dots, then don't explode based on that dot.

@param string $keyPath
@return array
@throws BadKeyPath
490339
private static function explodeKeys($keyPath)
    {
        $keys = explode('.', $keyPath);
        if (strpos($keyPath, '\\.') === false) {
            return array_filter($keys, function($elem) { return $elem !== ''; });
        }

        //
        // This is the slow path, where the keys contain escaped dots:
        //
        $joinNext = false;
        $result = array();
        $next = 0;
        foreach ($keys as $index => $key) {
            $len = strlen($key);
            if ($len === 0) {
                continue;
            }
            $endsWithBackslash = $key[$len - 1] === '\\';
            if ($joinNext) {
                $result[$next - 1] = sprintf("%s.%s", substr($result[$next - 1], 0, -1), $key);
                $joinNext = $endsWithBackslash;
                continue;
            }
            elseif ($endsWithBackslash) {
                $joinNext = true;
            }
            $result[$next] = $key;
            $next += 1;
        }

        return $result;
    }
1275111
public static function removeDotSegments($path)
    {
        static $noopPaths = ['' => true, '/' => true, '*' => true];
        static $ignoreSegments = ['.' => true, '..' => true];

        if (array_key_exists($path, $noopPaths)) {
            return $path;
        }

        $results = [];
        $segments = explode('/', $path);
        foreach ($segments as $segment) {
            if ($segment === '..') {
                array_pop($results);
            } elseif (!array_key_exists($segment, $ignoreSegments)) {
                $results[] = $segment;
            }
        }

        $newPath = implode('/', $results);
        // add the leading slash if necessary
        if (strpos($path, '/') === 0 && strpos($newPath, '/') !== 0) {
            $newPath = '/' . $newPath;
        }

        // add the trailing slash if necessary
        if ($newPath !== '/' && array_key_exists(end($segments), $ignoreSegments)) {
            $newPath .= '/';
        }

        return $newPath;
    }
388030
protected function explode_node_path($path) {
        list($mode, $realpath, $display) = explode(':', $path);
        return array(
            $mode,
            base64_decode($realpath),
            base64_decode($display)
        );
    }
1302272
public function realpath($path)
    {
        $path = str_replace('\\', '/', rtrim($path, '/'));
        if ($path[0] != '/' && (strlen($path) < 2 || $path[1] != ':')) {
            $path = getcwd() . '/' . $path;
        }
        $parts = explode('/', $path);
        $path = [];
        foreach ($parts as $part) {
            if ($part == '..') {
                array_pop($path);
            } else if ($part != '.') {
                array_push($path, $part);
            }
        }
        return implode('/', $path);
    }
190205
public function fields($basePath = '')
    {
        $fields = [];
        foreach ($this->names() as $name) {
            $fields[$name] = null;
        }
        $names = Set::expand($fields);
        if ($basePath) {
            $parts = explode('.', $basePath);
            foreach ($parts as $part) {
                if (!isset($names[$part])) {
                    return [];
                }
                $names = $names[$part];
            }
        }
        return array_keys($names);
    }
661996
protected function explode_path($path) {
        $parts = explode('/', $path, 2);
        if (isset($parts[1]) && $parts[1] !== '') {
            list($bucket, $uri) = $parts;
        } else {
            $bucket = $parts[0];
            $uri = '';
        }
        return array($bucket, $uri);
    }
1271599
public function memberIn($searchKeyPath)
    {
        $path = ArrayList::of($searchKeyPath);

        if ($path->count() === 0) {
            return false;
        }

        if ($path->count() === 1) {
            return $this->member($path->head());
        }

        if ($this->member($path->head()) === false) {
            return false;
        }

        $innerValue = Maybe::fromJust($this->lookup($path->head()));

        if ($innerValue instanceof Iterable) {
            return $innerValue->memberIn($path->tail());
        }

        return false;
    }
276770
protected function tokenizePath($path)
    {
        $parts = explode($this->pathSeparator, $path);
        if ($this->trimTokens) {
            for ($i = 0; $i < count($parts); $i++) {
                $parts[$i] = trim($parts[$i]);
                if ($parts[$i] === "") {
                    unset($parts[$i]);
                }
            }
        }
        return array_values($parts);
    }
703074
public static function driversIn($path)
    {
        if (! is_dir($path)) {
            return [];
        }

        $drivers = [];

        $dir = new RecursiveDirectoryIterator($path);
        $iterator = new RecursiveIteratorIterator($dir);
        $regex = new RegexIterator($iterator, '/^.+ValetDriver\.php$/i', RecursiveRegexIterator::GET_MATCH);

        foreach ($regex as $file) {
            require_once $file[0];

            $drivers[] = basename($file[0], '.php');
        }

        return $drivers;
    }
440325
private function getKeyValueFromConsul(string $kvPath): string
    {
        return $this->kv->get($kvPath, ['raw' => true])->getBody();
    }
1134796
private static function explodePath($parts)
    {
        if (!is_array($parts)) {
            $parts = explode(self::$delimiter, $parts);
        }

        return $parts;
    }
677074
public function explode_path($path) {
		$path = preg_replace('/\/{2,}/', '/', $path);
		$path = $this->fix_path($path);
		$retval = explode('/', $path);
		
		//if the initial index is blank, just remove it.
		if($retval[0] == '' || strlen($retval[0]) < 1) {
			//it was blank!  KILL IT!
			$checkItOut = array_shift($retval);
		}
		
		return($retval);
	}
603177
protected function splitPath($path)
    {
        $chunks = array_map(
            [$this, 'unescape'],
            preg_split('#(?<!\\\)\/#', ltrim($path, '/'))
        );

        if (empty($chunks) || (array_filter($chunks) !== $chunks)) {
            throw new \InvalidArgumentException('Invalid path provided:' . $path);
        }

        return $chunks;
    }
745837
protected static function combinePaths(string ...$paths): string
    {
        $last_key = \count($paths) - 1;
        array_walk($paths, function (&$val, $key) use ($last_key) {
            switch ($key) {
                case 0:
                    $val = rtrim($val, '/ ');
                    break;
                case $last_key:
                    $val = ltrim($val, '/ ');
                    break;
                default:
                    $val = trim($val, '/ ');
                    break;
            }
        });

        $first = array_shift($paths);
        $last = array_pop($paths);
        $paths = array_filter($paths);
        array_unshift($paths, $first);
        $paths[] = $last;

        return implode('/', $paths);
    }
1231336
public static function parsePath($path)
    {
        $lastDsPos = strripos($path, DIRECTORY_SEPARATOR);
        if ($lastDsPos == false) {
            $controller = $action = "";
        } else {
            $controllerPath = substr($path, 1, $lastDsPos - 1);
            $actionPath = substr($path, $lastDsPos + 1);

            $controller = self::formatController($controllerPath);
            $action = self::formatAction($actionPath);
        }

        return array($controller, $action);
    }
217227
public function removeNode( $nodePath )
	{
		$pathNodes	= explode( "/", $nodePath );
		$nodeName	= array_pop( $pathNodes );
		$nodePath	= implode( "/", $pathNodes );
		$nodeNumber	= 0;
		$branch		= $this->getNode( $nodePath );
		if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $nodeName, $matches ) )
		{
			$nodeName	= $matches[1][0];
			$nodeNumber	= $matches[2][0];
		}
		$nodes		=& $branch->getChildren();
		$index		= -1;
		for( $i=0; $i<count( $nodes ); $i++ )
		{
			if( !$nodeName || $nodes[$i]->getNodeName() == $nodeName )
			{
				$index++;
				if( $index != $nodeNumber ) 
					continue;
				unset( $nodes[$i] );
				return (bool) $this->write();
			}
		}
		throw new InvalidArgumentException( 'Node not found.' );
	}
516087
public function getEntries($path)
    {
        $entries = $this->get($path);
        $result  = [];
        $prefix  = trim($path, '/');
        if (strlen($prefix)) {
            $prefix .= '/';
        }
        if (is_array($entries)) {
            foreach (array_keys($entries) as $key) {
                $result[] = $prefix . $this->escape($key);
            }
        }

        return $result;
    }