1--TEST-- 2Phar::buildFromIterator() iterator, 1 file passed in 3--EXTENSIONS-- 4phar 5--INI-- 6phar.require_hash=0 7phar.readonly=0 8--FILE-- 9<?php 10class myIterator implements Iterator 11{ 12 var $a; 13 function __construct(array $a) 14 { 15 $this->a = $a; 16 } 17 function next(): void { 18 echo "next\n"; 19 next($this->a); 20 } 21 function current(): mixed { 22 echo "current\n"; 23 return current($this->a); 24 } 25 function key(): mixed { 26 echo "key\n"; 27 return key($this->a); 28 } 29 function valid(): bool { 30 echo "valid\n"; 31 return current($this->a); 32 } 33 function rewind(): void { 34 echo "rewind\n"; 35 reset($this->a); 36 } 37} 38try { 39 chdir(__DIR__); 40 $phar = new Phar(__DIR__ . '/buildfromiterator4.phar'); 41 var_dump($phar->buildFromIterator(new myIterator( 42 array( 43 'a' => basename(__FILE__, 'php') . 'phpt', 44 // demonstrate that none of these are added 45 '.phar/stub.php' => basename(__FILE__, 'php') . 'phpt', 46 '.phar/alias.txt' => basename(__FILE__, 'php') . 'phpt', 47 '.phar/oops' => basename(__FILE__, 'php') . 'phpt', 48 )))); 49} catch (Exception $e) { 50 var_dump(get_class($e)); 51 echo $e->getMessage() . "\n"; 52} 53?> 54--CLEAN-- 55<?php 56unlink(__DIR__ . '/buildfromiterator4.phar'); 57__HALT_COMPILER(); 58?> 59--EXPECTF-- 60rewind 61valid 62current 63key 64next 65valid 66current 67key 68next 69valid 70current 71key 72next 73valid 74current 75key 76next 77valid 78array(1) { 79 ["a"]=> 80 string(%d) "%sphar_buildfromiterator4.phpt" 81} 82