getFileName(); } //-------------------------------------------------------------------- /** * A recursive remove directory method. * * @param $dir */ protected static function removeDir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object !== '.' && $object !== '..') { if (filetype($dir . '/' . $object) === 'dir') { static::removeDir($dir . '/' . $object); } else { unlink($dir . '/' . $object); } } } reset($objects); rmdir($dir); } } protected static function copyDir($source, $dest) { $dir = opendir($source); @mkdir($dest); while (false !== ( $file = readdir($dir))) { if (( $file !== '.' ) && ( $file !== '..' )) { if (is_dir($source . '/' . $file)) { static::copyDir($source . '/' . $file, $dest . '/' . $file); } else { copy($source . '/' . $file, $dest . '/' . $file); } } } closedir($dir); } /** * Moves the Laminas Escaper files into our base repo so that it's * available for packaged releases where the users don't user Composer. * * @throws \ReflectionException */ public static function moveEscaper() { if (class_exists('\\Laminas\\Escaper\\Escaper') && is_file(static::getClassFilePath('\\Laminas\\Escaper\\Escaper'))) { $base = basename(__DIR__) . '/' . static::$basePath . 'Escaper'; foreach ([$base, $base . '/Exception'] as $path) { if (! is_dir($path)) { mkdir($path, 0755); } } $files = [ static::getClassFilePath('\\Laminas\\Escaper\\Exception\\ExceptionInterface') => $base . '/Exception/ExceptionInterface.php', static::getClassFilePath('\\Laminas\\Escaper\\Exception\\InvalidArgumentException') => $base . '/Exception/InvalidArgumentException.php', static::getClassFilePath('\\Laminas\\Escaper\\Exception\\RuntimeException') => $base . '/Exception/RuntimeException.php', static::getClassFilePath('\\Laminas\\Escaper\\Escaper') => $base . '/Escaper.php', ]; foreach ($files as $source => $dest) { if (! static::moveFile($source, $dest)) { // @codeCoverageIgnoreStart die('Error moving: ' . $source); // @codeCoverageIgnoreEnd } } } } //-------------------------------------------------------------------- /** * Moves the Kint file into our base repo so that it's * available for packaged releases where the users don't user Composer. */ public static function moveKint() { $dir = 'vendor/kint-php/kint/src'; if (is_dir($dir)) { $base = basename(__DIR__) . '/' . static::$basePath . 'Kint'; // Remove the contents of the previous Kint folder, if any. if (is_dir($base)) { static::removeDir($base); } // Create Kint if it doesn't exist already if (! is_dir($base)) { mkdir($base, 0755); } static::copyDir($dir, $base); static::copyDir($dir . '/../resources', $base . '/resources'); copy($dir . '/../init.php', $base . '/init.php'); copy($dir . '/../init_helpers.php', $base . '/init_helpers.php'); } } }