summaryrefslogtreecommitdiff
path: root/Zend/tests/enum/enum-as-params.phpt
blob: 90a1f0b5d07f6889692009a3be2bc81ed335ac5a (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
--TEST--
Enum types as parameters
--FILE--
<?php

enum Foo {
    case Bar;
}

enum Baz {
    case Qux;
}

function takesFoo(Foo $foo) {}
function takesBaz(Baz $baz) {}

takesFoo(Foo::Bar);
takesBaz(Baz::Qux);

try {
    takesBaz(Foo::Bar);
} catch (Error $e) {
    echo $e->getMessage() . "\n";
}

try {
    takesFoo(Baz::Qux);
} catch (Error $e) {
    echo $e->getMessage() . "\n";
}

?>
--EXPECTF--
takesBaz(): Argument #1 ($baz) must be of type Baz, Foo given, called in %s on line %d
takesFoo(): Argument #1 ($foo) must be of type Foo, Baz given, called in %s on line %d