Disallow declarations outside of the global scope.
[hiphop-php.git] / hphp / test / slow / inout / interp-callm / tests / call-static.php
blobc7f50b2d3646f2afe6b9c6246bd76515986bd5f7
1 <?hh /* @generated by make_suite.sh */
3 function foo($x, inout $y, $z, inout $q, $r, inout $s) {
4 var_dump($x, $y, $z, $q, $r, $s);
5 $y = 'Hello';
6 $q = ', ';
7 $s = 'World';
8 return '!';
11 function bar(inout $a) {
12 try {
13 echo "bar($a)\n";
14 throw new Exception();
15 } catch (Exception $e) {
16 try {
17 return $a++;
18 } finally {
19 echo "inner finally\n";
20 var_dump($e->getTrace()[0]['function']);
22 } finally {
23 echo "outer finally\n";
27 function baz($x, inout $a) {
28 echo "baz($x, $a)\n";
29 $a = $x;
30 if ($x === 42) throw new Exception();
31 return $x + 1;
34 function swap(inout $a, inout $b) {
35 $t = $b;
36 $b = $a;
37 $a = $t;
38 // implicit return
41 function empty_(inout $t) {
42 try {
43 new stdclass;
44 return;
45 } finally {
46 echo "empty_ finally\n";
50 function main() {
51 $one = 'Eat';
52 $two = ' my ';
53 $three = 'shorts';
54 $four = foo('apple', inout $one, 'orange', inout $two, $two, inout $three);
55 echo "$one$two$three$four\n";
57 $v = 42;
58 var_dump(bar(inout $v), bar(inout $v), $v, bar(inout $v), $v);
60 $q = 41;
61 try {
62 baz(baz($q, inout $q), inout $q);
63 } catch (Exception $e) {
64 var_dump(array_map($a ==> $a['function'], array_slice($e->getTrace(),0,2)));
65 var_dump($q);
68 $a = 'alpha';
69 $b = 'omega';
70 empty_(inout $a);
71 empty_(inout $b);
72 swap(inout $a, inout $b);
73 echo "$a $b\n";
76 main();