xref: /PHP-8.2/Zend/tests/enum/enum_exists.phpt (revision 269c8dac)
1--TEST--
2enum_exists
3--FILE--
4<?php
5
6enum Foo {
7    case Bar;
8}
9
10class Baz {}
11
12spl_autoload_register(function ($className) {
13    echo "Triggered autoloader with class $className\n";
14
15    if ($className === 'Quux') {
16        enum Quux {}
17    }
18});
19
20var_dump(enum_exists(Foo::class));
21var_dump(enum_exists(Foo::Bar::class));
22var_dump(enum_exists(Baz::class));
23var_dump(enum_exists(Qux::class));
24var_dump(enum_exists(Quux::class, false));
25var_dump(enum_exists(Quux::class, true));
26var_dump(enum_exists(Quuz::class, false));
27var_dump(enum_exists(Quuz::class, true));
28
29?>
30--EXPECT--
31bool(true)
32bool(true)
33bool(false)
34Triggered autoloader with class Qux
35bool(false)
36bool(false)
37Triggered autoloader with class Quux
38bool(true)
39bool(false)
40Triggered autoloader with class Quuz
41bool(false)
42