src/Helpers/FileSystem.php
public static function canonical($path)
    {
        $path = self::split($path);
        $canon = [];
        foreach ($path as $segment) {
            if ($segment === '..') {
                array_pop($canon);
            } elseif ($segment !== '.') {
                $canon[] = $segment;
            }
        }

        if ($canon[count($canon) - 1] === '') {
            array_pop($canon);
        }

        return self::join($canon);
    }
public static function canonical($path)
    {
        $path = self::split($path);
        $canon = [];
        foreach ($path as $segment) {
            if ($segment === '..') {
                array_pop($canon);
            } elseif ($segment !== '.') {
                $canon[] = $segment;
            }
        }

        if ($canon[count($canon) - 1] === '') {
            array_pop($canon);
        }

        return self::join($canon);
    }
public static function canonical ( $ path ) { $ path = self :: split ( $ path ) ; $ canon = [ ] ; foreach ( $ path as $ segment ) { if ( $ segment === '..' ) { array_pop ( $ canon ) ; } elseif ( $ segment !== '.' ) { $ canon [ ] = $ segment ; } } if ( $ canon [ count ( $ canon ) - 1 ] === '' ) { array_pop ( $ canon ) ; } return self :: join ( $ canon ) ; }
Canonicalizes the file system path. Always remove slash from the end.

@param string $path The path to canoncalize.

@return string The canoncalized path.
Canonicalizes the file system path . Always remove slash from the end .