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

Commit

Permalink
Merge branch 'feature/php-short-array-syntax'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Jun 5, 2015
2 parents e459bcd + 54014df commit 4c56b82
Show file tree
Hide file tree
Showing 22 changed files with 234 additions and 233 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $config->fixers(
'object_operator',
'php_closing_tag',
'remove_lines_between_uses',
'short_array_syntax',
'short_tag',
'standardize_not_equal',
'trailing_spaces',
Expand Down
8 changes: 4 additions & 4 deletions src/AbstractValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ protected static function _xmlStringToNativeXmlRpc($xml)
. ' type: ARRAY tag must contain DATA tag'
);
}
$values = array();
$values = [];
// Parse all the elements of the array from the XML string
// (simple xml element) to Value objects
foreach ($data->value as $element) {
Expand All @@ -386,7 +386,7 @@ protected static function _xmlStringToNativeXmlRpc($xml)
$xmlrpcValue = new Value\ArrayValue($values);
break;
case self::XMLRPC_TYPE_STRUCT:
$values = array();
$values = [];
// Parse all the members of the struct from the XML string
// (simple xml element) to Value objects
foreach ($value->member as $member) {
Expand Down Expand Up @@ -442,7 +442,7 @@ protected static function _extractTypeAndValue(\SimpleXMLElement $xml, &$type, &
$xmlAsArray = (array) $xml;
list($type, $value) = each($xmlAsArray);
if (!$type and $value === null) {
$namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions');
$namespaces = ['ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions'];
foreach ($namespaces as $namespaceName => $namespaceUri) {
$namespaceXml = $xml->children($namespaceUri);
list($type, $value) = each($namespaceXml);
Expand All @@ -457,7 +457,7 @@ protected static function _extractTypeAndValue(\SimpleXMLElement $xml, &$type, &
if (!$type) {
$type = self::XMLRPC_TYPE_STRING;
if (empty($value) and preg_match('#^<value>.*</value>$#', $xml->asXML())) {
$value = str_replace(array('<value>', '</value>'), '', $xml->asXML());
$value = str_replace(['<value>', '</value>'], '', $xml->asXML());
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Client implements ServerClient
* Proxy object for more convenient method calls
* @var array of Zend\XmlRpc\Client\ServerProxy
*/
protected $proxyCache = array();
protected $proxyCache = [];

/**
* Flag for skipping system lookup
Expand Down Expand Up @@ -205,10 +205,10 @@ public function doRequest($request, $response = null)
}

$headers = $httpRequest->getHeaders();
$headers->addHeaders(array(
$headers->addHeaders([
'Content-Type: text/xml; charset=utf-8',
'Accept: text/xml',
));
]);

if (!$headers->get('user-agent')) {
$headers->addHeaderLine('user-agent', 'Zend_XmlRpc_Client');
Expand Down Expand Up @@ -244,7 +244,7 @@ public function doRequest($request, $response = null)
* @return mixed
* @throws \Zend\XmlRpc\Client\Exception\FaultException
*/
public function call($method, $params = array())
public function call($method, $params = [])
{
if (!$this->skipSystemLookup() && ('system.' != substr($method, 0, 7))) {
// Ensure empty array/struct params are cast correctly
Expand All @@ -256,7 +256,7 @@ public function call($method, $params = array())
$success = false;
}
if ($success) {
$validTypes = array(
$validTypes = [
AbstractValue::XMLRPC_TYPE_ARRAY,
AbstractValue::XMLRPC_TYPE_BASE64,
AbstractValue::XMLRPC_TYPE_BOOLEAN,
Expand All @@ -267,10 +267,10 @@ public function call($method, $params = array())
AbstractValue::XMLRPC_TYPE_NIL,
AbstractValue::XMLRPC_TYPE_STRING,
AbstractValue::XMLRPC_TYPE_STRUCT,
);
];

if (!is_array($params)) {
$params = array($params);
$params = [$params];
}
foreach ($params as $key => $param) {
if ($param instanceof AbstractValue) {
Expand Down
10 changes: 5 additions & 5 deletions src/Client/ServerIntrospection.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public function getSignatureForEachMethodByMulticall($methods = null)
$methods = $this->listMethods();
}

$multicallParams = array();
$multicallParams = [];
foreach ($methods as $method) {
$multicallParams[] = array('methodName' => 'system.methodSignature',
'params' => array($method));
$multicallParams[] = ['methodName' => 'system.methodSignature',
'params' => [$method]];
}

$serverSignatures = $this->system->multicall($multicallParams);
Expand All @@ -88,7 +88,7 @@ public function getSignatureForEachMethodByMulticall($methods = null)
}

// Create a new signatures array with the methods name as keys and the signature as value
$signatures = array();
$signatures = [];
foreach ($serverSignatures as $i => $signature) {
$signatures[$methods[$i]] = $signature;
}
Expand All @@ -109,7 +109,7 @@ public function getSignatureForEachMethodByLooping($methods = null)
$methods = $this->listMethods();
}

$signatures = array();
$signatures = [];
foreach ($methods as $method) {
$signatures[$method] = $this->getMethodSignature($method);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Client/ServerProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ServerProxy
/**
* @var array of \Zend\XmlRpc\Client\ServerProxy
*/
private $cache = array();
private $cache = [];

/**
* Class constructor
Expand Down
8 changes: 4 additions & 4 deletions src/Fault.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Fault
* Internal fault codes => messages
* @var array
*/
protected $internal = array(
protected $internal = [
404 => 'Unknown Error',

// 610 - 619 reflection errors
Expand Down Expand Up @@ -78,7 +78,7 @@ class Fault
651 => 'Failed to parse response',
652 => 'Invalid response',
653 => 'Invalid XMLRPC value in response',
);
];

/**
* Constructor
Expand Down Expand Up @@ -271,10 +271,10 @@ public static function isFault($xml)
public function saveXml()
{
// Create fault value
$faultStruct = array(
$faultStruct = [
'faultCode' => $this->getCode(),
'faultString' => $this->getMessage()
);
];
$value = AbstractValue::getXmlRpcValue($faultStruct);

$generator = AbstractValue::getGenerator();
Expand Down
30 changes: 15 additions & 15 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Request
* Method parameters
* @var array
*/
protected $params = array();
protected $params = [];

/**
* Fault object, if any
Expand All @@ -60,13 +60,13 @@ class Request
* XML-RPC type for each param
* @var array
*/
protected $types = array();
protected $types = [];

/**
* XML-RPC request params
* @var array
*/
protected $xmlRpcParams = array();
protected $xmlRpcParams = [];

/**
* Create a new XML-RPC request
Expand Down Expand Up @@ -159,7 +159,7 @@ public function addParam($value, $type = null)
}
}
$this->types[] = $type;
$this->xmlRpcParams[] = array('value' => $value, 'type' => $type);
$this->xmlRpcParams[] = ['value' => $value, 'type' => $type];
}

/**
Expand Down Expand Up @@ -192,8 +192,8 @@ public function setParams()
}

if ((1 == $argc) && is_array($argv[0])) {
$params = array();
$types = array();
$params = [];
$types = [];
$wellFormed = true;
foreach ($argv[0] as $arg) {
if (!is_array($arg) || !isset($arg['value'])) {
Expand All @@ -214,16 +214,16 @@ public function setParams()
$this->types = $types;
} else {
$this->params = $argv[0];
$this->types = array();
$xmlRpcParams = array();
$this->types = [];
$xmlRpcParams = [];
foreach ($argv[0] as $arg) {
if ($arg instanceof AbstractValue) {
$type = $arg->getType();
} else {
$xmlRpcValue = AbstractValue::getXmlRpcValue($arg);
$type = $xmlRpcValue->getType();
}
$xmlRpcParams[] = array('value' => $arg, 'type' => $type);
$xmlRpcParams[] = ['value' => $arg, 'type' => $type];
$this->types[] = $type;
}
$this->xmlRpcParams = $xmlRpcParams;
Expand All @@ -232,16 +232,16 @@ public function setParams()
}

$this->params = $argv;
$this->types = array();
$xmlRpcParams = array();
$this->types = [];
$xmlRpcParams = [];
foreach ($argv as $arg) {
if ($arg instanceof AbstractValue) {
$type = $arg->getType();
} else {
$xmlRpcValue = AbstractValue::getXmlRpcValue($arg);
$type = $xmlRpcValue->getType();
}
$xmlRpcParams[] = array('value' => $arg, 'type' => $type);
$xmlRpcParams[] = ['value' => $arg, 'type' => $type];
$this->types[] = $type;
}
$this->xmlRpcParams = $xmlRpcParams;
Expand Down Expand Up @@ -328,8 +328,8 @@ public function loadXml($request)

// Check for parameters
if (!empty($xml->params)) {
$types = array();
$argv = array();
$types = [];
$argv = [];
foreach ($xml->params->children() as $param) {
if (!isset($param->value)) {
$this->fault = new Fault(633);
Expand Down Expand Up @@ -385,7 +385,7 @@ public function getFault()
*/
protected function _getXmlRpcParams()
{
$params = array();
$params = [];
if (is_array($this->xmlRpcParams)) {
foreach ($this->xmlRpcParams as $param) {
$value = $param['value'];
Expand Down
2 changes: 1 addition & 1 deletion src/Request/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getRawRequest()
public function getHeaders()
{
if (null === $this->headers) {
$this->headers = array();
$this->headers = [];
foreach ($_SERVER as $key => $value) {
if ('HTTP_' == substr($key, 0, 5)) {
$header = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
Expand Down
6 changes: 3 additions & 3 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Server extends AbstractServer
* PHP types => XML-RPC types
* @var array
*/
protected $typeMap = array(
protected $typeMap = [
'i4' => 'i4',
'int' => 'int',
'integer' => 'int',
Expand All @@ -101,7 +101,7 @@ class Server extends AbstractServer
'ex:nil' => 'nil',
'void' => 'void',
'mixed' => 'struct',
);
];

/**
* Send arguments to all methods or just constructor?
Expand Down Expand Up @@ -149,7 +149,7 @@ public function __call($method, $params)
if (!method_exists($system, $method)) {
throw new Server\Exception\BadMethodCallException('Unknown instance method called on server: ' . $method);
}
return call_user_func_array(array($system, $method), $params);
return call_user_func_array([$system, $method], $params);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Server/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class Cache extends \Zend\Server\Cache
/**
* @var array Skip system methods when caching XML-RPC server
*/
protected static $skipMethods = array(
protected static $skipMethods = [
'system.listMethods',
'system.methodHelp',
'system.methodSignature',
'system.multicall',
);
];
}
6 changes: 3 additions & 3 deletions src/Server/Fault.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class Fault extends \Zend\XmlRpc\Fault
/**
* @var array Array of exception classes that may define xmlrpc faults
*/
protected static $faultExceptionClasses = array('Zend\\XmlRpc\\Server\\Exception\\ExceptionInterface' => true);
protected static $faultExceptionClasses = ['Zend\\XmlRpc\\Server\\Exception\\ExceptionInterface' => true];

/**
* @var array Array of fault observers
*/
protected static $observers = array();
protected static $observers = [];

/**
* Constructor
Expand Down Expand Up @@ -134,7 +134,7 @@ public static function detachFaultException($classes)
*/
public static function attachObserver($class)
{
if (!is_string($class) || !class_exists($class) || !is_callable(array($class, 'observe'))) {
if (!is_string($class) || !class_exists($class) || !is_callable([$class, 'observe'])) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Server/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function methodSignature($method)
*/
public function multicall($methods)
{
$responses = array();
$responses = [];
foreach ($methods as $method) {
$fault = false;
if (!is_array($method)) {
Expand Down Expand Up @@ -132,10 +132,10 @@ public function multicall($methods)
}

if ($fault) {
$responses[] = array(
$responses[] = [
'faultCode' => $fault->getCode(),
'faultString' => $fault->getMessage()
);
];
}
}

Expand Down

0 comments on commit 4c56b82

Please sign in to comment.