]> granicus.if.org Git - php/commitdiff
Added test case for bug #24658
authorMoriyoshi Koizumi <moriyoshi@php.net>
Thu, 17 Jul 2003 18:50:56 +0000 (18:50 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Thu, 17 Jul 2003 18:50:56 +0000 (18:50 +0000)
tests/lang/bug24658.phpt [new file with mode: 0644]

diff --git a/tests/lang/bug24658.phpt b/tests/lang/bug24658.phpt
new file mode 100644 (file)
index 0000000..ff4d7ca
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+Bug #24658 (combo of typehint / reference causes crash)
+--FILE--
+<?php
+class foo {}
+function no_typehint($a) {
+       var_dump($a);
+}
+function typehint(foo $a) {
+       var_dump($a);
+}
+function no_typehint_ref(&$a) {
+       var_dump($a);
+}
+function typehint_ref(foo &$a) {
+       var_dump($a);
+}
+$v = new foo();
+$a = array(new foo(), 1, 2);
+no_typehint($v);
+typehint($v);
+no_typehint_ref($v);
+typehint_ref($v);
+array_walk($a, 'no_typehint');
+array_walk($a, 'no_typehint_ref');
+array_walk($a, 'typehint');
+array_walk($a, 'typehint_ref');
+?>
+--EXPECTF--
+object(foo)#%d (0) {
+}
+object(foo)#%d (0) {
+}
+object(foo)#%d (0) {
+}
+object(foo)#%d (0) {
+}
+object(foo)#%d (0) {
+}
+int(1)
+int(2)
+object(foo)#%d (0) {
+}
+int(1)
+int(2)
+
+Fatal error: Argument 1 must be an instance of foo in %s on line %d