xref: /PHP-7.4/ext/phar/tests/phar_oo_007.phpt (revision 26dfce7f)
1--TEST--
2Phar object: access through SplFileObject
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7--FILE--
8<?php
9
10require_once 'files/phar_oo_test.inc';
11
12class MyFile extends SplFileObject
13{
14	function __construct($name)
15	{
16		echo __METHOD__ . "(" . str_replace(str_replace('\\', '/', __DIR__), '*', $name) . ")\n";
17		parent::__construct($name);
18	}
19}
20
21$phar = new Phar($fname);
22$phar->setInfoClass('MyFile');
23
24$f = $phar['a.php'];
25
26$s = $f->fstat();
27
28var_dump($s['atime']);
29var_dump($s['ctime']);
30var_dump($s['mtime']);
31
32var_dump($f->ftell());
33var_dump($f->eof());
34var_dump($f->fgets());
35var_dump($f->eof());
36var_dump($f->fseek(20));
37var_dump($f->ftell());
38var_dump($f->fgets());
39var_dump($f->rewind());
40var_dump($f->ftell());
41var_dump($f->fgets());
42var_dump($f->ftell());
43
44?>
45===AGAIN===
46<?php
47
48$f = $phar['a.php'];
49
50var_dump($f->ftell());
51var_dump($f->eof());
52var_dump($f->fgets());
53var_dump($f->eof());
54
55//unset($f); without unset we check for working refcounting
56
57?>
58===DONE===
59--CLEAN--
60<?php
61unlink(__DIR__ . '/files/phar_oo_007.phar.php');
62__halt_compiler();
63?>
64--EXPECTF--
65MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php)
66int(%d)
67int(%d)
68int(%d)
69int(0)
70bool(false)
71string(32) "<?php echo "This is a.php\n"; ?>"
72bool(true)
73int(0)
74int(20)
75string(12) "a.php\n"; ?>"
76NULL
77int(0)
78string(32) "<?php echo "This is a.php\n"; ?>"
79int(32)
80===AGAIN===
81MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php)
82int(0)
83bool(false)
84string(32) "<?php echo "This is a.php\n"; ?>"
85bool(true)
86===DONE===
87