resolving extension name by realpath
@param String $path
@return boolean
@throws \Exception
199252
protected function resolveExtensionName($path)
    {
        preg_match("/src(.*?)src/", dirname($path), $match);
        if (!isset($match[1])) {
            throw new \Exception('Unable to resolve valid module path');
        }
        $name = trim($match[1], DIRECTORY_SEPARATOR);
        if (!starts_with($name, ['components', 'modules'])) {
            return false;
        }
        return str_replace('\\', '/', $name);
    }
206615
public static function get($path)
    {
        $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
        if (!isset(self::$fileTypes[$ext])) {
            return false;
        }
        return self::$fileTypes[$ext];
    }
888988
public static function getFileExtention($path)
    {

        $ext = pathinfo($path, PATHINFO_EXTENSION);

        if($ext === ''){
            $splitedPath = explode('.', $path);
            $ext = end($splitedPath);
        }

        return $ext;
    }
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);
    }
774056
public static function resolve_path_with_dots($path) {

		if(!is_null($path) && is_string($path) && strlen($path)) {
			while(preg_match('/\/\//', $path)) {
				$path = preg_replace('/\/\//', '/', $path);
			}
			$retval = $path;
			if(preg_match('/\./', $path)) {

				$isAbsolute = FALSE;
				if(preg_match('/^\//', $path)) {
					$isAbsolute = TRUE;
					$path = preg_replace('/^\//', '', $path);
				}
				$pieces = explode('/', $path);

				$finalPieces = array();
				for($i=0; $i < count($pieces); $i++) {
					$dirName = $pieces[$i];
					if($dirName == '.') {
						//do nothing; don't bother appending.
					}
					elseif($dirName == '..') {
						array_pop($finalPieces);
					}
					else {
						$finalPieces[] = $dirName;
					}
				}

				//$retval = cs_global::string_from_array($finalPieces, NULL, '/');
				$retval = implode('/', $finalPieces);
				if($isAbsolute) {
					$retval = '/'. $retval;
				}
			}
		}
		else {
			throw new \InvalidArgumentException(__METHOD__ .": invalid path (". $path .")");
		}

		if(is_null($retval)) {
			throw new \LogicException(__METHOD__ .": returning NULL for path (". $path .")");
		}
		return($retval);
	}
1051680
protected static function getMountNameFromPath($path)
	{
		preg_match('/([[:alpha:]]*):\/\//', $path, $name);

		if (!isset($name[1]) || !$name[1])
		{
			throw new \Exception('Could not determine source mount type', 500);
		}

		return $name[1];
	}
298983
public function normalizePath($path)
	{
		$path = rtrim($path, '/\\').DIRECTORY_SEPARATOR;
		$path = realpath($path).DIRECTORY_SEPARATOR;

		if ($this->root and strpos($path, $this->root) !== 0)
		{
			throw new \Exception('Cannot access path outside: '.$this->root.'. Trying to access: '.$path);
		}

		return $path;
	}
825428
public function realpath($path)
    {
        $path = str_replace('/', DS, trim($path));
        if (strpos($path, '..') === false) {
            if (!Folder::isAbsolute($path)) {
                $path = Folder::addPathElement($this->path, $path);
            }

            return $path;
        }
        $parts = explode(DS, $path);
        $newparts = array();
        $newpath = '';
        if ($path[0] === DS) {
            $newpath = DS;
        }

        while (($part = array_shift($parts)) !== null) {
            if ($part === '.' || $part === '') {
                continue;
            }
            if ($part === '..') {
                if (!empty($newparts)) {
                    array_pop($newparts);
                    continue;
                }

                return false;
            }
            $newparts[] = $part;
        }
        $newpath .= implode(DS, $newparts);

        return Folder::slashTerm($newpath);
    }
1157023
public function getExtensionConfigurationFromPath($path)
    {
        $extensionConfiguration = $this->getExtensionConfiguration();

        return (ArrayUtility::isValidPath($extensionConfiguration, $path, '.'))
            ? ArrayUtility::getValueByPath($extensionConfiguration, $path, '.')
            : null;
    }
528968
private function guessAdapterExtension($path)
    {
        $path = strtolower(trim($path));
        foreach ($this->getStrategies() as $extension => $strategy) {
            if ($extension === substr($path, (strlen($extension) * -1))) {
                return $extension;
            }
        }

        return null;
    }
643314
public function supports($path)
    {
        return is_string($path)
            && is_file($absolute = $this->findAbsolutePath($path))
            && 'yml' === pathinfo($absolute, PATHINFO_EXTENSION);
    }
63973
public function getEngineFromPath($path)
    {
        $extension = $this->getExtension($path);

        $engine = $this->extensions[$extension];

        return $this->engines->resolve($engine);
    }
641409
protected function realPath($path)
    {
        if (php_sapi_name() == 'cli' && ! $path) {
            $path = $_SERVER['DOCUMENT_ROOT'];
        }

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

        return rtrim($path, '/\\');
    }
983339
public static function realPharPath($path)
    {
        if (strpos($path, 'phar:///') !== 0) {
            return;
        }
        
        $parts = explode('/', str_replace(array('/','\\'), '/', substr($path, 8)));
        $parts = array_values(array_filter($parts, array(__CLASS__, 'concatPharParts')));

        array_walk($parts, array(__CLASS__, 'resolvePharParentPath'), $parts);

        if (file_exists($realPath = 'phar:///' . implode('/', $parts))) {
            return $realPath;
        }
    }
47703
public static function detectByFilePath(string $path): string
    {
        $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));

        return empty($extension) ? 'text/plain' : static::detectByFileExtension($extension);
    }
904030
protected function realpath(string $path): string
    {
        if ($path === '') {
            return $this->baseDir;
        }

        if ($path[0] === '/' || (!empty($path[1]) && $path[1] === ':')) {
            return $path;
        }

        return $this->baseDir . '/' . $path;
    }
1300808
public function get_path($path)
	{
		$pathinfo = is_dir($path) ? array('dirname' => $path, 'extension' => null, 'basename' => '') : pathinfo($path);

		// make sure we have a dirname to work with
		isset($pathinfo['dirname']) or $pathinfo['dirname'] = '';

		// do we have a basedir, and is the path already prefixed by the basedir? then just deal with the double dots...
		if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) == $this->basedir)
		{
			$pathinfo['dirname'] = realpath($pathinfo['dirname']);
		}
		else
		{
			// attempt to get the realpath(), otherwise just use path with any double dots taken out when basedir is set (for security)
			$pathinfo['dirname'] = ( ! empty($this->basedir) ? realpath($this->basedir.DS.$pathinfo['dirname']) : realpath($pathinfo['dirname']) )
					?: ( ! empty($this->basedir) ? $this->basedir.DS.str_replace('..', '', $pathinfo['dirname']) : $pathinfo['dirname']);
		}

		// basedir prefix is required when it is set (may cause unexpected errors when realpath doesn't work)
		if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) != $this->basedir)
		{
			throw new \OutsideAreaException('File operation not allowed: given path is outside the basedir for this area.');
		}

		// check file extension
		if ( ! empty(static::$extensions) && array_key_exists($pathinfo['extension'], static::$extensions))
		{
			throw new \FileAccessException('File operation not allowed: disallowed file extension.');
		}

		return $pathinfo['dirname'].DS.$pathinfo['basename'];
	}