blob: a03554c48540eff33bbb64830d5e51d8706e0c79 [file] [log] [blame]
Volodymyr Panivko68139d12024-03-19 23:14:07 +01001<?php
2
3class Handler implements \ThriftTest\ThriftTestIf
4{
5 public function testVoid()
6 {
7 return;
8 }
9
10 public function testString($thing)
11 {
12 return $thing;
13 }
14
15 public function testBool($thing)
16 {
17 return $thing;
18 }
19
20 public function testByte($thing)
21 {
22 return $thing;
23 }
24
25 public function testI32($thing)
26 {
27 return $thing;
28 }
29
30 public function testI64($thing)
31 {
32 return $thing;
33 }
34
35 public function testDouble($thing)
36 {
37 return $thing;
38 }
39
40 public function testBinary($thing)
41 {
42 return $thing;
43 }
44
Volodymyr Panivko05644342026-03-07 14:16:50 +010045 public function testUuid($thing)
46 {
47 return $thing;
48 }
49
Volodymyr Panivko68139d12024-03-19 23:14:07 +010050 public function testStruct(\ThriftTest\Xtruct $thing)
51 {
52 return $thing;
53 }
54
55 public function testNest(\ThriftTest\Xtruct2 $thing)
56 {
57 return $thing;
58 }
59
60 public function testMap(array $thing)
61 {
62 return $thing;
63 }
64
65 public function testStringMap(array $thing)
66 {
67 return $thing;
68 }
69
70 public function testSet(array $thing)
71 {
72 return $thing;
73 }
74
75 public function testList(array $thing)
76 {
77 return $thing;
78 }
79
80 public function testEnum($thing)
81 {
82 return $thing;
83 }
84
85 public function testTypedef($thing)
86 {
87 return $thing;
88 }
89
90 public function testMapMap($hello)
91 {
Volodymyr Panivko76113eb2026-03-26 21:57:29 +010092 return [
93 -4 => [
94 -4 => -4,
95 -3 => -3,
96 -2 => -2,
97 -1 => -1,
98 ],
99 4 => [
100 4 => 4,
101 3 => 3,
102 2 => 2,
103 1 => 1,
104 ],
105 ];
Volodymyr Panivko68139d12024-03-19 23:14:07 +0100106 }
107
108 public function testInsanity(\ThriftTest\Insanity $argument)
109 {
Volodymyr Panivko76113eb2026-03-26 21:57:29 +0100110 $looney = new \ThriftTest\Insanity();
111
112 return [
113 1 => [
114 \ThriftTest\Numberz::TWO => $argument,
115 \ThriftTest\Numberz::THREE => $argument,
116 ],
117 2 => [
118 \ThriftTest\Numberz::SIX => $looney,
119 ],
120 ];
Volodymyr Panivko68139d12024-03-19 23:14:07 +0100121 }
122
123 public function testMulti($arg0, $arg1, $arg2, array $arg3, $arg4, $arg5)
124 {
Volodymyr Panivko76113eb2026-03-26 21:57:29 +0100125 $result = new \ThriftTest\Xtruct();
126 $result->string_thing = 'Hello2';
127 $result->byte_thing = $arg0;
128 $result->i32_thing = $arg1;
129 $result->i64_thing = $arg2;
130
131 return $result;
Volodymyr Panivko68139d12024-03-19 23:14:07 +0100132 }
133
134 public function testException($arg)
135 {
Volodymyr Panivko76113eb2026-03-26 21:57:29 +0100136 if ($arg === 'Xception') {
137 $exception = new \ThriftTest\Xception();
138 $exception->errorCode = 1001;
139 $exception->message = $arg;
140 throw $exception;
141 }
142
143 if ($arg === 'TException') {
144 throw new \Thrift\Exception\TException('This is a TException');
145 }
Volodymyr Panivko68139d12024-03-19 23:14:07 +0100146 }
147
148 public function testMultiException($arg0, $arg1)
149 {
Volodymyr Panivko76113eb2026-03-26 21:57:29 +0100150 if ($arg0 === 'Xception') {
151 $exception = new \ThriftTest\Xception();
152 $exception->errorCode = 1001;
153 $exception->message = 'This is an Xception';
154 throw $exception;
155 }
156
157 if ($arg0 === 'Xception2') {
158 $exception = new \ThriftTest\Xception2();
159 $exception->errorCode = 2002;
160 $exception->struct_thing = new \ThriftTest\Xtruct();
161 $exception->struct_thing->string_thing = 'This is an Xception2';
162 throw $exception;
163 }
164
165 $result = new \ThriftTest\Xtruct();
166 $result->string_thing = $arg1;
167
168 return $result;
Volodymyr Panivko68139d12024-03-19 23:14:07 +0100169 }
170
171 public function testOneway($secondsToSleep)
172 {
Volodymyr Panivko76113eb2026-03-26 21:57:29 +0100173 usleep($secondsToSleep * 300000);
Volodymyr Panivko68139d12024-03-19 23:14:07 +0100174 }
175}