Resolving sourced file './path/to/file' or '../path/to/file'

@param  string $file
@param  string $path
@return string
@access protected
964483
protected function expandPath(
        /*# string */ $file,
        /*# string */ $path
    )/*# : string */ {
        // relative path found
        if (false !== strpos($file, './')) {
            // remember working dir
            $old = getcwd();

            // change to current file's directory
            chdir(dirname(realpath($path)));

            // expand file path
            $file = realpath($file);

            // back to working dir
            chdir($old);
        }

        return $file;
    }
1233068
public function resolvePath($path)
    {
        $path = Yii::getAlias($path);

        $pi = pathinfo($this->owner->{$this->attribute});
        $fileName = ArrayHelper::getValue($pi, 'filename');
        $extension = strtolower(ArrayHelper::getValue($pi, 'extension'));

        return preg_replace_callback('|\[\[([\w\_/]+)\]\]|', function ($matches) use ($fileName, $extension) {
            $name = $matches[1];
            switch ($name) {
                case 'extension':
                    return $extension;
                case 'filename':
                    return $fileName;
                case 'basename':
                    return implode('.', array_filter([$fileName, $extension]));
                case 'app_root':
                    return Yii::getAlias('@app');
                case 'web_root':
                    return Yii::getAlias('@webroot');
                case 'base_url':
                    return Yii::getAlias('@web');
                case 'model':
                    $r = new \ReflectionClass($this->owner->className());
                    return lcfirst($r->getShortName());
                case 'attribute':
                    return lcfirst($this->attribute);
                case 'id':
                case 'pk':
                    $pk = implode('_', $this->owner->getPrimaryKey(true));
                    return lcfirst($pk);
                case 'id_path':
                    return static::makeIdPath($this->owner->getPrimaryKey());
                case 'parent_id':
                    return $this->owner->{$this->parentRelationAttribute};
            }
            if (preg_match('|^attribute_(\w+)$|', $name, $am)) {
                $attribute = $am[1];
                return $this->owner->{$attribute};
            }
            if (preg_match('|^md5_attribute_(\w+)$|', $name, $am)) {
                $attribute = $am[1];
                return md5($this->owner->{$attribute});
            }
            return '[[' . $name . ']]';
        }, $path);
    }
186997
public static function DeleteFilesFromPath($file)
	{
		$files = self::RetrieveFilesFromFolder($file->PathSuggested(),null);
		foreach ($files as $f)
		{
			if (strpos($f,$file->Extension())!== false)
			{
				self::DeleteFileString($f);
			}
		}
	}
753043
private function resolveFilePath($path)
    {
        $path = str_replace(array($this->_protocol.'://', '/'), array('', DIRECTORY_SEPARATOR), $path);

        foreach ($this->_includeExtensions as $ext) {
            $filename = $path.$ext;
            File::resolveFilepath($filename, null, array('include_path' => $this->_classcontentdir));
            if (true === is_file($filename)) {
                return $filename;
            }
        }

        return $path;
    }
1017421
public static function getFile( $file ) {
		$file = Storage::getFile( Route::DOCUMENT_ROOT() . 'app/config/' . $file . '.json' );
		$out  = Parser::json( $file );

		return $out;
	}
790655
private static function cadenaoriginal_path($file = '')
    {
        if (null !== static::$default_xslt_directory) {
            $directory = static::$default_xslt_directory;
        }
        else {
            $directory = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'xslt33';
            if (!file_exists($directory)) mkdir($directory, 0775, true);
        }

        return $directory . ($file ? '/' . $file : '');
    }
357428
public function shortPath($file)
    {
        $shortPath = str_replace(ROOT, null, $file);
        $shortPath = str_replace('..' . DIRECTORY_SEPARATOR, '', $shortPath);
        $shortPath = str_replace(DIRECTORY_SEPARATOR, '/', $shortPath);

        return str_replace('//', DIRECTORY_SEPARATOR, $shortPath);
    }
501152
public function fileGet($file)
    {
        if (($r = @file_get_contents($this->alias->resolve($file))) === false) {
            throw new FileNotFoundException($file);
        }

        return $r;
    }
503324
public function basePath($file = '')
    {
        $basePath = dirname($_SERVER['PHP_SELF']);
        if ($basePath != '/') {
            $basePath .= '/';
        }

        if (! empty($file)) {
            $basePath.= ltrim($file, '/');
        }

        return $basePath;
    }
819071
protected function getFilePath(string $path): string
    {
        if (empty($path)) {
            $path = $this->fileName;
        }

        return $path;
    }
108625
protected static function appendToPath($path, $file)
    {
        if (empty($file)) return $path;

        return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
    }
644719
public function file( $file = null )
	{
		if ( !is_null( $file ) )
		{
			return $this->_file = $file;
		}
		
		return $this->_file;
	}
940464
public static function pathInfo(String $file, String $info = 'basename') : String
    {
        $pathInfo = pathinfo($file);

        return $pathInfo[$info] ?? false;
    }
372359
public static function extension($file = false) {

        if ($file && self::isFile($file)) {

            return pathinfo($file, PATHINFO_EXTENSION);
        }

        return false;
    }
1318951
private function resolveFile(\DirectoryIterator $file, array &$files)
    {
        if ($file->isDir() && !$file->isDot()) {
            $files = Tools::resolvePath($files, $this->getFileNames());
        }

        if ($file->isFile() && !$file->isLink() && $file->isReadable()) {
            $files = Tools::resolvePath($files, $file->getRealPath());
        }
    }
615775
protected function getFilePath($file)
    {
        // if were passed an instance of UploadedFile, return the path
        if ($file instanceof UploadedFile) {
            return $file->getPathname();
        }

        // if we're passed a PHP file upload array, return the "tmp_name"
        if (is_array($file) && null !== array_get($file, 'tmp_name')) {
            return $file['tmp_name'];
        }

        // fallback: we were likely passed a path already
        return $file;
    }
384095
public function resolveLocalPath($path)
    {
        if (is_array($path)) {
            $paths  = array();
            foreach ($path as $p) {
                $paths[]    = $this->resolveLocalPath($p);
            }
            return $paths;
        } else {
            $path   = FileSystem::normalizeDirectorySeparator($path);
            if (strpos($path, $this->getRepositoryPath()) === 0) {
                $path  = substr($path, strlen($this->getRepositoryPath()));
            }
            return ltrim($path, '/');
        }
    }