xref: /PHP-7.0/ext/phar/tests/phar_oo_006.phpt (revision 14d53417)
1--TEST--
2Phar object: array access
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
6--INI--
7phar.require_hash=0
8--FILE--
9<?php
10
11require_once 'files/phar_oo_test.inc';
12
13class MyFile extends SplFileObject
14{
15	function __construct($what)
16	{
17		echo __METHOD__ . "($what)\n";
18		parent::__construct($what);
19	}
20}
21
22$phar = new Phar($fname);
23try
24{
25	$phar->setFileClass('SplFileInfo');
26}
27catch (UnexpectedValueException $e)
28{
29	echo $e->getMessage() . "\n";
30}
31$phar->setInfoClass('MyFile');
32
33echo $phar['a.php']->getFilename() . "\n";
34echo $phar['b/c.php']->getFilename() . "\n";
35echo $phar['b.php']->getFilename() . "\n";
36
37?>
38===DONE===
39--CLEAN--
40<?php
41unlink(dirname(__FILE__) . '/files/phar_oo_006.phar.php');
42__halt_compiler();
43?>
44--EXPECTF--
45SplFileInfo::setFileClass() expects parameter 1 to be a class name derived from SplFileObject, 'SplFileInfo' given
46MyFile::__construct(phar://%s/a.php)
47a.php
48MyFile::__construct(phar://%s/b/c.php)
49c.php
50MyFile::__construct(phar://%s/b.php)
51b.php
52===DONE===
53