protected function realPath($path)
    {
        if (php_sapi_name() == 'cli' && ! $path) {
            $path = $_SERVER['DOCUMENT_ROOT'];
        }

        if ($realPath = realpath($path)) {
            $path = $realPath;
        }

        return rtrim($path, '/\\');
    }