Skip to content

Commit 8df0a40

Browse files
authored
Remove PHP 7 compatibility (#229)
1 parent 49a6f58 commit 8df0a40

File tree

5 files changed

+12
-69
lines changed

5 files changed

+12
-69
lines changed

.github/workflows/part_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ["7.4", "8.0", "8.1"]
17+
php: ["8.0", "8.1"]
1818
os: [ubuntu-latest]
1919
experimental: [false]
2020
include:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^7.4 || ^8.0",
25+
"php": "^8.0",
2626
"symfony/polyfill-mbstring": "^1.0",
2727
"psr/http-message": "^1.0",
2828
"myclabs/php-enum": "^1.5"

src/DeflateStream.php

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,24 @@
44

55
namespace ZipStream;
66

7+
/**
8+
* @deprecated
9+
*/
710
class DeflateStream extends Stream
811
{
9-
protected $filter;
10-
11-
/**
12-
* @var Option\File
13-
*/
14-
protected $options;
15-
16-
/**
17-
* Rewind stream
18-
*
19-
* @return void
20-
*/
21-
public function rewind(): void
12+
public function __construct($stream)
2213
{
23-
// deflate filter needs to be removed before rewind
24-
if ($this->filter) {
25-
$this->removeDeflateFilter();
26-
$this->seek(0);
27-
$this->addDeflateFilter($this->options);
28-
} else {
29-
rewind($this->stream);
30-
}
14+
parent::__construct($stream);
15+
trigger_error('Class ' . __CLASS__ . ' is deprecated, delation will be handled internally instead', E_USER_DEPRECATED);
3116
}
3217

33-
/**
34-
* Remove the deflate filter
35-
*
36-
* @return void
37-
*/
3818
public function removeDeflateFilter(): void
3919
{
40-
if (!$this->filter) {
41-
return;
42-
}
43-
stream_filter_remove($this->filter);
44-
$this->filter = null;
20+
trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED);
4521
}
4622

47-
/**
48-
* Add a deflate filter
49-
*
50-
* @param Option\File $options
51-
* @return void
52-
*/
5323
public function addDeflateFilter(Option\File $options): void
5424
{
55-
$this->options = $options;
56-
// parameter 4 for stream_filter_append expects array
57-
// so we convert the option object in an array
58-
$optionsArr = [
59-
'comment' => $options->getComment(),
60-
'method' => $options->getMethod(),
61-
'deflateLevel' => $options->getDeflateLevel(),
62-
'time' => $options->getTime(),
63-
];
64-
$this->filter = stream_filter_append(
65-
$this->stream,
66-
'zlib.deflate',
67-
STREAM_FILTER_READ,
68-
$optionsArr
69-
);
25+
trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED);
7026
}
7127
}

src/File.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function processPath(string $path): void
120120
} else {
121121
$this->method = $this->zip->opt->getLargeFileMethod();
122122

123-
$stream = new DeflateStream(fopen($path, 'rb'));
123+
$stream = new Stream(fopen($path, 'rb'));
124124
$this->processStream($stream);
125125
$stream->close();
126126
}
@@ -463,19 +463,6 @@ protected function processStreamWithComputedHeader(StreamInterface $stream): voi
463463
$this->readStream($stream, self::COMPUTE);
464464
$stream->rewind();
465465

466-
// incremental compression with deflate_add
467-
// makes this second read unnecessary
468-
// but it is only available from PHP 7.0
469-
if (!$this->deflate && $stream instanceof DeflateStream && $this->method->equals(Method::DEFLATE())) {
470-
$stream->addDeflateFilter($this->opt);
471-
$this->zlen = new Bigint();
472-
while (!$stream->eof()) {
473-
$data = $stream->read(self::CHUNKED_READ_BLOCK_SIZE);
474-
$this->zlen = $this->zlen->add(Bigint::init(strlen($data)));
475-
}
476-
$stream->rewind();
477-
}
478-
479466
$this->addFileHeader();
480467
$this->readStream($stream, self::SEND);
481468
$this->addFileFooter();

src/ZipStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function addFileFromStream(string $name, $stream, ?FileOptions $options =
299299
$options->defaultTo($this->opt);
300300

301301
$file = new File($this, $name, $options);
302-
$file->processStream(new DeflateStream($stream));
302+
$file->processStream(new Stream($stream));
303303
}
304304

305305
/**

0 commit comments

Comments
 (0)