| Volodymyr Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | class 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 Panivko | 0564434 | 2026-03-07 14:16:50 +0100 | [diff] [blame] | 45 | public function testUuid($thing) |
| 46 | { |
| 47 | return $thing; |
| 48 | } |
| 49 | |
| Volodymyr Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 50 | 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 Panivko | 76113eb | 2026-03-26 21:57:29 +0100 | [diff] [blame] | 92 | 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 Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | public function testInsanity(\ThriftTest\Insanity $argument) |
| 109 | { |
| Volodymyr Panivko | 76113eb | 2026-03-26 21:57:29 +0100 | [diff] [blame] | 110 | $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 Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | public function testMulti($arg0, $arg1, $arg2, array $arg3, $arg4, $arg5) |
| 124 | { |
| Volodymyr Panivko | 76113eb | 2026-03-26 21:57:29 +0100 | [diff] [blame] | 125 | $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 Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | public function testException($arg) |
| 135 | { |
| Volodymyr Panivko | 76113eb | 2026-03-26 21:57:29 +0100 | [diff] [blame] | 136 | 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 Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | public function testMultiException($arg0, $arg1) |
| 149 | { |
| Volodymyr Panivko | 76113eb | 2026-03-26 21:57:29 +0100 | [diff] [blame] | 150 | 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 Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | public function testOneway($secondsToSleep) |
| 172 | { |
| Volodymyr Panivko | 96f1e3f | 2026-03-26 23:25:37 +0100 | [diff] [blame] | 173 | // Keep the oneway test quick so the cross-test matrix measures fire-and-forget behavior, |
| 174 | // not a full second of handler blocking in the single-threaded PHP test server. |
| Volodymyr Panivko | 76113eb | 2026-03-26 21:57:29 +0100 | [diff] [blame] | 175 | usleep($secondsToSleep * 300000); |
| Volodymyr Panivko | 68139d1 | 2024-03-19 23:14:07 +0100 | [diff] [blame] | 176 | } |
| 177 | } |