From 713c1e8da792301657acb08a3b3e57f2861dc266 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 5 Aug 2023 02:36:11 +0000 Subject: [PATCH] chore(deps): Bump deepdiver1975/tarstreamer from 2.0.0 to 2.1.0 Bumps [deepdiver1975/tarstreamer](https://github.com/owncloud/TarStreamer) from 2.0.0 to 2.1.0. - [Release notes](https://github.com/owncloud/TarStreamer/releases) - [Commits](https://github.com/owncloud/TarStreamer/compare/2.0.0...v2.1.0) --- updated-dependencies: - dependency-name: deepdiver1975/tarstreamer dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .gitignore | 6 ++ composer.json | 2 +- composer.lock | 26 +++-- composer/ClassLoader.php | 96 +++++++++---------- composer/installed.json | 26 +++-- composer/installed.php | 18 ++-- deepdiver1975/tarstreamer/src/TarHeader.php | 52 +++++----- deepdiver1975/tarstreamer/src/TarStreamer.php | 76 +++++++-------- 8 files changed, 159 insertions(+), 143 deletions(-) diff --git a/.gitignore b/.gitignore index 5770c8a67..91c39fd4e 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,12 @@ brick/math/psalm*.xmls deepdiver/zipstreamer/test +deepdiver1975/tarstreamer/.drone.star +deepdiver1975/tarstreamer/.phan +deepdiver1975/tarstreamer/.php-cs-fixer.dist.php +deepdiver1975/tarstreamer/Makefile +deepdiver1975/tarstreamer/vendor-bin + doctrine/dbal/.doctrine-project.json doctrine/dbal/.gitmodules doctrine/dbal/build.* diff --git a/composer.json b/composer.json index 8ff208a50..adcc18fcc 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "christophwurst/id3parser": "^0.1.4", "cweagans/composer-patches": "^1.7", "deepdiver/zipstreamer": "2.0.0", - "deepdiver1975/tarstreamer": "v2.0.0", + "deepdiver1975/tarstreamer": "v2.1.0", "doctrine/dbal": "3.3.8", "egulias/email-validator": "^3.2.5", "fusonic/opengraph": "^2.2", diff --git a/composer.lock b/composer.lock index abdc24a23..bde00c5d5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "da1054812d0d125957e0611f6927eb1a", + "content-hash": "c5b0f8b9a3f9e9dc500bcf3aeb52dcb7", "packages": [ { "name": "aws/aws-crt-php", @@ -462,27 +462,33 @@ }, { "name": "deepdiver1975/tarstreamer", - "version": "2.0.0", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/owncloud/TarStreamer.git", - "reference": "ad48505d1ab54a8e94e6b1cc5297bbed72e956de" + "reference": "163052d7a076fd3dd54d4f50e1ff2705b72604db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/owncloud/TarStreamer/zipball/ad48505d1ab54a8e94e6b1cc5297bbed72e956de", - "reference": "ad48505d1ab54a8e94e6b1cc5297bbed72e956de", + "url": "https://api.github.com/repos/owncloud/TarStreamer/zipball/163052d7a076fd3dd54d4f50e1ff2705b72604db", + "reference": "163052d7a076fd3dd54d4f50e1ff2705b72604db", "shasum": "" }, "require": { "php": ">=7.1" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.5", "pear/archive_tar": "~1.4", - "pear/pear-core-minimal": "v1.10.10", - "phpunit/phpunit": "^7.5" + "pear/pear-core-minimal": "v1.10.13", + "phpunit/phpunit": "^7.5|^8.5|^9.6" }, "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": false + } + }, "autoload": { "psr-4": { "ownCloud\\TarStreamer\\": "src/" @@ -500,7 +506,11 @@ "stream", "tar" ], - "time": "2020-01-08T09:55:35+00:00" + "support": { + "issues": "https://github.com/owncloud/TarStreamer/issues", + "source": "https://github.com/owncloud/TarStreamer/tree/v2.1.0" + }, + "time": "2023-06-16T08:01:55+00:00" }, { "name": "doctrine/cache", diff --git a/composer/ClassLoader.php b/composer/ClassLoader.php index a72151c77..7824d8f7e 100644 --- a/composer/ClassLoader.php +++ b/composer/ClassLoader.php @@ -45,35 +45,34 @@ class ClassLoader /** @var \Closure(string):void */ private static $includeFile; - /** @var ?string */ + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -81,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -90,21 +88,20 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { @@ -113,7 +110,7 @@ public function __construct($vendorDir = null) } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -125,8 +122,7 @@ public function getPrefixes() } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -134,8 +130,7 @@ public function getPrefixesPsr4() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -143,8 +138,7 @@ public function getFallbackDirs() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -152,8 +146,7 @@ public function getFallbackDirsPsr4() } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -161,8 +154,7 @@ public function getClassMap() } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -179,24 +171,25 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -205,19 +198,19 @@ public function add($prefix, $paths, $prepend = false) $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -226,9 +219,9 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -236,17 +229,18 @@ public function add($prefix, $paths, $prepend = false) */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -256,18 +250,18 @@ public function addPsr4($prefix, $paths, $prepend = false) throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -276,8 +270,8 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -294,8 +288,8 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -481,9 +475,9 @@ public function findFile($class) } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { diff --git a/composer/installed.json b/composer/installed.json index a2dd67123..85695e7fb 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -480,29 +480,35 @@ }, { "name": "deepdiver1975/tarstreamer", - "version": "2.0.0", - "version_normalized": "2.0.0.0", + "version": "v2.1.0", + "version_normalized": "2.1.0.0", "source": { "type": "git", "url": "https://github.com/owncloud/TarStreamer.git", - "reference": "ad48505d1ab54a8e94e6b1cc5297bbed72e956de" + "reference": "163052d7a076fd3dd54d4f50e1ff2705b72604db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/owncloud/TarStreamer/zipball/ad48505d1ab54a8e94e6b1cc5297bbed72e956de", - "reference": "ad48505d1ab54a8e94e6b1cc5297bbed72e956de", + "url": "https://api.github.com/repos/owncloud/TarStreamer/zipball/163052d7a076fd3dd54d4f50e1ff2705b72604db", + "reference": "163052d7a076fd3dd54d4f50e1ff2705b72604db", "shasum": "" }, "require": { "php": ">=7.1" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.5", "pear/archive_tar": "~1.4", - "pear/pear-core-minimal": "v1.10.10", - "phpunit/phpunit": "^7.5" + "pear/pear-core-minimal": "v1.10.13", + "phpunit/phpunit": "^7.5|^8.5|^9.6" }, - "time": "2020-01-08T09:55:35+00:00", + "time": "2023-06-16T08:01:55+00:00", "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": false + } + }, "installation-source": "dist", "autoload": { "psr-4": { @@ -521,6 +527,10 @@ "stream", "tar" ], + "support": { + "issues": "https://github.com/owncloud/TarStreamer/issues", + "source": "https://github.com/owncloud/TarStreamer/tree/v2.1.0" + }, "install-path": "../deepdiver1975/tarstreamer" }, { diff --git a/composer/installed.php b/composer/installed.php index e9f1fc4b8..ec141032f 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'nextcloud/3rdparty', - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '6c36449d6cea0a8b5eec3a3c7d1b40a137b689b7', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -83,9 +83,9 @@ 'dev_requirement' => false, ), 'deepdiver1975/tarstreamer' => array( - 'pretty_version' => '2.0.0', - 'version' => '2.0.0.0', - 'reference' => 'ad48505d1ab54a8e94e6b1cc5297bbed72e956de', + 'pretty_version' => 'v2.1.0', + 'version' => '2.1.0.0', + 'reference' => '163052d7a076fd3dd54d4f50e1ff2705b72604db', 'type' => 'library', 'install_path' => __DIR__ . '/../deepdiver1975/tarstreamer', 'aliases' => array(), @@ -326,9 +326,9 @@ 'dev_requirement' => false, ), 'nextcloud/3rdparty' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '6c36449d6cea0a8b5eec3a3c7d1b40a137b689b7', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), diff --git a/deepdiver1975/tarstreamer/src/TarHeader.php b/deepdiver1975/tarstreamer/src/TarHeader.php index ad6999b66..b8ff15da6 100644 --- a/deepdiver1975/tarstreamer/src/TarHeader.php +++ b/deepdiver1975/tarstreamer/src/TarHeader.php @@ -14,9 +14,7 @@ class TarHeader { private $size; private $mtime = ''; - - private $checksum; - + private $typeflag; private $linkname = ''; @@ -37,39 +35,39 @@ class TarHeader { private $reserved = ''; - public function setName($name){ + public function setName($name) { $this->name = $name; return $this; } - public function setSize($size){ + public function setSize($size) { $this->size = $size; return $this; } - public function setMtime($mtime){ + public function setMtime($mtime) { $this->mtime = $mtime; return $this; } - public function setTypeflag($typeflag){ + public function setTypeflag($typeflag) { $this->typeflag = $typeflag; return $this; } - public function setPrefix($prefix){ + public function setPrefix($prefix) { $this->prefix = $prefix; return $this; } - public function getHeader(){ + public function getHeader() { $fields = [ ['a100', substr($this->name, 0, 100)], ['a8', str_pad($this->mode, 7, '0', STR_PAD_LEFT)], - ['a8', decoct(str_pad($this->uid, 7, '0', STR_PAD_LEFT))], - ['a8', decoct(str_pad($this->gid, 7, '0', STR_PAD_LEFT))], - ['a12', str_pad(decoct($this->size), 11, '0', STR_PAD_LEFT)], - ['a12', str_pad(decoct($this->mtime), 11, '0', STR_PAD_LEFT)], + ['a8', decoct((int) str_pad($this->uid, 7, '0', STR_PAD_LEFT))], + ['a8', decoct((int) str_pad($this->gid, 7, '0', STR_PAD_LEFT))], + ['a12', str_pad(decoct((int)$this->size), 11, '0', STR_PAD_LEFT)], + ['a12', str_pad(decoct((int)$this->mtime), 11, '0', STR_PAD_LEFT)], // We calculate checksum later ['a8', ''], ['a1', $this->typeflag], @@ -89,11 +87,11 @@ public function getHeader(){ // Compute header checksum $checksum = str_pad(decoct($this->computeUnsignedChecksum($header)), 6, "0", STR_PAD_LEFT); - for ($i = 0; $i < 6; $i++){ + for ($i = 0; $i < 6; $i++) { $header[(148 + $i)] = substr($checksum, $i, 1); } - $header[154] = chr(0); - $header[155] = chr(32); + $header[154] = \chr(0); + $header[155] = \chr(32); return $header; } @@ -104,11 +102,11 @@ public function getHeader(){ * @param array $fields key being the format string and value being the data to pack * @return string binary packed data returned from pack() */ - protected function packFields($fields){ - list ($fmt, $args) = ['', []]; + protected function packFields($fields) { + list($fmt, $args) = ['', []]; // populate format string and argument list - foreach ($fields as $field){ + foreach ($fields as $field) { $fmt .= $field[0]; $args[] = $field[1]; } @@ -117,24 +115,24 @@ protected function packFields($fields){ array_unshift($args, $fmt); // build output string from header and compressed data - return call_user_func_array('pack', $args); + return \call_user_func_array('pack', $args); } /** * Generate unsigned checksum of header * * @param string $header - * @return string unsigned checksum + * @return float|int unsigned checksum */ - protected function computeUnsignedChecksum($header){ + protected function computeUnsignedChecksum($header) { $unsignedChecksum = 0; - for ($i = 0; $i < 512; $i++){ - $unsignedChecksum += ord($header[$i]); + for ($i = 0; $i < 512; $i++) { + $unsignedChecksum += \ord($header[$i]); } - for ($i = 0; $i < 8; $i++){ - $unsignedChecksum -= ord($header[148 + $i]); + for ($i = 0; $i < 8; $i++) { + $unsignedChecksum -= \ord($header[148 + $i]); } - $unsignedChecksum += ord(" ") * 8; + $unsignedChecksum += \ord(" ") * 8; return $unsignedChecksum; } diff --git a/deepdiver1975/tarstreamer/src/TarStreamer.php b/deepdiver1975/tarstreamer/src/TarStreamer.php index 5ee76756a..8bbf54a34 100644 --- a/deepdiver1975/tarstreamer/src/TarStreamer.php +++ b/deepdiver1975/tarstreamer/src/TarStreamer.php @@ -5,11 +5,10 @@ use ownCloud\TarStreamer\TarHeader; class TarStreamer { - - const REGTYPE = 0; - const DIRTYPE = 5; - const XHDTYPE = 'x'; - const LONGNAMETYPE = 'L'; + public const REGTYPE = 0; + public const DIRTYPE = 5; + public const XHDTYPE = 'x'; + public const LONGNAMETYPE = 'L'; /** * Process in 1 MB chunks @@ -24,13 +23,13 @@ class TarStreamer { * * @param array $options */ - public function __construct($options = []){ - if (isset($options['outstream'])){ + public function __construct($options = []) { + if (isset($options['outstream'])) { $this->outStream = $options['outstream']; } else { $this->outStream = fopen('php://output', 'w'); // turn off output buffering - while (ob_get_level() > 0){ + while (ob_get_level() > 0) { ob_end_flush(); } } @@ -49,13 +48,13 @@ public function __construct($options = []){ * @param string $contentType Content mime type to be set (optional, default 'application/x-tar') * @throws \Exception */ - public function sendHeaders($archiveName = 'archive.tar', $contentType = 'application/x-tar'){ + public function sendHeaders($archiveName = 'archive.tar', $contentType = 'application/x-tar') { $encodedArchiveName = rawurlencode($archiveName); - if (headers_sent($headerFile, $headerLine)){ + if (headers_sent($headerFile, $headerLine)) { throw new \Exception("Unable to send file $encodedArchiveName. HTML Headers have already been sent from $headerFile in line $headerLine"); } $buffer = ob_get_contents(); - if (!empty($buffer)){ + if (!empty($buffer)) { throw new \Exception("Unable to send file $encodedArchiveName. Output buffer already contains text (typically warnings or errors)."); } @@ -71,14 +70,14 @@ public function sendHeaders($archiveName = 'archive.tar', $contentType = 'applic ]; // Use UTF-8 filenames when not using Internet Explorer - if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') > 0) { + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') > 0) { header('Content-Disposition: attachment; filename="' . rawurlencode($archiveName) . '"'); - } else { + } else { header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($archiveName) . '; filename="' . rawurlencode($archiveName) . '"'); } - foreach ($headers as $key => $value){ + foreach ($headers as $key => $value) { header("$key: $value"); } } @@ -94,15 +93,15 @@ public function sendHeaders($archiveName = 'archive.tar', $contentType = 'applic * * int timestamp: timestamp for the file (default: current time) * @return bool $success */ - public function addFileFromStream($stream, $filePath, $size, $options = []){ - if (!is_resource($stream) || get_resource_type($stream) != 'stream'){ + public function addFileFromStream($stream, $filePath, $size, $options = []) { + if (!\is_resource($stream) || get_resource_type($stream) != 'stream') { return false; } $this->initFileStreamTransfer($filePath, self::REGTYPE, $size, $options); // send file blocks - while ($data = fread($stream, $this->blockSize)){ + while ($data = fread($stream, $this->blockSize)) { // send data $this->streamFilePart($data); } @@ -117,12 +116,12 @@ public function addFileFromStream($stream, $filePath, $size, $options = []){ * Explicitly adds a directory to the tar (necessary for empty directories) * * @param string $name Name (path) of the directory - * @param array $opt Additional options to set + * @param array $opt Additional options to set * Valid options are: * * int timestamp: timestamp for the file (default: current time) * @return void */ - public function addEmptyDir($name, $opt = []){ + public function addEmptyDir($name, $opt = []) { $opt['type'] = self::DIRTYPE; // send header @@ -137,7 +136,7 @@ public function addEmptyDir($name, $opt = []){ * A closed archive can no longer have new files added to it. After * closing, the file is completely written to the output stream. * @return bool $success */ - public function finalize(){ + public function finalize() { // tar requires the end of the file have two 512 byte null blocks $this->send(pack('a1024', '')); @@ -150,19 +149,18 @@ public function finalize(){ * Initialize a file stream * * @param string $name file path or just name - * @param int $type type of the item + * @param int|string $type type of the item * @param int $size size in bytes of the file * @param array $opt array (optional) * Valid options are: * * int timestamp: timestamp for the file (default: current time) */ - protected function initFileStreamTransfer($name, $type, $size, $opt = []){ - $dirName = (dirname($name) == '.') ? '' : dirname($name); + protected function initFileStreamTransfer($name, $type, $size, $opt = []) { + $dirName = (\dirname($name) == '.') ? '' : \dirname($name); $fileName = ($type == self::DIRTYPE) ? basename($name) . '/' : basename($name); - // handle long file names - if (strlen($fileName) > 99 || strlen($dirName) > 154){ + if (\strlen($fileName) > 99 || \strlen($dirName) > 154) { $this->writeLongName($fileName, $dirName); } @@ -176,29 +174,29 @@ protected function initFileStreamTransfer($name, $type, $size, $opt = []){ ->setTypeflag($type) ->setPrefix($dirName) ->getHeader() - ; + ; // print header $this->send($header); } - protected function writeLongName($fileName, $dirName){ + protected function writeLongName($fileName, $dirName) { $internalPath = trim($dirName . '/' . $fileName, '/'); if ($this->longNameHeaderType === self::XHDTYPE) { // Long names via PAX $pax = $this->paxGenerate([ 'path' => $internalPath]); - $paxSize = strlen($pax); + $paxSize = \strlen($pax); $this->initFileStreamTransfer('', self::XHDTYPE, $paxSize); $this->streamFilePart($pax); $this->completeFileStream($paxSize); } else { // long names via 'L' header - $pathSize = strlen($internalPath); + $pathSize = \strlen($internalPath); $tarHeader = new TarHeader(); $header = $tarHeader->setName('././@LongLink') ->setSize($pathSize) ->setTypeflag(self::LONGNAMETYPE) ->getHeader() - ; + ; $this->send($header); $this->streamFilePart($internalPath); $this->completeFileStream($pathSize); @@ -210,7 +208,7 @@ protected function writeLongName($fileName, $dirName){ * * @param string $data raw data to send */ - protected function streamFilePart($data){ + protected function streamFilePart($data) { // send data $this->send($data); @@ -222,9 +220,9 @@ protected function streamFilePart($data){ * Complete the current file stream * @param $size */ - protected function completeFileStream($size){ + protected function completeFileStream($size) { // ensure we pad the last block so that it is 512 bytes - if (($mod = ($size % 512)) > 0){ + if (($mod = ($size % 512)) > 0) { $this->send(pack('a' . (512 - $mod), '')); } @@ -237,8 +235,8 @@ protected function completeFileStream($size){ * * @param string $data data to send */ - protected function send($data){ - if ($this->needHeaders){ + protected function send($data) { + if ($this->needHeaders) { $this->sendHeaders(); } $this->needHeaders = false; @@ -250,15 +248,15 @@ protected function send($data){ * Generate a PAX string * * @param array $fields key value mapping - * @return string PAX formated string + * @return string PAX formatted string * @link http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5&manpath=FreeBSD+8-current tar / PAX spec */ - protected function paxGenerate($fields){ + protected function paxGenerate($fields) { $lines = ''; - foreach ($fields as $name => $value){ + foreach ($fields as $name => $value) { // build the line and the size $line = ' ' . $name . '=' . $value . "\n"; - $size = strlen(strlen($line)) + strlen($line); + $size = \strlen((string) \strlen($line)) + \strlen($line); // add the line $lines .= $size . $line;