1--TEST-- 2Phar: tar-based phar, require_hash=1, no signature 3--SKIPIF-- 4<?php if (!extension_loaded('phar')) die('skip'); ?> 5--INI-- 6phar.readonly=1 7phar.require_hash=0 8--FILE-- 9<?php 10ini_set('phar.require_hash', 1); 11include __DIR__ . '/files/tarmaker.php.inc'; 12$fname = __DIR__ . '/require_hash.phar.tar'; 13$alias = 'phar://' . $fname; 14$fname2 = __DIR__ . '/require_hash.tar'; 15 16$tar = new tarmaker($fname, 'none'); 17$tar->init(); 18$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);'); 19$tar->addFile('internal/file/here', "hi there!\n"); 20$tar->addFile('.phar/stub.php', "__HALT_COMPILER();"); 21$tar->close(); 22 23try { 24 $phar = new Phar($fname); 25 var_dump($phar->getStub()); 26} catch (Exception $e) { 27 echo $e->getMessage()."\n"; 28} 29ini_set('phar.require_hash', 0); 30try { 31 $phar = new PharData($fname2); 32 $phar['file'] = 'hi'; 33 var_dump($phar->getSignature()); 34 $phar->setSignatureAlgorithm(Phar::MD5); 35 var_dump($phar->getSignature()); 36} catch (Exception $e) { 37 echo $e->getMessage()."\n"; 38} 39 40?> 41--CLEAN-- 42<?php 43@unlink(__DIR__ . '/require_hash.phar.tar'); 44@unlink(__DIR__ . '/require_hash.tar'); 45?> 46--EXPECTF-- 47tar-based phar "%srequire_hash.phar.tar" does not have a signature 48bool(false) 49array(2) { 50 ["hash"]=> 51 string(32) "%s" 52 ["hash_type"]=> 53 string(3) "MD5" 54} 55