summaryrefslogtreecommitdiff
path: root/ext/phar/tests/phar_oo_006.phpt
blob: c050859b864bad914c11ceb6093276812f8bc57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
Phar object: array access
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
phar.require_hash=0
--FILE--
<?php

require_once 'files/phar_oo_test.inc';

class MyFile extends SplFileObject
{
    function __construct($what)
    {
        echo __METHOD__ . "($what)\n";
        parent::__construct($what);
    }
}

$phar = new Phar($fname);
try
{
    $phar->setFileClass('SplFileInfo');
}
catch (TypeError $e)
{
    echo $e->getMessage() . "\n";
}
$phar->setInfoClass('MyFile');

echo $phar['a.php']->getFilename() . "\n";
echo $phar['b/c.php']->getFilename() . "\n";
echo $phar['b.php']->getFilename() . "\n";

?>
--CLEAN--
<?php
unlink(__DIR__ . '/files/phar_oo_006.phar.php');
__halt_compiler();
?>
--EXPECTF--
SplFileInfo::setFileClass(): Argument #1 ($class_name) must be a class name derived from SplFileObject, 'SplFileInfo' given
MyFile::__construct(phar://%s/a.php)
a.php
MyFile::__construct(phar://%s/b/c.php)
c.php
MyFile::__construct(phar://%s/b.php)
b.php