From 8a7e2a3c00ee53e6c3a2d5fb67296302f5c10cc0 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 7 Jun 2013 17:11:56 +0100 Subject: [PATCH] Unbind the filter Closure from ArchivableFilesFinder to allow the object to be garbage collected correctly, and the folder closed. Fixes https://github.com/composer/satis/issues/64 for PHP 5.4 --- .../Archiver/ArchivableFilesFinder.php | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Composer/Package/Archiver/ArchivableFilesFinder.php b/src/Composer/Package/Archiver/ArchivableFilesFinder.php index 343c82b65..451265b8b 100644 --- a/src/Composer/Package/Archiver/ArchivableFilesFinder.php +++ b/src/Composer/Package/Archiver/ArchivableFilesFinder.php @@ -52,21 +52,28 @@ class ArchivableFilesFinder extends \FilterIterator ); $this->finder = new Finder\Finder(); + + $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) { + $relativePath = preg_replace( + '#^'.preg_quote($sources, '#').'#', + '', + $fs->normalizePath($file->getRealPath()) + ); + + $exclude = false; + foreach ($filters as $filter) { + $exclude = $filter->filter($relativePath, $exclude); + } + return !$exclude; + }; + + if (method_exists($filter, 'bindTo')) { + $filter = $filter->bindTo(null); + } + $this->finder ->in($sources) - ->filter(function (\SplFileInfo $file) use ($sources, $filters, $fs) { - $relativePath = preg_replace( - '#^'.preg_quote($sources, '#').'#', - '', - $fs->normalizePath($file->getRealPath()) - ); - - $exclude = false; - foreach ($filters as $filter) { - $exclude = $filter->filter($relativePath, $exclude); - } - return !$exclude; - }) + ->filter($filter) ->ignoreVCS(true) ->ignoreDotFiles(false);