1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix some more CLEAN sections

This commit is contained in:
Nikita Popov
2021-09-06 11:20:53 +02:00
parent 86a0d4b22d
commit 768265cd22
17 changed files with 42 additions and 72 deletions

View File

@@ -17,9 +17,9 @@ print('OK');
OK
--CLEAN--
<?php
@rmdir(__DIR__ . '/bug78650/foo/bar');
@rmdir(__DIR__ . '/bug78650/foo');
rmdir(__DIR__ . '/bug78650/baz/bar');
rmdir(__DIR__ . '/bug78650/foo/bar');
rmdir(__DIR__ . '/bug78650/baz');
rmdir(__DIR__ . '/bug78650/foo');
rmdir(__DIR__ . '/bug78650');
?>

View File

@@ -19,11 +19,6 @@ try {
echo $e->getMessage() . "\n";
}
?>
--CLEAN--
<?php
unlink(__DIR__ . '/buildfromdirectory2.phar');
__HALT_COMPILER();
?>
--EXPECTF--
%s(24) "UnexpectedValueException"
RecursiveDirectoryIterator::__construct(1): %s (code: 2)

View File

@@ -26,8 +26,10 @@ opendir("foo/hi");
include $pname . '/foo/hi';
?>
--CLEAN--
<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.php'); ?>
<?php
@unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.php');
?>
--EXPECTF--
Warning: readfile(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d

View File

@@ -35,20 +35,15 @@ class myIterator implements Iterator
reset($this->a);
}
}
try {
chdir(__DIR__);
$phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar');
var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt'))));
var_dump($phar->isFileFormat(Phar::TAR));
} catch (Exception $e) {
var_dump(get_class($e));
echo $e->getMessage() . "\n";
}
chdir(__DIR__);
$phar = new Phar(__DIR__ . '/buildfromiterator4.phar.tar');
var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt'))));
var_dump($phar->isFileFormat(Phar::TAR));
?>
--CLEAN--
<?php
unlink(__DIR__ . '/buildfromiterator.phar.tar');
__HALT_COMPILER();
unlink(__DIR__ . '/buildfromiterator4.phar.tar');
?>
--EXPECTF--
rewind

View File

@@ -6,22 +6,16 @@ phar
phar.readonly=0
--FILE--
<?php
try {
chdir(__DIR__);
$phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar');
$a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR);
asort($a);
var_dump($a);
var_dump($phar->isFileFormat(Phar::TAR));
} catch (Exception $e) {
var_dump(get_class($e));
echo $e->getMessage() . "\n";
}
chdir(__DIR__);
$phar = new Phar(__DIR__ . '/buildfromiterator8.phar.tar');
$a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR);
asort($a);
var_dump($a);
var_dump($phar->isFileFormat(Phar::TAR));
?>
--CLEAN--
<?php
unlink(__DIR__ . '/buildfromiterator.phar.tar');
__HALT_COMPILER();
unlink(__DIR__ . '/buildfromiterator8.phar.tar');
?>
--EXPECTF--
array(21) {

View File

@@ -35,20 +35,15 @@ class myIterator implements Iterator
reset($this->a);
}
}
try {
chdir(__DIR__);
$phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar');
var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r')))));
fclose($a);
} catch (Exception $e) {
var_dump(get_class($e));
echo $e->getMessage() . "\n";
}
chdir(__DIR__);
$phar = new Phar(__DIR__ . '/buildfromiterator9.phar.tar');
var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r')))));
fclose($a);
?>
--CLEAN--
<?php
unlink(__DIR__ . '/buildfromiterator.phar.tar');
__HALT_COMPILER();
unlink(__DIR__ . '/buildfromiterator9.phar.tar');
?>
--EXPECTF--
rewind

View File

@@ -19,12 +19,6 @@ var_dump(socket_last_error($socket));
socket_clear_error($socket);
var_dump(socket_last_error($socket));
?>
--CLEAN--
<?php
socket_close($socket);
unset($socket);
unset($socketConn);
?>
--EXPECTF--
Warning: socket_connect(): unable to connect [%d]: No connection could be made because the target machine actively refused it in %s on line %d
int(%d)

View File

@@ -30,6 +30,10 @@ bool(false)
--CLEAN--
<?php
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'symlinktest';
unlink($dir . DIRECTORY_SEPARATOR . 'symlink');
if (PHP_OS_FAMILY == 'Windows') {
rmdir($dir . DIRECTORY_SEPARATOR . 'symlink');
} else {
unlink($dir . DIRECTORY_SEPARATOR . 'symlink');
}
rmdir($dir);
?>

View File

@@ -15,7 +15,7 @@ foreach ($exts as $ext) {
$file = md5('SplFileInfo::getExtension');
$exts = array('.txt', '.extension', '..', '.', '');
foreach ($exts as $ext) {
unlink($file . $ext);
@unlink($file . $ext);
}
?>
--EXPECT--

View File

@@ -139,7 +139,7 @@ unlink($file_path."/005_variation_softlink.tmp");
unlink($file_path."/005_variation_hardlink.tmp");
unlink($file_path."/005_variation1.tmp");
unlink($file_path."/005_variation_copy.tmp");
unlink($file_path."/005_variation_touch.tmp");
@unlink($file_path."/005_variation_touch.tmp");
unlink($file_path."/005_variation_touch_fly.tmp");
unlink($file_path."/005_variation_touch_new.tmp");
?>

View File

@@ -22,7 +22,7 @@ var_dump(filesize($dst));
<?php
$file_path = __DIR__ . "/bug65701/";
foreach (scandir($file_path) as $file) {
if (strpos($file, "bug65701") !== false || 'WIN' == substr(PHP_OS, 0, 3)) {
if (!is_dir($file_path . $file)) {
unlink($file_path . $file);
}
}

View File

@@ -27,7 +27,6 @@ echo "*** Done ***\n";
?>
--CLEAN--
<?php
unlink(__DIR__."/copy_copy_variation12");
rmdir(__DIR__."/copy_variation12");
?>
--EXPECTF--

View File

@@ -12,8 +12,13 @@ echo "2. " . realpath("$file_path/realpath_basic4/link2/test") . "\n";
--CLEAN--
<?php
$file_path = __DIR__;
unlink("$file_path/realpath_basic4/link2");
unlink("$file_path/realpath_basic4/link1");
if (PHP_OS_FAMILY == 'Windows') {
rmdir("$file_path/realpath_basic4/link2");
rmdir("$file_path/realpath_basic4/link1");
} else {
unlink("$file_path/realpath_basic4/link2");
unlink("$file_path/realpath_basic4/link1");
}
rmdir("$file_path/realpath_basic4/home/test");
rmdir("$file_path/realpath_basic4/home");
rmdir("$file_path/realpath_basic4");

View File

@@ -46,16 +46,12 @@ foreach($src_filenames as $src_filename) {
unlink($dest_filename);
}
rmdir("$file_path/rename_variation");
echo "Done\n";
?>
--CLEAN--
<?php
$file_path = __DIR__;
unlink($file_path."/rename_variation_link.tmp");
unlink($file_path."/rename_variation.tmp");
rmdir($file_path."/rename_variation_dir");
rmdir($file_path."/rename_variation");
?>
--EXPECTF--
*** Testing rename() : rename files across directories ***

View File

@@ -55,8 +55,6 @@ echo "Done\n";
--CLEAN--
<?php
$file_path = __DIR__;
unlink($file_path."/rename_variation_link.tmp");
unlink($file_path."/rename_variation.tmp");
rmdir($file_path."/rename_variation_dir");
?>
--EXPECT--

View File

@@ -34,16 +34,12 @@ var_dump( rename($file_path."/rename_variation2_dir/", $file_path."/12345") );
var_dump( file_exists($file_path."/rename_variation2_dir" ) ); // expecting false
var_dump( file_exists($file_path."/12345" ) ); // expecting true
rmdir($file_path."/12345");
echo "Done\n";
?>
--CLEAN--
<?php
$file_path = __DIR__;
unlink($file_path."/rename_variation2_link.tmp");
unlink($file_path."/rename_variation2.tmp");
rmdir($file_path."/rename_variation2_dir");
rmdir($file_path."/12345");
?>
--EXPECT--
*** Testing rename() by renaming a file and directory to numeric name ***

View File

@@ -51,9 +51,6 @@ echo "Done\n";
--CLEAN--
<?php
$file_path = __DIR__;
unlink($file_path."/rename_variation3_link.tmp");
unlink($file_path."/rename_variation3.tmp");
rmdir($file_path."/rename_variation3_dir");
rmdir($file_path."/rename_variation3.tmp");
?>
--EXPECTF--