Skip to content

Commit c662baa

Browse files
committed
update from upstream
1 parent 41aa8e1 commit c662baa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+914
-554
lines changed

src/Thrift/Base/TBase.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* of PHP. Note that code is intentionally duplicated in here to avoid making
3232
* function calls for every field or member of a container..
3333
*/
34-
abstract class TBase {
35-
34+
abstract class TBase
35+
{
3636
static $tmethod = array(TType::BOOL => 'Bool',
3737
TType::BYTE => 'Byte',
3838
TType::I16 => 'I16',
@@ -41,11 +41,12 @@ abstract class TBase {
4141
TType::DOUBLE => 'Double',
4242
TType::STRING => 'String');
4343

44-
abstract function read($input);
44+
abstract public function read($input);
4545

46-
abstract function write($output);
46+
abstract public function write($output);
4747

48-
public function __construct($spec=null, $vals=null) {
48+
public function __construct($spec=null, $vals=null)
49+
{
4950
if (is_array($spec) && is_array($vals)) {
5051
foreach ($spec as $fid => $fspec) {
5152
$var = $fspec['var'];
@@ -61,7 +62,8 @@ public function __wakeup()
6162
$this->__construct(get_object_vars($this));
6263
}
6364

64-
private function _readMap(&$var, $spec, $input) {
65+
private function _readMap(&$var, $spec, $input)
66+
{
6567
$xfer = 0;
6668
$ktype = $spec['ktype'];
6769
$vtype = $spec['vtype'];
@@ -124,10 +126,12 @@ private function _readMap(&$var, $spec, $input) {
124126
$var[$key] = $val;
125127
}
126128
$xfer += $input->readMapEnd();
129+
127130
return $xfer;
128131
}
129132

130-
private function _readList(&$var, $spec, $input, $set=false) {
133+
private function _readList(&$var, $spec, $input, $set=false)
134+
{
131135
$xfer = 0;
132136
$etype = $spec['etype'];
133137
$eread = $vread = null;
@@ -177,10 +181,12 @@ private function _readList(&$var, $spec, $input, $set=false) {
177181
} else {
178182
$xfer += $input->readListEnd();
179183
}
184+
180185
return $xfer;
181186
}
182187

183-
protected function _read($class, $spec, $input) {
188+
protected function _read($class, $spec, $input)
189+
{
184190
$xfer = 0;
185191
$fname = null;
186192
$ftype = 0;
@@ -226,10 +232,12 @@ protected function _read($class, $spec, $input) {
226232
$xfer += $input->readFieldEnd();
227233
}
228234
$xfer += $input->readStructEnd();
235+
229236
return $xfer;
230237
}
231238

232-
private function _writeMap($var, $spec, $output) {
239+
private function _writeMap($var, $spec, $output)
240+
{
233241
$xfer = 0;
234242
$ktype = $spec['ktype'];
235243
$vtype = $spec['vtype'];
@@ -284,10 +292,12 @@ private function _writeMap($var, $spec, $output) {
284292
}
285293
}
286294
$xfer += $output->writeMapEnd();
295+
287296
return $xfer;
288297
}
289298

290-
private function _writeList($var, $spec, $output, $set=false) {
299+
private function _writeList($var, $spec, $output, $set=false)
300+
{
291301
$xfer = 0;
292302
$etype = $spec['etype'];
293303
$ewrite = null;
@@ -327,10 +337,12 @@ private function _writeList($var, $spec, $output, $set=false) {
327337
} else {
328338
$xfer += $output->writeListEnd();
329339
}
340+
330341
return $xfer;
331342
}
332343

333-
protected function _write($class, $spec, $output) {
344+
protected function _write($class, $spec, $output)
345+
{
334346
$xfer = 0;
335347
$xfer += $output->writeStructBegin($class);
336348
foreach ($spec as $fid => $fspec) {
@@ -362,6 +374,7 @@ protected function _write($class, $spec, $output) {
362374
}
363375
$xfer += $output->writeFieldStop();
364376
$xfer += $output->writeStructEnd();
377+
365378
return $xfer;
366379
}
367380
}

src/Thrift/ClassLoader/ThriftClassLoader.php

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* under the License.
1919
*
2020
* ClassLoader to load Thrift library and definitions
21-
* Inspired from UniversalClassLoader from Symfony 2
21+
* Inspired from UniversalClassLoader from Symfony 2
2222
*
2323
* @package thrift.classloader
2424
*/
@@ -54,7 +54,7 @@ class ThriftClassLoader
5454
/**
5555
* Set autoloader to use APC cache
5656
* @param boolean $apc
57-
* @param string $apc_prefix
57+
* @param string $apc_prefix
5858
*/
5959
public function __construct($apc = false, $apc_prefix = null)
6060
{
@@ -112,7 +112,7 @@ public function loadClass($class)
112112

113113
/**
114114
* Loads the given class or interface in APC.
115-
* @param string $class The name of the class
115+
* @param string $class The name of the class
116116
* @return string
117117
*/
118118
protected function findFileInApc($class)
@@ -126,42 +126,36 @@ protected function findFileInApc($class)
126126

127127
/**
128128
* Find class in namespaces or definitions directories
129-
* @param string $class
129+
* @param string $class
130130
* @return string
131131
*/
132132
public function findFile($class)
133133
{
134134
// Remove first backslash
135-
if ('\\' == $class[0])
136-
{
135+
if ('\\' == $class[0]) {
137136
$class = substr($class, 1);
138137
}
139138

140-
if (false !== $pos = strrpos($class, '\\'))
141-
{
139+
if (false !== $pos = strrpos($class, '\\')) {
142140
// Namespaced class name
143141
$namespace = substr($class, 0, $pos);
144142

145143
// Iterate in normal namespaces
146-
foreach ($this->namespaces as $ns => $dirs)
147-
{
144+
foreach ($this->namespaces as $ns => $dirs) {
148145
//Don't interfere with other autoloaders
149-
if (0 !== strpos($namespace, $ns))
150-
{
146+
if (0 !== strpos($namespace, $ns)) {
151147
continue;
152148
}
153149

154-
foreach ($dirs as $dir)
155-
{
150+
foreach ($dirs as $dir) {
156151
$className = substr($class, $pos + 1);
157152

158153
$file = $dir.DIRECTORY_SEPARATOR.
159154
str_replace('\\', DIRECTORY_SEPARATOR, $namespace).
160155
DIRECTORY_SEPARATOR.
161156
$className.'.php';
162157

163-
if (file_exists($file))
164-
{
158+
if (file_exists($file)) {
165159
return $file;
166160
}
167161
}
@@ -173,24 +167,20 @@ public function findFile($class)
173167
$m = explode('\\', $class);
174168

175169
// Ignore wrong call
176-
if(count($m) <= 1)
177-
{
170+
if (count($m) <= 1) {
178171
return;
179172
}
180173

181174
$class = array_pop($m);
182175
$namespace = implode('\\', $m);
183176

184-
foreach ($this->definitions as $ns => $dirs)
185-
{
177+
foreach ($this->definitions as $ns => $dirs) {
186178
//Don't interfere with other autoloaders
187-
if (0 !== strpos($namespace, $ns))
188-
{
179+
if (0 !== strpos($namespace, $ns)) {
189180
continue;
190181
}
191182

192-
foreach ($dirs as $dir)
193-
{
183+
foreach ($dirs as $dir) {
194184
/**
195185
* Available in service: Interface, Client, Processor, Rest
196186
* And every service methods (_.+)
@@ -201,9 +191,7 @@ public function findFile($class)
201191
)
202192
{
203193
$className = 'Types';
204-
}
205-
else
206-
{
194+
} else {
207195
$className = $n[1];
208196
}
209197

@@ -212,8 +200,7 @@ public function findFile($class)
212200
DIRECTORY_SEPARATOR .
213201
$className . '.php';
214202

215-
if (file_exists($file))
216-
{
203+
if (file_exists($file)) {
217204
return $file;
218205
}
219206
}

src/Thrift/Exception/TApplicationException.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
namespace Thrift\Exception;
2424

25-
use Thrift\Exception\TException;
2625
use Thrift\Type\TType;
2726

28-
class TApplicationException extends TException {
27+
class TApplicationException extends TException
28+
{
2929
static $_TSPEC =
3030
array(1 => array('var' => 'message',
3131
'type' => TType::STRING),
@@ -44,15 +44,18 @@ class TApplicationException extends TException {
4444
const INVALID_PROTOCOL = 9;
4545
const UNSUPPORTED_CLIENT_TYPE = 10;
4646

47-
function __construct($message=null, $code=0) {
47+
public function __construct($message=null, $code=0)
48+
{
4849
parent::__construct($message, $code);
4950
}
5051

51-
public function read($output) {
52+
public function read($output)
53+
{
5254
return $this->_read('TApplicationException', self::$_TSPEC, $output);
5355
}
5456

55-
public function write($output) {
57+
public function write($output)
58+
{
5659
$xfer = 0;
5760
$xfer += $output->writeStructBegin('TApplicationException');
5861
if ($message = $this->getMessage()) {
@@ -67,6 +70,7 @@ public function write($output) {
6770
}
6871
$xfer += $output->writeFieldStop();
6972
$xfer += $output->writeStructEnd();
73+
7074
return $xfer;
7175
}
7276
}

src/Thrift/Exception/TException.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
* @param mixed $p1 Message (string) or type-spec (array)
3939
* @param mixed $p2 Code (integer) or values (array)
4040
*/
41-
class TException extends \Exception {
42-
function __construct($p1=null, $p2=0) {
41+
class TException extends \Exception
42+
{
43+
public function __construct($p1=null, $p2=0)
44+
{
4345
if (is_array($p1) && is_array($p2)) {
4446
$spec = $p1;
4547
$vals = $p2;
@@ -62,7 +64,8 @@ function __construct($p1=null, $p2=0) {
6264
TType::DOUBLE => 'Double',
6365
TType::STRING => 'String');
6466

65-
private function _readMap(&$var, $spec, $input) {
67+
private function _readMap(&$var, $spec, $input)
68+
{
6669
$xfer = 0;
6770
$ktype = $spec['ktype'];
6871
$vtype = $spec['vtype'];
@@ -125,10 +128,12 @@ private function _readMap(&$var, $spec, $input) {
125128
$var[$key] = $val;
126129
}
127130
$xfer += $input->readMapEnd();
131+
128132
return $xfer;
129133
}
130134

131-
private function _readList(&$var, $spec, $input, $set=false) {
135+
private function _readList(&$var, $spec, $input, $set=false)
136+
{
132137
$xfer = 0;
133138
$etype = $spec['etype'];
134139
$eread = $vread = null;
@@ -178,10 +183,12 @@ private function _readList(&$var, $spec, $input, $set=false) {
178183
} else {
179184
$xfer += $input->readListEnd();
180185
}
186+
181187
return $xfer;
182188
}
183189

184-
protected function _read($class, $spec, $input) {
190+
protected function _read($class, $spec, $input)
191+
{
185192
$xfer = 0;
186193
$fname = null;
187194
$ftype = 0;
@@ -227,10 +234,12 @@ protected function _read($class, $spec, $input) {
227234
$xfer += $input->readFieldEnd();
228235
}
229236
$xfer += $input->readStructEnd();
237+
230238
return $xfer;
231239
}
232240

233-
private function _writeMap($var, $spec, $output) {
241+
private function _writeMap($var, $spec, $output)
242+
{
234243
$xfer = 0;
235244
$ktype = $spec['ktype'];
236245
$vtype = $spec['vtype'];
@@ -285,10 +294,12 @@ private function _writeMap($var, $spec, $output) {
285294
}
286295
}
287296
$xfer += $output->writeMapEnd();
297+
288298
return $xfer;
289299
}
290300

291-
private function _writeList($var, $spec, $output, $set=false) {
301+
private function _writeList($var, $spec, $output, $set=false)
302+
{
292303
$xfer = 0;
293304
$etype = $spec['etype'];
294305
$ewrite = null;
@@ -328,10 +339,12 @@ private function _writeList($var, $spec, $output, $set=false) {
328339
} else {
329340
$xfer += $output->writeListEnd();
330341
}
342+
331343
return $xfer;
332344
}
333345

334-
protected function _write($class, $spec, $output) {
346+
protected function _write($class, $spec, $output)
347+
{
335348
$xfer = 0;
336349
$xfer += $output->writeStructBegin($class);
337350
foreach ($spec as $fid => $fspec) {
@@ -363,6 +376,7 @@ protected function _write($class, $spec, $output) {
363376
}
364377
$xfer += $output->writeFieldStop();
365378
$xfer += $output->writeStructEnd();
379+
366380
return $xfer;
367381
}
368382

0 commit comments

Comments
 (0)