mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-08-10 17:33:56 +02:00
refactoring
This commit is contained in:
2
.php_cs
2
.php_cs
@@ -899,7 +899,7 @@ $rules = [
|
|||||||
* Risky when PHPUnit classes are overridden or not accessible, or
|
* Risky when PHPUnit classes are overridden or not accessible, or
|
||||||
* when project has PHPUnit incompatibilities.
|
* when project has PHPUnit incompatibilities.
|
||||||
*/
|
*/
|
||||||
'php_unit_expectation' => true,
|
'php_unit_expectation' => false,
|
||||||
|
|
||||||
// PHPUnit annotations should be a FQCNs including a root namespace.
|
// PHPUnit annotations should be a FQCNs including a root namespace.
|
||||||
'php_unit_fqcn_annotation' => true,
|
'php_unit_fqcn_annotation' => true,
|
||||||
|
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace PhpZip\Exception;
|
namespace PhpZip\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ZipUnsupportMethodException.
|
||||||
|
*/
|
||||||
class ZipUnsupportMethodException extends RuntimeException
|
class ZipUnsupportMethodException extends RuntimeException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ class EndOfCentralDirectory
|
|||||||
private $entryCount;
|
private $entryCount;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $zip64 = false;
|
private $zip64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EndOfCentralDirectory constructor.
|
* EndOfCentralDirectory constructor.
|
||||||
|
@@ -507,6 +507,7 @@ class ZipInputStream implements ZipInputStreamInterface
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ZipFileInterface::METHOD_DEFLATED:
|
case ZipFileInterface::METHOD_DEFLATED:
|
||||||
|
/** @noinspection PhpUsageOfSilenceOperatorInspection */
|
||||||
$content = @gzinflate($content);
|
$content = @gzinflate($content);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** @noinspection PhpUsageOfSilenceOperatorInspection */
|
||||||
|
|
||||||
namespace PhpZip;
|
namespace PhpZip;
|
||||||
|
|
||||||
use PhpZip\Exception\InvalidArgumentException;
|
use PhpZip\Exception\InvalidArgumentException;
|
||||||
|
@@ -10,10 +10,16 @@ class DummyFileSystemStream
|
|||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $fp;
|
private $fp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $path
|
||||||
|
* @param $mode
|
||||||
|
* @param $options
|
||||||
|
* @param $opened_path
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function stream_open($path, $mode, $options, &$opened_path)
|
public function stream_open($path, $mode, $options, &$opened_path)
|
||||||
{
|
{
|
||||||
// echo "DummyFileSystemStream->stream_open($path, $mode, $options)" . PHP_EOL;
|
|
||||||
|
|
||||||
$parsedUrl = parse_url($path);
|
$parsedUrl = parse_url($path);
|
||||||
$path = $parsedUrl['path'];
|
$path = $parsedUrl['path'];
|
||||||
$this->fp = fopen($path, $mode);
|
$this->fp = fopen($path, $mode);
|
||||||
@@ -21,37 +27,46 @@ class DummyFileSystemStream
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $count
|
||||||
|
*
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function stream_read($count)
|
public function stream_read($count)
|
||||||
{
|
{
|
||||||
// echo "DummyFileSystemStream->stream_read($count)" . PHP_EOL;
|
|
||||||
$position = ftell($this->fp);
|
|
||||||
|
|
||||||
// echo "Loading chunk " . $position . " to " . ($position + $count - 1) . PHP_EOL;
|
|
||||||
return fread($this->fp, $count);
|
return fread($this->fp, $count);
|
||||||
// echo "String length: " . strlen($ret) . PHP_EOL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return false|int
|
||||||
|
*/
|
||||||
public function stream_tell()
|
public function stream_tell()
|
||||||
{
|
{
|
||||||
// echo "DummyFileSystemStream->stream_tell()" . PHP_EOL;
|
|
||||||
return ftell($this->fp);
|
return ftell($this->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function stream_eof()
|
public function stream_eof()
|
||||||
{
|
{
|
||||||
// echo "DummyFileSystemStream->stream_eof()" . PHP_EOL;
|
|
||||||
return feof($this->fp);
|
return feof($this->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $offset
|
||||||
|
* @param $whence
|
||||||
|
*/
|
||||||
public function stream_seek($offset, $whence)
|
public function stream_seek($offset, $whence)
|
||||||
{
|
{
|
||||||
// echo "DummyFileSystemStream->stream_seek($offset, $whence)" . PHP_EOL;
|
|
||||||
fseek($this->fp, $offset, $whence);
|
fseek($this->fp, $offset, $whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function stream_stat()
|
public function stream_stat()
|
||||||
{
|
{
|
||||||
// echo "DummyFileSystemStream->stream_stat()" . PHP_EOL;
|
|
||||||
return fstat($this->fp);
|
return fstat($this->fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -133,10 +133,10 @@ class PhpZipExtResourceTest extends ZipTestCase
|
|||||||
static::assertTrue(mkdir($this->outputDirname, 0755, true));
|
static::assertTrue(mkdir($this->outputDirname, 0755, true));
|
||||||
|
|
||||||
$zipFile = new ZipFile();
|
$zipFile = new ZipFile();
|
||||||
|
$zipFile->openFile($filename);
|
||||||
|
$zipFile->setReadPassword('bar');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$zipFile->openFile($filename);
|
|
||||||
$zipFile->setReadPassword('bar');
|
|
||||||
$zipFile->extractTo($this->outputDirname);
|
$zipFile->extractTo($this->outputDirname);
|
||||||
static::markTestIncomplete('failed test');
|
static::markTestIncomplete('failed test');
|
||||||
} catch (ZipException $exception) {
|
} catch (ZipException $exception) {
|
||||||
|
Reference in New Issue
Block a user