1--TEST-- 2Phar: test edge cases of file_get_contents() function interception 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6?> 7--INI-- 8phar.readonly=0 9--FILE-- 10<?php 11 12Phar::interceptFileFuncs(); 13 14$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php'; 15$pname = 'phar://' . $fname; 16 17file_get_contents(array()); 18chdir(__DIR__); 19file_put_contents($fname, "blah\n"); 20file_put_contents("fgc_edgecases.txt", "test\n"); 21echo file_get_contents($fname); 22unlink($fname); 23mkdir($pname . '/oops'); 24 25file_put_contents($pname . '/foo/hi', '<?php 26echo file_get_contents("foo/" . basename(__FILE__)); 27$context = stream_context_create(); 28file_get_contents("./hi", 0, $context, 0, -1); 29echo file_get_contents("fgc_edgecases.txt"); 30set_include_path("' . addslashes(__DIR__) . '"); 31echo file_get_contents("fgc_edgecases.txt", true); 32echo file_get_contents("./hi", 0, $context); 33echo file_get_contents("../oops"); 34echo file_get_contents("./hi", 0, $context, 50000); 35echo file_get_contents("./hi"); 36echo file_get_contents("./hi", 0, $context, 0, 0); 37?> 38'); 39 40include $pname . '/foo/hi'; 41 42?> 43===DONE=== 44--CLEAN-- 45<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 46<?php unlink(__DIR__ . '/fgc_edgecases.txt'); ?> 47--EXPECTF-- 48Warning: file_get_contents() expects parameter 1 to be a valid path, array given in %sfgc_edgecases.php on line %d 49blah 50<?php 51echo file_get_contents("foo/" . basename(__FILE__)); 52$context = stream_context_create(); 53file_get_contents("./hi", 0, $context, 0, -1); 54echo file_get_contents("fgc_edgecases.txt"); 55set_include_path("%stests"); 56echo file_get_contents("fgc_edgecases.txt", true); 57echo file_get_contents("./hi", 0, $context); 58echo file_get_contents("../oops"); 59echo file_get_contents("./hi", 0, $context, 50000); 60echo file_get_contents("./hi"); 61echo file_get_contents("./hi", 0, $context, 0, 0); 62?> 63 64Warning: file_get_contents(): length must be greater than or equal to zero in phar://%sfgc_edgecases.phar.php/foo/hi on line %d 65test 66test 67<?php 68echo file_get_contents("foo/" . basename(__FILE__)); 69$context = stream_context_create(); 70file_get_contents("./hi", 0, $context, 0, -1); 71echo file_get_contents("fgc_edgecases.txt"); 72set_include_path("%stests"); 73echo file_get_contents("fgc_edgecases.txt", true); 74echo file_get_contents("./hi", 0, $context); 75echo file_get_contents("../oops"); 76echo file_get_contents("./hi", 0, $context, 50000); 77echo file_get_contents("./hi"); 78echo file_get_contents("./hi", 0, $context, 0, 0); 79?> 80 81Warning: file_get_contents(phar://%sfgc_edgecases.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfgc_edgecases.phar.php/foo/hi on line %d 82 83Warning: file_get_contents(): Failed to seek to position 50000 in the stream in phar://%sfgc_edgecases.phar.php/foo/hi on line %d 84<?php 85echo file_get_contents("foo/" . basename(__FILE__)); 86$context = stream_context_create(); 87file_get_contents("./hi", 0, $context, 0, -1); 88echo file_get_contents("fgc_edgecases.txt"); 89set_include_path("%stests"); 90echo file_get_contents("fgc_edgecases.txt", true); 91echo file_get_contents("./hi", 0, $context); 92echo file_get_contents("../oops"); 93echo file_get_contents("./hi", 0, $context, 50000); 94echo file_get_contents("./hi"); 95echo file_get_contents("./hi", 0, $context, 0, 0); 96?> 97===DONE=== 98