1--TEST--
2Phar: test edge cases of fopen() function interception #2
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9Phar::interceptFileFuncs();
10$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
11$pname = 'phar://' . $fname;
12
13try {
14    fopen(array(), 'r');
15} catch (TypeError $e) {
16    echo $e->getMessage(), "\n";
17}
18chdir(__DIR__);
19file_put_contents($fname, "blah\n");
20file_put_contents("fopen_edgecases2.txt", "test\n");
21$a = fopen($fname, 'rb');
22echo fread($a, 1000);
23fclose($a);
24unlink($fname);
25mkdir($pname . '/oops');
26file_put_contents($pname . '/foo/hi', '<?php
27$context = stream_context_create();
28$a = fopen("fopen_edgecases2.txt", "rb", false, $context);
29echo fread($a, 1000);
30fclose($a);
31fopen("../oops", "r");
32?>
33');
34include $pname . '/foo/hi';
35?>
36--CLEAN--
37<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
38<?php unlink(__DIR__ . '/fopen_edgecases2.txt'); ?>
39--EXPECTF--
40fopen(): Argument #1 ($filename) must be of type string, array given
41blah
42test
43
44Warning: fopen(phar://%sfopen_edgecases2.phar.php/oops): Failed to open stream: phar error: path "oops" is a directory in phar://%sfopen_edgecases2.phar.php/foo/hi on line %d
45