Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit 203219a

Browse files
committed
CS cleanup of JSON-compliant support
- CS cleanup -- imports, docblocks, etc. - Ensured that AMF server also supports new Server interface features
1 parent 8f5eab8 commit 203219a

File tree

2 files changed

+55
-78
lines changed

2 files changed

+55
-78
lines changed

src/Client.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,21 @@
2323
* @namespace
2424
*/
2525
namespace Zend\XmlRpc;
26+
2627
use Zend\Http,
27-
Zend\Server\Client as ClientInterface,
28+
Zend\Server\Client as ServerClient,
2829
Zend\XmlRpc\Value;
2930

3031
/**
3132
* An XML-RPC client implementation
3233
*
33-
* @uses Zend\Http\Client
34-
* @uses Zend\XmlRpc\Client\FaultException
35-
* @uses Zend\XmlRpc\Client\HttpException
36-
* @uses Zend\XmlRpc\Client\ServerIntrospection
37-
* @uses Zend\XmlRpc\Client\ServerProxy
38-
* @uses Zend\XmlRpc\Fault
39-
* @uses Zend\XmlRpc\Request
40-
* @uses Zend\XmlRpc\Response
41-
* @uses Zend\XmlRpc\Value
4234
* @category Zend
4335
* @package Zend_XmlRpc
4436
* @subpackage Client
4537
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
4638
* @license http://framework.zend.com/license/new-bsd New BSD License
4739
*/
48-
class Client implements ClientInterface
40+
class Client implements ServerClient
4941
{
5042
/**
5143
* Full address of the XML-RPC service

src/Server.php

Lines changed: 52 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
* @license http://framework.zend.com/license/new-bsd New BSD License
2020
*/
2121

22-
/**
23-
* @namespace
24-
*/
2522
namespace Zend\XmlRpc;
26-
use Zend\Server\AbstractServer,
23+
24+
use ReflectionClass,
25+
Zend\Server\AbstractServer,
2726
Zend\Server\Definition,
2827
Zend\Server\Reflection;
2928

@@ -58,20 +57,6 @@
5857
* echo $response;
5958
* </code>
6059
*
61-
* @uses ReflectionClass
62-
* @uses Zend\Server\AbstractServer
63-
* @uses Zend\Server\Definition
64-
* @uses Zend\Server\Reflection
65-
* @uses Zend\Server\Reflection\AbstractFunction
66-
* @uses Zend\Server\Reflection\ReflectionMethod
67-
* @uses Zend\XmlRpc\Request
68-
* @uses Zend\XmlRpc\Request\Http
69-
* @uses Zend\XmlRpc\Response
70-
* @uses Zend\XmlRpc\Response\Http
71-
* @uses Zend\XmlRpc\Server\Exception
72-
* @uses Zend\XmlRpc\Server\Fault
73-
* @uses Zend\XmlRpc\Server\System
74-
* @uses Zend\XmlRpc\Value
7560
* @category Zend
7661
* @package Zend_XmlRpc
7762
* @subpackage Server
@@ -84,25 +69,25 @@ class Server extends AbstractServer
8469
* Character encoding
8570
* @var string
8671
*/
87-
protected $_encoding = 'UTF-8';
72+
protected $encoding = 'UTF-8';
8873

8974
/**
9075
* Request processed
91-
* @var null|\Zend\XmlRpc\Request
76+
* @var null|Request
9277
*/
93-
protected $_request = null;
78+
protected $request = null;
9479

9580
/**
96-
* Class to use for responses; defaults to {@link Zend\XmlRpc\Response\Http}
81+
* Class to use for responses; defaults to {@link Response\Http}
9782
* @var string
9883
*/
99-
protected $_responseClass = 'Zend\\XmlRpc\\Response\\Http';
84+
protected $responseClass = 'Zend\XmlRpc\Response\Http';
10085

10186
/**
10287
* Dispatch table of name => method pairs
103-
* @var \Zend\Server\Definition
88+
* @var Definition
10489
*/
105-
protected $_table;
90+
protected $table;
10691

10792
/**
10893
* PHP types => XML-RPC types
@@ -112,7 +97,7 @@ class Server extends AbstractServer
11297
'i4' => 'i4',
11398
'int' => 'int',
11499
'integer' => 'int',
115-
'Zend_Crypt_Math_BigInteger' => 'i8',
100+
'Zend\Crypt\Math\BigInteger' => 'i8',
116101
'i8' => 'i8',
117102
'ex:i8' => 'i8',
118103
'double' => 'double',
@@ -145,7 +130,7 @@ class Server extends AbstractServer
145130
*
146131
* @var bool
147132
*/
148-
protected $_sendArgumentsToAllMethods = true;
133+
protected $sendArgumentsToAllMethods = true;
149134

150135
/**
151136
* Flag: whether or not {@link handle()} should return a response instead
@@ -156,7 +141,7 @@ class Server extends AbstractServer
156141

157142
/**
158143
* Last response results.
159-
* @var \Zend\XmlRpc\Response
144+
* @var Response
160145
*/
161146
protected $response;
162147

@@ -169,8 +154,8 @@ class Server extends AbstractServer
169154
*/
170155
public function __construct()
171156
{
172-
$this->_table = new Definition();
173-
$this->_registerSystemMethods();
157+
$this->table = new Definition();
158+
$this->registerSystemMethods();
174159
}
175160

176161
/**
@@ -291,7 +276,7 @@ public function fault($fault = null, $code = 404)
291276
* The response is always available via {@link getResponse()}.
292277
*
293278
* @param boolean $flag
294-
* @return \Zend\XmlRpc\Server
279+
* @return Server
295280
*/
296281
public function setReturnResponse($flag = true)
297282
{
@@ -312,8 +297,8 @@ public function getReturnResponse()
312297
/**
313298
* Handle an xmlrpc call
314299
*
315-
* @param Zend\XmlRpc\Request $request Optional
316-
* @return Zend\XmlRpc\Response|Zend\XmlRpc\Fault
300+
* @param Request $request Optional
301+
* @return Response|Fault
317302
*/
318303
public function handle($request = false)
319304
{
@@ -331,7 +316,7 @@ public function handle($request = false)
331316
$response = $request->getFault();
332317
} else {
333318
try {
334-
$response = $this->_handle($request);
319+
$response = $this->handleRequest($request);
335320
} catch (\Exception $e) {
336321
$response = $this->fault($e);
337322
}
@@ -353,11 +338,11 @@ public function handle($request = false)
353338
* Load methods as returned from {@link getFunctions}
354339
*
355340
* Typically, you will not use this method; it will be called using the
356-
* results pulled from {@link Zend_XmlRpc_Server_Cache::get()}.
341+
* results pulled from {@link Zend\XmlRpc\Server\Cache::get()}.
357342
*
358-
* @param array|Zend\Server\Definition $definition
343+
* @param array|Definition $definition
359344
* @return void
360-
* @throws Zend\XmlRpc\Server\Exception on invalid input
345+
* @throws Server\Exception on invalid input
361346
*/
362347
public function loadFunctions($definition)
363348
{
@@ -370,8 +355,8 @@ public function loadFunctions($definition)
370355
throw new Server\Exception\InvalidArgumentException('Unable to load server definition; must be an array or Zend_Server_Definition, received ' . $type, 612);
371356
}
372357

373-
$this->_table->clearMethods();
374-
$this->_registerSystemMethods();
358+
$this->table->clearMethods();
359+
$this->registerSystemMethods();
375360

376361
if ($definition instanceof Definition) {
377362
$definition = $definition->getMethods();
@@ -381,19 +366,19 @@ public function loadFunctions($definition)
381366
if ('system.' == substr($key, 0, 7)) {
382367
continue;
383368
}
384-
$this->_table->addMethod($method, $key);
369+
$this->table->addMethod($method, $key);
385370
}
386371
}
387372

388373
/**
389374
* Set encoding
390375
*
391-
* @param string $encoding
392-
* @return Zend\XmlRpc\Server
376+
* @param string $encoding
377+
* @return Server
393378
*/
394379
public function setEncoding($encoding)
395380
{
396-
$this->_encoding = $encoding;
381+
$this->encoding = $encoding;
397382
Value::setEncoding($encoding);
398383
return $this;
399384
}
@@ -405,7 +390,7 @@ public function setEncoding($encoding)
405390
*/
406391
public function getEncoding()
407392
{
408-
return $this->_encoding;
393+
return $this->encoding;
409394
}
410395

411396
/**
@@ -421,9 +406,9 @@ public function setPersistence($mode)
421406
/**
422407
* Set the request object
423408
*
424-
* @param string|Zend\XmlRpc\Request $request
425-
* @return Zend\XmlRpc\Server
426-
* @throws Zend\XmlRpc\Server\Exception on invalid request class or object
409+
* @param string|Request $request
410+
* @return Server
411+
* @throws Server\Exception on invalid request class or object
427412
*/
428413
public function setRequest($request)
429414
{
@@ -437,24 +422,24 @@ public function setRequest($request)
437422
throw new Server\Exception\InvalidArgumentException('Invalid request object');
438423
}
439424

440-
$this->_request = $request;
425+
$this->request = $request;
441426
return $this;
442427
}
443428

444429
/**
445430
* Return currently registered request object
446431
*
447-
* @return null|Zend\XmlRpc\Request
432+
* @return null|Request
448433
*/
449434
public function getRequest()
450435
{
451-
return $this->_request;
436+
return $this->request;
452437
}
453438

454439
/**
455440
* Last response.
456441
*
457-
* @return \Zend\XmlRpc\Response
442+
* @return Response
458443
*/
459444
public function getResponse()
460445
{
@@ -464,17 +449,17 @@ public function getResponse()
464449
/**
465450
* Set the class to use for the response
466451
*
467-
* @param string $class
452+
* @param string $class
468453
* @return boolean True if class was set, false if not
469454
*/
470455
public function setResponseClass($class)
471456
{
472457
if (!class_exists($class) or
473-
($c = new \ReflectionClass($class) and !$c->isSubclassOf('Zend\\XmlRpc\\Response'))) {
458+
($c = new ReflectionClass($class) and !$c->isSubclassOf('Zend\\XmlRpc\\Response'))) {
474459

475460
throw new Server\Exception\InvalidArgumentException('Invalid response class');
476461
}
477-
$this->_responseClass = $class;
462+
$this->responseClass = $class;
478463
return true;
479464
}
480465

@@ -485,7 +470,7 @@ public function setResponseClass($class)
485470
*/
486471
public function getResponseClass()
487472
{
488-
return $this->_responseClass;
473+
return $this->responseClass;
489474
}
490475

491476
/**
@@ -495,7 +480,7 @@ public function getResponseClass()
495480
*/
496481
public function getDispatchTable()
497482
{
498-
return $this->_table;
483+
return $this->table;
499484
}
500485

501486
/**
@@ -508,13 +493,13 @@ public function getDispatchTable()
508493
*/
509494
public function getFunctions()
510495
{
511-
return $this->_table->toArray();
496+
return $this->table->toArray();
512497
}
513498

514499
/**
515500
* Retrieve system object
516501
*
517-
* @return \Zend\XmlRpc\Server\System
502+
* @return Server\System
518503
*/
519504
public function getSystem()
520505
{
@@ -532,10 +517,10 @@ public function getSystem()
532517
public function sendArgumentsToAllMethods($flag = null)
533518
{
534519
if ($flag === null) {
535-
return $this->_sendArgumentsToAllMethods;
520+
return $this->sendArgumentsToAllMethods;
536521
}
537522

538-
$this->_sendArgumentsToAllMethods = (bool)$flag;
523+
$this->sendArgumentsToAllMethods = (bool)$flag;
539524
return $this;
540525
}
541526

@@ -556,22 +541,22 @@ protected function _fixType($type)
556541
/**
557542
* Handle an xmlrpc call (actual work)
558543
*
559-
* @param Zend\XmlRpc\Request $request
560-
* @return Zend\XmlRpc\Response
561-
* @throws Zend\XmlRpc\Server\Exception|Exception
544+
* @param Request $request
545+
* @return Response
546+
* @throws Server\Exception|Exception
562547
* Zend\XmlRpc\Server\Exceptions are thrown for internal errors; otherwise,
563548
* any other exception may be thrown by the callback
564549
*/
565-
protected function _handle(Request $request)
550+
protected function handleRequest(Request $request)
566551
{
567552
$method = $request->getMethod();
568553

569554
// Check for valid method
570-
if (!$this->_table->hasMethod($method)) {
555+
if (!$this->table->hasMethod($method)) {
571556
throw new Server\Exception\RuntimeException('Method "' . $method . '" does not exist', 620);
572557
}
573558

574-
$info = $this->_table->getMethod($method);
559+
$info = $this->table->getMethod($method);
575560
$params = $request->getParams();
576561
$argv = $info->getInvokeArguments();
577562
if (0 < count($argv) and $this->sendArgumentsToAllMethods()) {
@@ -613,7 +598,7 @@ protected function _handle(Request $request)
613598
*
614599
* @return void
615600
*/
616-
protected function _registerSystemMethods()
601+
protected function registerSystemMethods()
617602
{
618603
$system = new Server\System($this);
619604
$this->_system = $system;

0 commit comments

Comments
 (0)