original_string: 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);
                  }
              }
          }
      }
code: 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);
                  }
              }
          }
      }
code_tokens: 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 ) ; } } } }
docstring: Removes all files in cache that do not occur in the given FileSet Collection.
  
  @param Collection $collection
  
  @return void
docstring_tokens: Removes all files in cache that do not occur in the given FileSet Collection .