public function getTemplateNamesForFilename($filename)
    {
        $map = $this->getMap();
        $matching = array_filter(array_keys($map), function ($path) use ($filename) {
            return $filename[0] === $path[0] && 0 === strpos($filename, $path);
        });

        $templateNames = [];
        foreach ($matching as $match) {
            $namespace = $map[$match];
            $templateNames[] = self::MAIN_NAMESPACE === $namespace
                ? ltrim(substr($filename, strlen($match)), '/\\')
                : '@'.$namespace.substr($filename, strlen($match));
        }

        return $templateNames;
    }