Extract the class name from the file at the given path.

@param  string  $path
@return string|null
341299
public function findClass($path)
    {
        $namespace = null;
        $tokens = token_get_all(file_get_contents($path));
        foreach ($tokens as $key => $token) {
            if ($this->tokenIsNamespace($token)) {
                $namespace = $this->getNamespace($key + 2, $tokens);
            } elseif ($this->tokenIsClassOrInterface($token)) {
                return ltrim($namespace.'\\'.$this->getClass($key + 2, $tokens), '\\');
            }
        }
    }
48939
public function Path($Path = NULL) {
      if (is_string($Path)) {
         $Result = $this->_ParsedRequestElement('Path', $Path);
      } else {
         $Result = $this->_ParsedRequestElement('Path');
         if ($Path === TRUE) {
            // Encode the path.
            $Parts = explode('/', $Result);
            $Parts = array_map('urlencode', $Parts);
            $Result = implode('/', $Parts);
         }
      }
      
      return $Result;
   }
52079
private function detectFromPath($path)
    {
        if (!$this->usePath) {
            return null;
        }

        $first = \explode('/', \ltrim($path, '/'), 2)[0];
        $first = \strtolower($first);

        if (!empty($first) && \in_array($first, $this->languages, true)) {
            return $first;
        }

        return null;
    }
1059127
private function filterPath(?string $path): string
    {
        if (null === $path) {
            throw new SyntaxError('The path can not be null');
        }

        if ('' === $path || ',' === $path) {
            return 'text/plain;charset=us-ascii,';
        }

        if (1 === preg_match(self::REGEXP_DATAPATH, $path)) {
            $path = substr($path, 0, -1).'charset=us-ascii,';
        }

        if (1 === preg_match(self::REGEXP_NON_ASCII_PATTERN, $path) && false === strpos($path, ',')) {
            throw new SyntaxError(sprintf('The path `%s` is invalid according to RFC2937', $path));
        }

        return $path;
    }
1316318
static public function dirname($path)
    {
        if (substr($path, -1) == self::PATH_SEGMENT_SEPARATOR) return substr($path, 0, -1);
        else {
            $d = dirname($path);
            if ($d == DIRECTORY_SEPARATOR) $d = self::PATH_SEGMENT_SEPARATOR;
            return $d;
        }
    }
1041107
public function findMapping($path) {
        if (!strEndsWith($path, '/'))
            $path .= '/';
        // $path: /
        // $path: /action/
        // $path: /controller/action/
        // $path: /controller/action/parameter/

        $pattern = $path;
        while (strlen($pattern)) {
            if (isset($this->mappings['paths'][$pattern]))          // path keys start and end with a slash "/"
                return $this->mappings['paths'][$pattern];
            $pattern = strLeftTo($pattern, '/', $count=-2, $includeLimiter=true);
            if ($pattern == '/')
                break;
        }
        return null;
    }
501895
public function get($path)
    {
        $p = explode('.', $path);
        $cfg = &$this->config;
        $count = 1;

        foreach ($p as $part) {
            if (array_key_exists($part, $cfg)) {
                // see if it's the end
                if ($count == count($p)) {
                    echo 'end';
                    return $cfg[$part];
                }
                $cfg = &$cfg[$part];
            }
            $count++;
        }
        return null;
    }
653333
public static function getFileMimeByCmd($path)
    {
        if (empty($path) || ! is_file($path)) {
            return null;
        }
        
        $info = exec('file -ib "' . $path . '"');
        list ($type, $temp) = explode(';', $info);
        return $type;
    }
328116
public static function cleanPathname($path) {
		if (UString::isNotNull ( $path )) {
			if (\DS === "/")
				$path = \str_replace ( "\\", \DS, $path );
			else
				$path = \str_replace ( "/", \DS, $path );
			$path = \str_replace ( \DS . \DS, \DS, $path );
			if (! UString::endswith ( $path, \DS )) {
				$path = $path . \DS;
			}
		}
		return $path;
	}
1071699
private function getPath($path)
    {
        return $this->root .
            ltrim(
                preg_replace(
                    sprintf('|%s{2,}|', preg_quote(DIRECTORY_SEPARATOR)),
                    DIRECTORY_SEPARATOR,
                    $path
                ),
                DIRECTORY_SEPARATOR
            );
    }
389216
protected function cleanPathInternal($path)
    {
        if ($this->isVirtual($path)) {
            return $this->cleanPath($path);
        }

        if ($this->hasCDBack($path)) {
            $realpath = $this->cleanPath(realpath($path));
            return $realpath ?: null;
        }

        return $this->cleanPath($path);
    }
319335
protected function getValueForPath($path)
    {
        $data = $this->data;
        if (!$data) {
            return null;
        }

        $steps = $this->getPath($path);
        if (!$steps) {
            return null;
        }

        if (\is_array($steps)) {
            if (1 === \count($steps)) {
                return $this->getValue(current($steps), $data);
            }

            $value = [];
            foreach ($steps as $step) {
                $value[] = $this->getValue($step, $data);
            }

            return trim(implode(' ', $value)) ?: null;
        }

        return $this->getValue($steps, $data);
    }
787325
public function getPath(string $path = ''): string
    {
        return $this->dirPath.($path ? DIRECTORY_SEPARATOR.$path : $path);
    }
497021
public static function getType($path)
    {
        if (!is_file($path)) {
            throw new \InvalidArgumentException(sprintf('invalid filename or path "%s"', $path));
        }

        $info = (new \finfo(FILEINFO_MIME))->file($path);

        return substr($info, 0, strpos($info, ';'));
    }
556400
public static function cleanFilePathname($path) {
		if (UString::isNotNull ( $path )) {
			if (\DS === "/")
				$path = \str_replace ( "\\", \DS, $path );
			else
				$path = \str_replace ( "/", \DS, $path );
			$path = \str_replace ( \DS . \DS, \DS, $path );
		}
		return $path;
	}
113749
public function extractWebspaceFromPath($path)
    {
        $match = preg_match('/^\/' . $this->getPath('base') . '\/([^\/]*)\/.*$/', $path, $matches);

        if ($match) {
            return $matches[1];
        } else {
            return;
        }
    }
554953
protected function _findPath($path)
    {
        $path = $this->_unifyPath($path);
        $dirs = $this->_dirs;

        $file = null;

        foreach ($dirs as $dir) {
            if (is_readable(realpath($dir.DS.$path))) {
                $file = $dir.DS.$path;
                break;
            }
        }

        return $file;
    }