1--TEST-- 2Phar::startBuffering()/setStub()/stopBuffering() zip-based 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required"); 7?> 8--INI-- 9phar.readonly=0 10--FILE-- 11<?php 12$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.zip', 0, 'brandnewphar.phar'); 13var_dump($p->isFileFormat(Phar::ZIP)); 14//var_dump($p->getStub()); 15var_dump($p->isBuffering()); 16$p->startBuffering(); 17var_dump($p->isBuffering()); 18$p['a.php'] = '<?php var_dump("Hello");'; 19$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>'); 20include 'phar://brandnewphar.phar/a.php'; 21var_dump($p->getStub()); 22$p['b.php'] = '<?php var_dump("World");'; 23$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();'); 24include 'phar://brandnewphar.phar/b.php'; 25var_dump($p->getStub()); 26$p->stopBuffering(); 27echo "===COMMIT===\n"; 28var_dump($p->isBuffering()); 29include 'phar://brandnewphar.phar/a.php'; 30include 'phar://brandnewphar.phar/b.php'; 31var_dump($p->getStub()); 32 33// add portion to test setting stub from resource 34file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>'); 35$a = fopen(dirname(__FILE__) . '/myfakestub.php', 'rb'); 36$p->setStub($a); 37var_dump($p->getStub()); 38$c = strlen('<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>'); 39file_put_contents(dirname(__FILE__) . '/myfakestub.php', '<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>' . 'extra stuff'); 40fseek($a, 0); 41$p->setStub($a, $c); 42var_dump($p->getStub()); 43fclose($a); 44?> 45===DONE=== 46--CLEAN-- 47<?php 48unlink(dirname(__FILE__) . '/brandnewphar.phar.zip'); 49unlink(dirname(__FILE__) . '/myfakestub.php'); 50?> 51--EXPECT-- 52bool(true) 53bool(false) 54bool(true) 55unicode(5) "Hello" 56string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?> 57" 58unicode(5) "World" 59string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?> 60" 61===COMMIT=== 62bool(false) 63unicode(5) "Hello" 64unicode(5) "World" 65string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?> 66" 67string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?> 68" 69string(93) "<?php var_dump("First resource"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?> 70" 71===DONE=== 72