-
Notifications
You must be signed in to change notification settings - Fork 8k
Expand file tree
/
Copy pathgetPathname_exception.phpt
More file actions
63 lines (58 loc) · 1.59 KB
/
getPathname_exception.phpt
File metadata and controls
63 lines (58 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--TEST--
buildFromIterator with user overrides - exception in getPathname()
--EXTENSIONS--
phar
--INI--
phar.readonly=0
phar.require_hash=0
--CREDITS--
Arne Blankerts
N. Dossche
--FILE--
<?php
class MyGlobIterator extends GlobIterator {
public function getPathname(): string {
echo "[getPathname]\n";
var_dump(parent::getPathname());
throw new Error('exception in getPathname()');
}
}
class MyIterator extends RecursiveDirectoryIterator {
public function current(): SplFileInfo {
echo "[ Found: " . parent::current()->getPathname() . " ]\n";
return new MyGlobIterator(parent::current()->getPath() . '/*');
}
}
$workdir = __DIR__.'/getPathname_exception';
mkdir($workdir . '/content', recursive: true);
file_put_contents($workdir . '/content/hello.txt', "Hello world.");
$phar = new \Phar($workdir . "/test.phar");
$phar->startBuffering();
try {
$phar->buildFromIterator(
new RecursiveIteratorIterator(
new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS)
),
$workdir
);
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
if ($previous = $e->getPrevious()) {
echo "Previous: ", $previous->getMessage(), "\n";
}
}
$phar->stopBuffering();
?>
--CLEAN--
<?php
$workdir = __DIR__.'/getPathname_exception';
@unlink($workdir . '/content/hello.txt');
@rmdir($workdir . '/content');
@rmdir($workdir);
?>
--EXPECTF--
[ Found: %shello.txt ]
[getPathname]
string(%d) "%shello.txt"
MyGlobIterator::getPathname(): Return value must be of type string, null returned
Previous: exception in getPathname()