mirror of
https://github.com/php/php-src.git
synced 2026-04-18 05:21:02 +02:00
PHP requires integer typehints to be written "int" and does not allow "integer" as an alias. This changes type error messages to match the actual type name and avoids confusing messages like "must be of the type integer, integer given".
94 lines
2.2 KiB
PHP
94 lines
2.2 KiB
PHP
--TEST--
|
|
Phar: PharFileInfo compression-related methods
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
|
<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
|
|
<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
|
|
--INI--
|
|
phar.readonly=0
|
|
--FILE--
|
|
<?php
|
|
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
|
|
$pname = 'phar://' . $fname;
|
|
|
|
$phar = new Phar($fname);
|
|
|
|
$phar['a/b'] = 'hi there';
|
|
|
|
$b = $phar['a/b'];
|
|
|
|
$b->isCompressed(array());
|
|
try {
|
|
$b->isCompressed(25);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
$b->compress(25);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
$tar = $phar->convertToData(Phar::TAR);
|
|
|
|
$c = $tar['a/b'];
|
|
try {
|
|
$c->compress(Phar::GZ);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
$phar['a']->compress(Phar::GZ);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
ini_set('phar.readonly', 1);
|
|
try {
|
|
$b->compress(Phar::GZ);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
ini_set('phar.readonly', 0);
|
|
var_dump($b->compress(Phar::GZ));
|
|
var_dump($b->compress(Phar::GZ));
|
|
var_dump($b->compress(Phar::BZ2));
|
|
var_dump($b->compress(Phar::BZ2));
|
|
|
|
echo "decompress\n";
|
|
|
|
ini_set('phar.readonly', 1);
|
|
try {
|
|
$phar['a/b']->decompress();
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
ini_set('phar.readonly', 0);
|
|
try {
|
|
$phar['a']->decompress();
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
var_dump($b->decompress());
|
|
var_dump($b->decompress());
|
|
|
|
?>
|
|
===DONE===
|
|
--CLEAN--
|
|
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
|
|
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
|
|
--EXPECTF--
|
|
Warning: PharFileInfo::isCompressed() expects parameter 1 to be int, array given in %spharfileinfo_compression.php on line 11
|
|
Unknown compression type specified
|
|
Unknown compression type specified
|
|
Cannot compress with Gzip compression, not possible with tar-based phar archives
|
|
Phar entry is a directory, cannot set compression
|
|
Phar is readonly, cannot change compression
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
decompress
|
|
Phar is readonly, cannot decompress
|
|
Phar entry is a directory, cannot set compression
|
|
bool(true)
|
|
bool(true)
|
|
===DONE===
|