xref: /PHP-7.4/ext/phar/tests/phar_oo_006.phpt (revision 26dfce7f)
1--TEST--
2Phar object: array access
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($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 (UnexpectedValueException $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===DONE===
38--CLEAN--
39<?php
40unlink(__DIR__ . '/files/phar_oo_006.phar.php');
41__halt_compiler();
42?>
43--EXPECTF--
44SplFileInfo::setFileClass() expects parameter 1 to be a class name derived from SplFileObject, 'SplFileInfo' given
45MyFile::__construct(phar://%s/a.php)
46a.php
47MyFile::__construct(phar://%s/b/c.php)
48c.php
49MyFile::__construct(phar://%s/b.php)
50b.php
51===DONE===
52