xref: /PHP-8.0/ext/phar/tests/phar_oo_001.phpt (revision f8d79582)
1--TEST--
2Phar object: basics
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.require_hash=0
9phar.readonly=0
10--FILE--
11<?php
12
13require_once 'files/phar_oo_test.inc';
14
15$phar = new Phar($fname);
16var_dump($phar->getVersion());
17var_dump(count($phar));
18
19class MyPhar extends Phar
20{
21    function __construct()
22    {
23    }
24}
25
26try
27{
28    $phar = new MyPhar();
29    var_dump($phar->getVersion());
30}
31catch (LogicException $e)
32{
33    var_dump($e->getMessage());
34}
35try {
36    $phar = new Phar('test.phar');
37    $phar->__construct('oops');
38} catch (LogicException $e)
39{
40    var_dump($e->getMessage());
41}
42
43?>
44--CLEAN--
45<?php
46unlink(__DIR__ . '/files/phar_oo_001.phar.php');
47__halt_compiler();
48?>
49--EXPECT--
50string(5) "1.0.0"
51int(5)
52string(50) "Cannot call method on an uninitialized Phar object"
53string(29) "Cannot call constructor twice"
54