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

Commit

Permalink
Merge ae66117 into c2cac5d
Browse files Browse the repository at this point in the history
  • Loading branch information
Koopzington committed Nov 15, 2016
2 parents c2cac5d + ae66117 commit 2ef8456
Show file tree
Hide file tree
Showing 24 changed files with 114 additions and 101 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ install:
- composer show

script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi

Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ To do so:

## Running Coding Standards Checks

This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
standards checks, and provides configuration for our selected checks.
`php-cs-fixer` is installed by default via Composer.
`phpcs` is installed by default via Composer.

To run checks only:

```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
$ composer cs-check
```

To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
flag:
`phpcs` also includes a tool for fixing most CS violations, `phpcbf`:


```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
$ composer cs-fix
```

If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
they pass, and make sure you add and commit the changes after verification.

## Recommended Workflow for Contributions
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"require-dev": {
"phpunit/PHPUnit": "^4.8",
"squizlabs/php_codesniffer": "^2.3.1"
"zendframework/zend-coding-standard": "~1.0.0"
},
"suggest": {
"zendframework/zend-cache": "To support Zend\\XmlRpc\\Server\\Cache usage"
Expand Down
43 changes: 36 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 1 addition & 16 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<description>Zend Framework coding standard</description>

<!-- display progress -->
<arg value="p"/>
<arg name="colors"/>

<!-- inherit rules from: -->
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
<exclude-pattern>test/_files/*</exclude-pattern>
<exclude-pattern>test/TestAsset/*</exclude-pattern>
</ruleset>
12 changes: 6 additions & 6 deletions src/AbstractValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getType()
*/
public static function getGenerator()
{
if (!static::$generator) {
if (! static::$generator) {
if (extension_loaded('xmlwriter')) {
static::$generator = new Generator\XmlWriter();
} else {
Expand Down Expand Up @@ -142,7 +142,7 @@ abstract public function getValue();
*/
public function saveXml()
{
if (!$this->xml) {
if (! $this->xml) {
$this->generateXml();
$this->xml = (string) $this->getGenerator();
}
Expand Down Expand Up @@ -244,7 +244,7 @@ public static function getXmlRpcTypeByValue($value)
}
return static::getXmlRpcTypeByValue(get_object_vars($value));
} elseif (is_array($value)) {
if (!empty($value) && is_array($value) && (array_keys($value) !== range(0, count($value) - 1))) {
if (! empty($value) && is_array($value) && (array_keys($value) !== range(0, count($value) - 1))) {
return self::XMLRPC_TYPE_STRUCT;
}
return self::XMLRPC_TYPE_ARRAY;
Expand Down Expand Up @@ -393,7 +393,7 @@ protected static function xmlStringToNativeXmlRpc($xml)
foreach ($value->member as $member) {
// @todo? If a member doesn't have a <value> tag, we don't add it to the struct
// Maybe we want to throw an exception here ?
if (!isset($member->value) or !isset($member->name)) {
if (! isset($member->value) or ! isset($member->name)) {
continue;
}
$values[(string) $member->name] = static::xmlStringToNativeXmlRpc($member->value);
Expand Down Expand Up @@ -442,7 +442,7 @@ protected static function extractTypeAndValue(\SimpleXMLElement $xml, &$type, &$
// Casting is necessary to work with strict-typed systems
$xmlAsArray = (array) $xml;
list($type, $value) = each($xmlAsArray);
if (!$type and $value === null) {
if (! $type and $value === null) {
$namespaces = ['ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions'];
foreach ($namespaces as $namespaceName => $namespaceUri) {
$namespaceXml = $xml->children($namespaceUri);
Expand All @@ -456,7 +456,7 @@ protected static function extractTypeAndValue(\SimpleXMLElement $xml, &$type, &$
}

// If no type was specified, the default is string
if (!$type) {
if (! $type) {
$type = self::XMLRPC_TYPE_STRING;
if (empty($value) and preg_match('#^<value>.*</value>$#', $xml->asXML())) {
$value = str_replace(['<value>', '</value>'], '', $xml->asXML());
Expand Down
12 changes: 6 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ public function doRequest($request, $response = null)
'Accept: text/xml',
]);

if (!$headers->get('user-agent')) {
if (! $headers->get('user-agent')) {
$headers->addHeaderLine('user-agent', 'Zend_XmlRpc_Client');
}

$xml = $this->lastRequest->__toString();
$http->setRawBody($xml);
$httpResponse = $http->setMethod('POST')->send();

if (!$httpResponse->isSuccess()) {
if (! $httpResponse->isSuccess()) {
/**
* Exception thrown when an HTTP error occurs
*/
Expand Down Expand Up @@ -246,7 +246,7 @@ public function doRequest($request, $response = null)
*/
public function call($method, $params = [])
{
if (!$this->skipSystemLookup() && ('system.' != substr($method, 0, 7))) {
if (! $this->skipSystemLookup() && ('system.' != substr($method, 0, 7))) {
// Ensure empty array/struct params are cast correctly
// If system.* methods are not available, bypass. (ZF-2978)
$success = true;
Expand All @@ -269,7 +269,7 @@ public function call($method, $params = [])
AbstractValue::XMLRPC_TYPE_STRUCT,
];

if (!is_array($params)) {
if (! is_array($params)) {
$params = [$params];
}
foreach ($params as $key => $param) {
Expand All @@ -280,7 +280,7 @@ public function call($method, $params = [])
if (count($signatures) > 1) {
$type = AbstractValue::getXmlRpcTypeByValue($param);
foreach ($signatures as $signature) {
if (!is_array($signature)) {
if (! is_array($signature)) {
continue;
}
if (isset($signature['parameters'][$key])) {
Expand All @@ -295,7 +295,7 @@ public function call($method, $params = [])
$type = null;
}

if (empty($type) || !in_array($type, $validTypes)) {
if (empty($type) || ! in_array($type, $validTypes)) {
$type = AbstractValue::AUTO_DETECT_TYPE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Client/ServerIntrospection.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function getSignatureForEachMethodByLooping($methods = null)
public function getMethodSignature($method)
{
$signature = $this->system->methodSignature($method);
if (!is_array($signature)) {
if (! is_array($signature)) {
$error = 'Invalid signature for method "' . $method . '"';
throw new Exception\IntrospectException($error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Client/ServerProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(XMLRPCClient $client, $namespace = '')
public function __get($namespace)
{
$namespace = ltrim("$this->namespace.$namespace", '.');
if (!isset($this->cache[$namespace])) {
if (! isset($this->cache[$namespace])) {
$this->cache[$namespace] = new $this($this->client, $namespace);
}
return $this->cache[$namespace];
Expand Down
8 changes: 4 additions & 4 deletions src/Fault.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function getEncoding()
*/
public function loadXml($fault)
{
if (!is_string($fault)) {
if (! is_string($fault)) {
throw new Exception\InvalidArgumentException('Invalid XML provided to fault');
}

Expand All @@ -188,7 +188,7 @@ public function loadXml($fault)
// Unsecure XML
throw new Exception\RuntimeException('Failed to parse XML fault: ' . $e->getMessage(), 500, $e);
}
if (!$xml instanceof SimpleXMLElement) {
if (! $xml instanceof SimpleXMLElement) {
$errors = libxml_get_errors();
$errors = array_reduce($errors, function ($result, $item) {
if (empty($result)) {
Expand All @@ -202,12 +202,12 @@ public function loadXml($fault)
libxml_use_internal_errors($xmlErrorsFlag);

// Check for fault
if (!$xml->fault) {
if (! $xml->fault) {
// Not a fault
return false;
}

if (!$xml->fault->value->struct) {
if (! $xml->fault->value->struct) {
// not a proper fault
throw new Exception\InvalidArgumentException('Invalid fault structure', 500);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getEncoding()
*/
public function setMethod($method)
{
if (!is_string($method) || !preg_match('/^[a-z0-9_.:\\\\\/]+$/i', $method)) {
if (! is_string($method) || ! preg_match('/^[a-z0-9_.:\\\\\/]+$/i', $method)) {
$this->fault = new Fault(634, 'Invalid method name ("' . $method . '")');
$this->fault->setEncoding($this->getEncoding());
return false;
Expand Down Expand Up @@ -196,13 +196,13 @@ public function setParams()
$types = [];
$wellFormed = true;
foreach ($argv[0] as $arg) {
if (!is_array($arg) || !isset($arg['value'])) {
if (! is_array($arg) || ! isset($arg['value'])) {
$wellFormed = false;
break;
}
$params[] = $arg['value'];

if (!isset($arg['type'])) {
if (! isset($arg['type'])) {
$xmlRpcValue = AbstractValue::getXmlRpcValue($arg['value']);
$arg['type'] = $xmlRpcValue->getType();
}
Expand Down Expand Up @@ -276,7 +276,7 @@ public function getTypes()
*/
public function loadXml($request)
{
if (!is_string($request)) {
if (! is_string($request)) {
$this->fault = new Fault(635);
$this->fault->setEncoding($this->getEncoding());
return false;
Expand Down Expand Up @@ -308,7 +308,7 @@ public function loadXml($request)
libxml_use_internal_errors($xmlErrorsFlag);
return false;
}
if (!$xml instanceof SimpleXMLElement || $error) {
if (! $xml instanceof SimpleXMLElement || $error) {
// Not valid XML
$this->fault = new Fault(631);
$this->fault->setEncoding($this->getEncoding());
Expand All @@ -327,11 +327,11 @@ public function loadXml($request)
$this->method = (string) $xml->methodName;

// Check for parameters
if (!empty($xml->params)) {
if (! empty($xml->params)) {
$types = [];
$argv = [];
foreach ($xml->params->children() as $param) {
if (!isset($param->value)) {
if (! isset($param->value)) {
$this->fault = new Fault(633);
$this->fault->setEncoding($this->getEncoding());
return false;
Expand Down Expand Up @@ -391,7 +391,7 @@ protected function getXmlRpcParams()
$value = $param['value'];
$type = $param['type'] ?: AbstractValue::AUTO_DETECT_TYPE;

if (!$value instanceof AbstractValue) {
if (! $value instanceof AbstractValue) {
$value = AbstractValue::getXmlRpcValue($value, $type);
}
$params[] = $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 @@ -47,7 +47,7 @@ public function __construct()
ErrorHandler::start();
$xml = file_get_contents('php://input');
ErrorHandler::stop();
if (!$xml) {
if (! $xml) {
$this->fault = new Fault(630);
return;
}
Expand Down

0 comments on commit 2ef8456

Please sign in to comment.