public function garbageCollect(Collection $collection)
    {
        $projectRoot = $collection->getProjectRoot();
        $filenames   = $collection->getFilenames();

        foreach ($filenames as &$name) {
            // the cache key contains a path relative to the project root; here we expect absolute paths.
            $name = self::FILE_PREFIX . md5(substr($name, strlen($projectRoot)));
        }

        /** @var IteratorInterface $iteratorInterface  */
        $iteratorInterface = $this->getCache()->getIterator();

        // FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
        if ($iteratorInterface->valid()) {
            foreach ($this->getCache() as $item) {
                if (substr($item, 0, strlen(self::FILE_PREFIX)) === self::FILE_PREFIX && !in_array($item, $filenames)) {
                    $this->getCache()->removeItem($item);
                }
            }
        }
    }