diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da70ebb..c60a4bf 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: - name: Install dependencies run: > - curl -sSL https://baltocdn.com/xp-framework/xp-runners/distribution/downloads/e/entrypoint/xp-run-9.1.0.sh > xp-run && + curl -sSL https://github.com/xp-runners/reference/releases/download/v9.2.0/xp-run-9.2.0.sh > xp-run && composer install --prefer-dist && echo "vendor/autoload.php" > composer.pth diff --git a/composer.json b/composer.json index 3620dbd..d816364 100755 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "description" : "Compression I/O for the XP Framework", "keywords": ["language", "module", "xp"], "require" : { - "xp-framework/core": "^12.0 | ^11.0 | ^10.0", + "xp-framework/core": "^12.11 | ^11.11", "php" : ">=7.4.0" }, "require-dev" : { diff --git a/src/main/php/io/streams/compress/Brotli.class.php b/src/main/php/io/streams/compress/Brotli.class.php index 373a8ad..f3ae74f 100755 --- a/src/main/php/io/streams/compress/Brotli.class.php +++ b/src/main/php/io/streams/compress/Brotli.class.php @@ -1,6 +1,6 @@ fd= Streams::readableFd($in); if (!stream_filter_append($this->fd, 'bzip2.decompress', STREAM_FILTER_READ)) { fclose($this->fd); $this->fd= null; - throw new IOException('Could not append stream filter'); + throw new OperationFailed('Could not append stream filter'); } } @@ -35,7 +35,7 @@ public function __construct(InputStream $in) { */ public function read($limit= 8192) { if (false === ($bytes= fread($this->fd, $limit))) { - $e= new IOException('Reading compressed data failed'); + $e= new OperationFailed('Reading compressed data failed'); \xp::gc(__FILE__); throw $e; } diff --git a/src/main/php/io/streams/compress/Bzip2OutputStream.class.php b/src/main/php/io/streams/compress/Bzip2OutputStream.class.php index b3af7bd..735775c 100755 --- a/src/main/php/io/streams/compress/Bzip2OutputStream.class.php +++ b/src/main/php/io/streams/compress/Bzip2OutputStream.class.php @@ -1,6 +1,6 @@ 9) { @@ -30,7 +30,7 @@ public function __construct(OutputStream $out, $level= 6) { if (!stream_filter_append($this->fd, 'bzip2.compress', STREAM_FILTER_WRITE, ['blocks' => $level])) { fclose($this->fd); $this->fd= null; - throw new IOException('Could not append stream filter'); + throw new OperationFailed('Could not append stream filter'); } } diff --git a/src/main/php/io/streams/compress/DeflatingOutputStream.class.php b/src/main/php/io/streams/compress/DeflatingOutputStream.class.php index e71c7ee..4b5a576 100644 --- a/src/main/php/io/streams/compress/DeflatingOutputStream.class.php +++ b/src/main/php/io/streams/compress/DeflatingOutputStream.class.php @@ -1,6 +1,6 @@ out, 'zlib.deflate', STREAM_FILTER_WRITE, $level)) { fclose($this->out); $this->out= null; - throw new IOException('Could not append stream filter'); + throw new OperationFailed('Could not append stream filter'); } } diff --git a/src/main/php/io/streams/compress/Gzip.class.php b/src/main/php/io/streams/compress/Gzip.class.php index 4c1f047..dde61ac 100755 --- a/src/main/php/io/streams/compress/Gzip.class.php +++ b/src/main/php/io/streams/compress/Gzip.class.php @@ -1,6 +1,6 @@ header= unpack('a2id/Cmethod/Cflags/Vtime/Cextra/Cos', $header); if ("\x1F\x8B" !== $this->header['id']) { - $e= new IOException('Invalid format, expected \037\213, have '.addcslashes($this->header['id'], "\0..\377")); + $e= new OperationFailed('Invalid format, expected \037\213, have '.addcslashes($this->header['id'], "\0..\377")); \xp::gc(__FILE__); throw $e; } if (8 !== $this->header['method']) { - throw new IOException('Unknown compression method #'.$this->header['method']); + throw new OperationFailed('Unknown compression method #'.$this->header['method']); } // Extract filename if present @@ -103,7 +103,7 @@ public function __construct(InputStream $in) { if (!stream_filter_append($this->fd, 'zlib.inflate', STREAM_FILTER_READ)) { fclose($this->fd); $this->fd= null; - throw new IOException('Could not append stream filter'); + throw new OperationFailed('Could not append stream filter'); } } @@ -118,7 +118,7 @@ public function header() { return $this->header; } */ public function read($limit= 8192) { if (false === ($bytes= fread($this->fd, $limit))) { - $e= new IOException('Reading compressed data failed'); + $e= new OperationFailed('Reading compressed data failed'); \xp::gc(__FILE__); throw $e; } diff --git a/src/main/php/io/streams/compress/GzipOutputStream.class.php b/src/main/php/io/streams/compress/GzipOutputStream.class.php index 66414ba..cec34a4 100755 --- a/src/main/php/io/streams/compress/GzipOutputStream.class.php +++ b/src/main/php/io/streams/compress/GzipOutputStream.class.php @@ -1,6 +1,6 @@ 9) { @@ -43,7 +43,7 @@ public function __construct(OutputStream $out, $level= 6) { if (!($this->filter= stream_filter_append($this->fd, 'zlib.deflate', STREAM_FILTER_WRITE, $level))) { fclose($this->fd); $this->fd= null; - throw new IOException('Could not append stream filter'); + throw new OperationFailed('Could not append stream filter'); } $this->md= hash_init('crc32b'); } diff --git a/src/main/php/io/streams/compress/InflatingInputStream.class.php b/src/main/php/io/streams/compress/InflatingInputStream.class.php index 3e74961..765d152 100644 --- a/src/main/php/io/streams/compress/InflatingInputStream.class.php +++ b/src/main/php/io/streams/compress/InflatingInputStream.class.php @@ -1,6 +1,6 @@ in= Streams::readableFd($in); if (!stream_filter_append($this->in, 'zlib.inflate', STREAM_FILTER_READ)) { - throw new IOException('Could not append stream filter'); + throw new OperationFailed('Could not append stream filter'); } } diff --git a/src/main/php/io/streams/compress/Snappy.class.php b/src/main/php/io/streams/compress/Snappy.class.php index 0151118..aa772b6 100755 --- a/src/main/php/io/streams/compress/Snappy.class.php +++ b/src/main/php/io/streams/compress/Snappy.class.php @@ -1,6 +1,6 @@ > 2; if ($l >= 60) { $n= $l - 59; - if ($pos + $n >= $limit) throw new IOException('Not enough input, expected '.$n); + if ($pos + $n >= $limit) throw new OperationFailed('Not enough input, expected '.$n); $l= unpack('P', str_pad(substr($bytes, $pos, $n), 8, "\0"))[1]; $pos+= $n; } $l++; - if ($pos + $l > $limit) throw new IOException('Not enough input, expected '.$l); + if ($pos + $l > $limit) throw new OperationFailed('Not enough input, expected '.$l); $out.= substr($bytes, $pos, $l); $pos+= $l; @@ -193,7 +193,7 @@ public function decompress(string $bytes): string { break; case 2: - if ($pos + 1 >= $limit) throw new IOException('Not enough input, expected 1'); + if ($pos + 1 >= $limit) throw new OperationFailed('Not enough input, expected 1'); $l= 1 + ($c >> 2); $offset= unpack('v', $bytes, $pos)[1]; @@ -204,7 +204,7 @@ public function decompress(string $bytes): string { break; case 3: - if ($pos + 3 >= $limit) throw new IOException('Not enough input, expected 3'); + if ($pos + 3 >= $limit) throw new OperationFailed('Not enough input, expected 3'); $l= 1 + ($c >> 2); $offset= unpack('V', $bytes, $pos)[1]; @@ -218,7 +218,7 @@ public function decompress(string $bytes): string { // Verify uncompressed length if ($length !== ($l= strlen($out))) { - throw new IOException('Expected length '.$length.', have '.$l); + throw new OperationFailed('Expected length '.$length.', have '.$l); } return $out; diff --git a/src/main/php/io/streams/compress/SnappyInputStream.class.php b/src/main/php/io/streams/compress/SnappyInputStream.class.php index bb73fce..3c051ab 100755 --- a/src/main/php/io/streams/compress/SnappyInputStream.class.php +++ b/src/main/php/io/streams/compress/SnappyInputStream.class.php @@ -1,6 +1,6 @@ buffer) < $n) { if ($this->in->available()) { $this->buffer.= $this->in->read(); } else { - throw new IOException('Not enough input, expected '.$n); + throw new OperationFailed('Not enough input, expected '.$n); } } diff --git a/src/main/php/io/streams/compress/ZStandard.class.php b/src/main/php/io/streams/compress/ZStandard.class.php index 8091795..71e739e 100755 --- a/src/main/php/io/streams/compress/ZStandard.class.php +++ b/src/main/php/io/streams/compress/ZStandard.class.php @@ -1,6 +1,6 @@ handle, $this->in->read($limit)); if (false === $bytes) { - $e= new IOException('Failed to uncompress'); + $e= new OperationFailed('Failed to uncompress'); \xp::gc(__FILE__); throw $e; } diff --git a/src/test/php/io/streams/compress/unittest/CompressionTest.class.php b/src/test/php/io/streams/compress/unittest/CompressionTest.class.php index ec7a4cd..f6e15db 100755 --- a/src/test/php/io/streams/compress/unittest/CompressionTest.class.php +++ b/src/test/php/io/streams/compress/unittest/CompressionTest.class.php @@ -1,6 +1,6 @@ decompress($bytes); } diff --git a/src/test/php/io/streams/compress/unittest/DecompressingInputStreamTest.class.php b/src/test/php/io/streams/compress/unittest/DecompressingInputStreamTest.class.php index cfd6827..75f2985 100755 --- a/src/test/php/io/streams/compress/unittest/DecompressingInputStreamTest.class.php +++ b/src/test/php/io/streams/compress/unittest/DecompressingInputStreamTest.class.php @@ -1,6 +1,6 @@ fixture(new MemoryInputStream($data)); try { diff --git a/src/test/php/io/streams/compress/unittest/GzipInputStreamTest.class.php b/src/test/php/io/streams/compress/unittest/GzipInputStreamTest.class.php index 625c7bf..1ccb494 100755 --- a/src/test/php/io/streams/compress/unittest/GzipInputStreamTest.class.php +++ b/src/test/php/io/streams/compress/unittest/GzipInputStreamTest.class.php @@ -1,6 +1,6 @@ header()['filename']); } - #[Test, Expect(IOException::class)] + #[Test, Expect(OperationFailed::class)] public function from_empty() { $this->fixture(new MemoryInputStream('')); } diff --git a/src/test/php/io/streams/compress/unittest/SnappyInputStreamTest.class.php b/src/test/php/io/streams/compress/unittest/SnappyInputStreamTest.class.php index 47ff065..1d11ae8 100755 --- a/src/test/php/io/streams/compress/unittest/SnappyInputStreamTest.class.php +++ b/src/test/php/io/streams/compress/unittest/SnappyInputStreamTest.class.php @@ -1,6 +1,6 @@ fixture('')); } - #[Test, Expect(class: IOException::class, message: 'Not enough input, expected 1')] + #[Test, Expect(class: OperationFailed::class, message: 'Not enough input, expected 1')] public function not_enough_input() { Streams::readAll($this->fixture("\x01")); } diff --git a/src/test/php/io/streams/compress/unittest/ZStandardInputStreamTest.class.php b/src/test/php/io/streams/compress/unittest/ZStandardInputStreamTest.class.php index bd8870c..1d70130 100755 --- a/src/test/php/io/streams/compress/unittest/ZStandardInputStreamTest.class.php +++ b/src/test/php/io/streams/compress/unittest/ZStandardInputStreamTest.class.php @@ -1,6 +1,6 @@ read(); }); $in->close();