xref: /php-src/ext/phar/tests/phar_oo_006.phpt (revision 74859783)
1--TEST--
2Phar object: array access
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($what)
15    {
16        echo __METHOD__ . "($what)\n";
17        parent::__construct($what);
18    }
19}
20
21$phar = new Phar($fname);
22try
23{
24    $phar->setFileClass('SplFileInfo');
25}
26catch (TypeError $e)
27{
28    echo $e->getMessage() . "\n";
29}
30$phar->setInfoClass('MyFile');
31
32echo $phar['a.php']->getFilename() . "\n";
33echo $phar['b/c.php']->getFilename() . "\n";
34echo $phar['b.php']->getFilename() . "\n";
35
36?>
37--CLEAN--
38<?php
39unlink(__DIR__ . '/files/phar_oo_006.phar.php');
40__halt_compiler();
41?>
42--EXPECTF--
43SplFileInfo::setFileClass(): Argument #1 ($class) must be a class name derived from SplFileObject, SplFileInfo given
44MyFile::__construct(phar://%s/a.php)
45a.php
46MyFile::__construct(phar://%s/b/c.php)
47c.php
48MyFile::__construct(phar://%s/b.php)
49b.php
50