fix for php-5.5
authorMichael Wallner <mike@php.net>
Sat, 28 Mar 2015 07:11:10 +0000 (08:11 +0100)
committerMichael Wallner <mike@php.net>
Sat, 28 Mar 2015 07:11:10 +0000 (08:11 +0100)
src/pharext/Task/Cleanup.php

index 1263bd966e33f0399dac123c2d9e6a401996ed15..c2cfefa8b768019dcc1c55202812e89460b99c72 100644 (file)
@@ -26,14 +26,17 @@ class Cleanup implements Task
         * @param bool $verbose
         */
        public function run($verbose = false) {
-               if (is_dir($this->rm)) {
+               if ($this->rm instanceof Tempfile) {
+                       unset($this->rm);
+               } elseif (is_dir($this->rm)) {
                        $rdi = new RecursiveDirectoryIterator($this->rm,
-                               FilesystemIterator::CURRENT_AS_PATHNAME |
+                               FilesystemIterator::CURRENT_AS_SELF | // needed for 5.5
+                               FilesystemIterator::KEY_AS_PATHNAME |
                                FilesystemIterator::SKIP_DOTS);
                        $rii = new RecursiveIteratorIterator($rdi,
                                RecursiveIteratorIterator::CHILD_FIRST);
-                       foreach ($rii as $path) {
-                               if ($rii->isDir()) {
+                       foreach ($rii as $path => $child) {
+                               if ($child->isDir()) {
                                        rmdir($path);
                                } else {
                                        unlink($path);