UriSequence.php
function normalize()
    {
        $normalized = array();
        $paths      = $this->getPath();

        if (empty($paths))
            return $normalized;

        // Replace "~" with user's home directory.
        if ('~' === $paths[0]) {
            $home  = explode($this->getSeparator(), str_replace('\\', '/', $this->_getHomeDir()));
            $paths = $paths + $home;
        }

        $isRoot = $this->_isRoot($paths[0]);
        $paths  = array_filter($paths, function($p, $i) use (&$isRoot, $paths) {
            if ( ($isRoot && $i > 0) || $i+1 == count($paths) /* keep last slash remain */) {
                // keep last slash /go/to/path/
                // keep first slash after root if exists
                //   phar://path/to/res
                $isRoot = false;
                return true;
            }

            // Remove all ['',] from path
            // on appended path we don't want any absolute sign in
            // array list
            return ($p !== '' && $p !== '.');
        }, ARRAY_FILTER_USE_BOTH);

        // Collapse ".." with the previous part, if one exists
        // Don't collapse ".." if the previous part is also ".."
        foreach ($paths as $path) {
            if (   '..' === $path && count($normalized) > 0      // keep first segment
                && '..' !== $normalized[count($normalized) - 1]
            ) {
                if (! $this->_isRoot($normalized[count($normalized) - 1]) )
                    array_pop($normalized);

                continue;
            }

            $normalized[] = $path;
        }

        $this->setPath($normalized);
        return $this;
    }
function normalize()
    {
        $normalized = array();
        $paths      = $this->getPath();

        if (empty($paths))
            return $normalized;

        // Replace "~" with user's home directory.
        if ('~' === $paths[0]) {
            $home  = explode($this->getSeparator(), str_replace('\\', '/', $this->_getHomeDir()));
            $paths = $paths + $home;
        }

        $isRoot = $this->_isRoot($paths[0]);
        $paths  = array_filter($paths, function($p, $i) use (&$isRoot, $paths) {
            if ( ($isRoot && $i > 0) || $i+1 == count($paths) /* keep last slash remain */) {
                // keep last slash /go/to/path/
                // keep first slash after root if exists
                //   phar://path/to/res
                $isRoot = false;
                return true;
            }

            // Remove all ['',] from path
            // on appended path we don't want any absolute sign in
            // array list
            return ($p !== '' && $p !== '.');
        }, ARRAY_FILTER_USE_BOTH);

        // Collapse ".." with the previous part, if one exists
        // Don't collapse ".." if the previous part is also ".."
        foreach ($paths as $path) {
            if (   '..' === $path && count($normalized) > 0      // keep first segment
                && '..' !== $normalized[count($normalized) - 1]
            ) {
                if (! $this->_isRoot($normalized[count($normalized) - 1]) )
                    array_pop($normalized);

                continue;
            }

            $normalized[] = $path;
        }

        $this->setPath($normalized);
        return $this;
    }
function normalize ( ) { $ normalized = array ( ) ; $ paths = $ this -> getPath ( ) ; if ( empty ( $ paths ) ) return $ normalized ; // Replace "~" with user's home directory. if ( '~' === $ paths [ 0 ] ) { $ home = explode ( $ this -> getSeparator ( ) , str_replace ( '\\' , '/' , $ this -> _getHomeDir ( ) ) ) ; $ paths = $ paths + $ home ; } $ isRoot = $ this -> _isRoot ( $ paths [ 0 ] ) ; $ paths = array_filter ( $ paths , function ( $ p , $ i ) use ( & $ isRoot , $ paths ) { if ( ( $ isRoot && $ i > 0 ) || $ i + 1 == count ( $ paths ) /* keep last slash remain */ ) { // keep last slash /go/to/path/ // keep first slash after root if exists //   phar://path/to/res $ isRoot = false ; return true ; } // Remove all ['',] from path // on appended path we don't want any absolute sign in // array list return ( $ p !== '' && $ p !== '.' ) ; } , ARRAY_FILTER_USE_BOTH ) ; // Collapse ".." with the previous part, if one exists // Don't collapse ".." if the previous part is also ".." foreach ( $ paths as $ path ) { if ( '..' === $ path && count ( $ normalized ) > 0 // keep first segment && '..' !== $ normalized [ count ( $ normalized ) - 1 ] ) { if ( ! $ this -> _isRoot ( $ normalized [ count ( $ normalized ) - 1 ] ) ) array_pop ( $ normalized ) ; continue ; } $ normalized [ ] = $ path ; } $ this -> setPath ( $ normalized ) ; return $ this ; }
Normalize Array Path Stored On Class

@return $this
Normalize Array Path Stored On Class