summaryrefslogtreecommitdiff
path: root/Zend/tests/enum/enum-as-params.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests/enum/enum-as-params.phpt')
-rw-r--r--Zend/tests/enum/enum-as-params.phpt35
1 files changed, 35 insertions, 0 deletions
diff --git a/Zend/tests/enum/enum-as-params.phpt b/Zend/tests/enum/enum-as-params.phpt
new file mode 100644
index 0000000000..90a1f0b5d0
--- /dev/null
+++ b/Zend/tests/enum/enum-as-params.phpt
@@ -0,0 +1,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