summaryrefslogtreecommitdiff
path: root/ext/opcache/tests/invalid_new_dce.phpt
blob: c029a49bdc8b9d476effa0ffba06491e95e35e96 (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
--TEST--
Throwings NEWs should not be DCEd
--INI--
opcache.enable_cli=1
opcache.optimization_level=-1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php

abstract class Foo {}
interface Bar {}
trait Baz {}

class Abc {
    const BAR = Abc::BAR;
}

function test1() {
    $x = new Foo;
}
function test2() {
    $x = new Bar;
}
function test3() {
    $x = new Baz;
}
function test4() {
    $x = new Abc;
}

try { test1(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
try { test2(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
try { test3(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
try { test4(); } catch (Error $e) { echo $e->getMessage(), "\n"; }

?>
--EXPECT--
Cannot instantiate abstract class Foo
Cannot instantiate interface Bar
Cannot instantiate trait Baz
Cannot declare self-referencing constant 'Abc::BAR'