xref: /PHP-8.1/ext/phar/tests/phar_oo_007.phpt (revision 74859783)
1--TEST--
2Phar object: access through SplFileObject
3--EXTENSIONS--
4phar
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--CLEAN--
59<?php
60unlink(__DIR__ . '/files/phar_oo_007.phar.php');
61__halt_compiler();
62?>
63--EXPECTF--
64MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php)
65int(%d)
66int(%d)
67int(%d)
68int(0)
69bool(false)
70string(32) "<?php echo "This is a.php\n"; ?>"
71bool(true)
72int(0)
73int(20)
74string(12) "a.php\n"; ?>"
75NULL
76int(0)
77string(32) "<?php echo "This is a.php\n"; ?>"
78int(32)
79===AGAIN===
80MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php)
81int(0)
82bool(false)
83string(32) "<?php echo "This is a.php\n"; ?>"
84bool(true)
85