Resolves requires to the compass namespace (eg namespace/css3/border-radius)

@param string $file
@return string|FALSE
484474
public static function compassResolvePath($file)
	{
		if ($file{0}=='/') {
			return $file;
			}
		if (!$path=realpath($file)) {
			$path=\PHPSass\Script\ScriptFunction::$context->node->token->filename;
			$path=substr($path, 0, strrpos($path, '/')).'/';
			$path=$path.$file;
			$last='';
			while ($path!=$last) {
				$last=$path;
				$path=preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
				}
			$path=realpath($path);
			}
		if ($path) {
			return $path;
			}

		return FALSE;
	}
378687
protected function findMiddlewareFromFile($file)
    {
        $filename = pathinfo($file, PATHINFO_FILENAME);

        foreach ($this->middleware as $alias => $class) {
            if (strpos($class, $filename) !== false) {
                return $alias;
            }
        }
    }
701678
public function getBindingForFile( $file ) {
		$engine_key = $this->default;

		foreach ( $this->bindings as $suffix => $engine ) {
			if ( substr( $file, -strlen( $suffix ) ) === $suffix ) {
				$engine_key = $engine;
				break;
			}
		}

		return $engine_key;
	}
1111058
public function loadStyle($file = null)
    {
        // init required vars
        $content = '';

        // Get style file or get default
        if (is_null($file)) {
            $file = __DIR__.'/../public/github.css';
        }

        // check if style file exists
        if ($this->filesystem->exists($file)) {
            $content = $this->filesystem->get($file);
        }

        // Finally return style
        return "<style>{$content}</style>";
    }
384588
protected function loadFile($file)
    {
        if (class_exists('Symfony\Component\Config\Util\XmlUtils')) {
            $dom = XmlUtils::loadFile($file);
            $this->validate($dom);

            return $dom;
        }

        return parent::loadFile($file);
    }
88180
public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
982468
private function getClassByToken($file)
    {

        if (false === file_exists($file)) {
            throw new FileNotFoundException(sprintf("File %s is not readable or not exist", $file));
        }

        $fp = fopen($file, 'r');

        $class = $namespace = $buffer = '';
        $i     = 0;

        while (!$class) {

            if (feof($fp)) {
                break;
            }

            $buffer .= fread($fp, 512);
            $tokens = token_get_all($buffer);

            if (strpos($buffer, '{') === false) {
                continue;
            }

            list($namespace, $class) = $this->loopToken($i, $tokens, $namespace);
        }

        if ($namespace == '') {
            return $class;
        }

        return sprintf("%s\\%s", $namespace, $class);
    }
28052
protected static function fixPathForInput($file)
    {
        if (empty($file)) {
            throw new \InvalidArgumentException('fixPathForInput needs a valid $file, the given value was empty');
        }
        if (TYPO3_MODE === 'FE') {
            return GeneralUtility::getFileAbsFileName($file);
        }
        if (TYPO3_MODE === 'BE' && !self::isCliRequest()) {
            return GeneralUtility::resolveBackPath(PATH_typo3 . $file);
        }
        return $file;
    }
422204
private function getFullPath(string $file = null): string
	{
		return $this->getBasePath() . $this->path . ($file !== null ? DIRECTORY_SEPARATOR . $file : '');
	}
567288
public function locateFile($file)
    {
        $components = $this->parseResource($file);
        if ($components['path']) {
            $path = dirname($components['path']) . '/public/';

            return $path . $components['file'];
        } else {
            return $components['file'];
        }
    }
94102
public static function keyPath($file)
    {
        $file = ltrim($file, '/\\');

        return static::$keyPath
            ? rtrim(static::$keyPath, '/\\').DIRECTORY_SEPARATOR.$file
            : storage_path($file);
    }
94952
protected function resolveImportPath($file)
    {
        if (($path = realpath($file)) !== false) {
            return $path;
        } elseif (($path = realpath($file.'.blade.php')) !== false) {
            return $path;
        } elseif (($path = realpath(getcwd().'/vendor/'.$file.'/Envoy.blade.php')) !== false) {
            return $path;
        } elseif (($path = realpath(__DIR__.'/'.$file.'.blade.php')) !== false) {
            return $path;
        }

        return false;
    }
217807
public function getFilePath($file): string
    {
        if (null === ($fileObj = $this->container->get('huh.utils.file')->getFileFromUuid($file))) {
            return '';
        }

        return $fileObj->path;
    }
585391
private function convertFileToClass($path, $file, $prefix)
    {
        $candidates = array(
            // namespaced class
            $namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
            // namespaced class (with target dir)
            $prefix.$namespacedClass,
            // namespaced class (with target dir and separator)
            $prefix.'\\'.$namespacedClass,
            // PEAR class
            str_replace('\\', '_', $namespacedClass),
            // PEAR class (with target dir)
            str_replace('\\', '_', $prefix.$namespacedClass),
            // PEAR class (with target dir and separator)
            str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
        );

        if ($prefix) {
            $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
        }

        // We cannot use the autoloader here as most of them use require; but if the class
        // is not found, the new autoloader call will require the file again leading to a
        // "cannot redeclare class" error.
        foreach ($candidates as $candidate) {
            if ($this->classExists($candidate)) {
                return $candidate;
            }
        }

        require_once $file;

        foreach ($candidates as $candidate) {
            if ($this->classExists($candidate)) {
                return $candidate;
            }
        }
    }
1081875
public static function getClassNameFromFile($file)
    {
        $fp = fopen($file, 'r');

        $class = $namespace = $buffer = '';
        $i = 0;

        while (!$class) {
            if (feof($fp)) {
                break;
            }

            // Read entire lines to prevent keyword truncation
            for ($line = 0; $line <= 20; $line++) {
                $buffer .= fgets($fp);
            }
            $tokens = @token_get_all($buffer);

            if (strpos($buffer, '{') === false) {
                continue;
            }

            for (;$i < count($tokens);$i++) {
                if ($tokens[$i][0] === T_NAMESPACE) {
                    for ($j = $i + 1;$j < count($tokens); $j++) {
                        if ($tokens[$j][0] === T_STRING) {
                            $namespace .= '\\' . $tokens[$j][1];
                        } elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
                            break;
                        }
                    }
                }

                if ($tokens[$i][0] === T_CLASS) {
                    for ($j = $i + 1;$j < count($tokens);$j++) {
                        if ($tokens[$j] === '{') {
                            $class = $tokens[$i + 2][1];
                        }
                    }
                }
            }
        };

        if (!$class) {
            return;
        }

        return $namespace . '\\' . $class;
    }
350031
private function getManifestFileName($file)
    {
        if (!isset($this->metaCache[$file])) {
            $ds = DIRECTORY_SEPARATOR;
            $base = sha1_file($file) . '_'.basename($file) . '.manifest';
            $name = substr_replace(substr_replace($base, $ds, 4, 0), $ds, 2, 0);

            $this->metaCache[$file] = sprintf('%s%s%s', $this->manifest, $ds, $name);
        }

        return $this->metaCache[$file];
    }
72571
public function getNamespace($file, $defaultToPath = false)
    {
        // massage file path into a format compatible with PSR-4 entries
        $file = str_replace('\\', '/', $file);
        $base = str_replace('\\', '/', base_path()) . '/';
        $file = str_replace($base, '', $file);

        // compare file path against existing entries
        foreach($this->namespaces as $ns => $path)
        {
            // convert paths to all use forward slashes
            $path = str_replace('\\', '/', $path);

            // if the file starts with the namespace path
            if(strpos($file, $path) === 0)
            {
                $file   = substr($file, strlen($path));
                $file   = preg_replace('%/[^/]+$%', '', $file);
                $file   = str_replace('/', '\\', $file);

                // defensive trim, in case any double slashes
                return trim($ns . $file, '\\');
            }
        }

        // namespace could not be resolved
        $info = pathinfo($file);

        return $defaultToPath
            ? str_replace('/', '\\', $info['dirname'])
            : null;

    }