Reformat source code: tests
authorgggeek <giunta.gaetano@gmail.com>
Sat, 21 Feb 2015 19:04:06 +0000 (19:04 +0000)
committergggeek <giunta.gaetano@gmail.com>
Sat, 21 Feb 2015 19:04:06 +0000 (19:04 +0000)
tests/InvalidHostTest.php
tests/LocalhostTest.php
tests/ParsingBugsTest.php
tests/benchmark.php
tests/parse_args.php
tests/verify_compat.php

index fb89b43..1ac111f 100644 (file)
@@ -1,62 +1,58 @@
 <?php
 
-include_once(__DIR__.'/../lib/xmlrpc.inc');
+include_once __DIR__ . '/../lib/xmlrpc.inc';
 
-include_once(__DIR__.'/parse_args.php');
+include_once __DIR__ . '/parse_args.php';
 
 class InvalidHostTest extends PHPUnit_Framework_TestCase
 {
-    var $client = null;
-    var $args = array();
+    public $client = null;
+    public $args = array();
 
-    function setUp()
+    public function setUp()
     {
         $this->args = argParser::getArgs();
 
         $this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['LOCALSERVER'], 80);
-        if($this->args['DEBUG'])
-        {
+        if ($this->args['DEBUG']) {
             $this->client->setDebug($this->args['DEBUG']);
         }
     }
 
-    function test404()
+    public function test404()
     {
-        $f = new xmlrpcmsg('examples.echo',array(
-            new xmlrpcval('hello', 'string')
+        $f = new xmlrpcmsg('examples.echo', array(
+            new xmlrpcval('hello', 'string'),
         ));
         $r = $this->client->send($f, 5);
         $this->assertEquals(5, $r->faultCode());
     }
 
-    function testSrvNotFound()
+    public function testSrvNotFound()
     {
-        $f = new xmlrpcmsg('examples.echo',array(
-            new xmlrpcval('hello', 'string')
+        $f = new xmlrpcmsg('examples.echo', array(
+            new xmlrpcval('hello', 'string'),
         ));
         $this->client->server .= 'XXX';
         $r = $this->client->send($f, 5);
         // make sure there's no freaking catchall DNS in effect
         $dnsinfo = dns_get_record($this->client->server);
-        if($dnsinfo)
-        {
+        if ($dnsinfo) {
             $this->markTestSkipped('Seems like there is a catchall DNS in effect: host ' . $this->client->server . ' found');
-        }
-        else
-        {
+        } else {
             $this->assertEquals(5, $r->faultCode());
         }
     }
 
-    function testCurlKAErr()
+    public function testCurlKAErr()
     {
-        if(!function_exists('curl_init'))
-        {
+        if (!function_exists('curl_init')) {
             $this->markTestSkipped('CURL missing: cannot test curl keepalive errors');
+
             return;
         }
-        $f = new xmlrpcmsg('examples.stringecho',array(
-            new xmlrpcval('hello', 'string')
+        $f = new xmlrpcmsg('examples.stringecho', array(
+            new xmlrpcval('hello', 'string'),
         ));
         // test 2 calls w. keepalive: 1st time connection ko, second time ok
         $this->client->server .= 'XXX';
@@ -67,8 +63,7 @@ class InvalidHostTest extends PHPUnit_Framework_TestCase
 
         // now test a successful connection
         $server = explode(':', $this->args['LOCALSERVER']);
-        if(count($server) > 1)
-        {
+        if (count($server) > 1) {
             $this->client->port = $server[1];
         }
         $this->client->server = $server[0];
@@ -77,6 +72,6 @@ class InvalidHostTest extends PHPUnit_Framework_TestCase
         $r = $this->client->send($f, 5, 'http11');
         $this->assertEquals(0, $r->faultCode());
         $ro = $r->value();
-        is_object( $ro ) && $this->assertEquals('hello', $ro->scalarVal());
+        is_object($ro) && $this->assertEquals('hello', $ro->scalarVal());
     }
 }
index 3078960..ec2ad1e 100644 (file)
@@ -1,31 +1,28 @@
 <?php
 
-include_once(__DIR__.'/../lib/xmlrpc.inc');
-include_once(__DIR__.'/../lib/xmlrpc_wrappers.inc');
+include_once __DIR__ . '/../lib/xmlrpc.inc';
+include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc';
 
-include_once(__DIR__.'/parse_args.php');
+include_once __DIR__ . '/parse_args.php';
 
 class LocalhostTest extends PHPUnit_Framework_TestCase
 {
-    var $client = null;
-    var $method = 'http';
-    var $timeout = 10;
-    var $request_compression = null;
-    var $accepted_compression = '';
-    var $args = array();
-
-    static function fail($message = '')
+    public $client = null;
+    public $method = 'http';
+    public $timeout = 10;
+    public $request_compression = null;
+    public $accepted_compression = '';
+    public $args = array();
+
+    public static function fail($message = '')
     {
         // save in global var that this particular test has failed
         // (but only if not called from subclass objects / multitests)
-        if (function_exists('debug_backtrace') && strtolower(get_called_class()) == 'localhosttests')
-        {
+        if (function_exists('debug_backtrace') && strtolower(get_called_class()) == 'localhosttests') {
             global $failed_tests;
             $trace = debug_backtrace();
-            for ($i = 0; $i < count($trace); $i++)
-            {
-                if (strpos($trace[$i]['function'], 'test') === 0)
-                {
+            for ($i = 0; $i < count($trace); $i++) {
+                if (strpos($trace[$i]['function'], 'test') === 0) {
                     $failed_tests[$trace[$i]['function']] = true;
                     break;
                 }
@@ -38,124 +35,115 @@ class LocalhostTest extends PHPUnit_Framework_TestCase
     /**
      * @todo be smarter with setup, do not use global variables anymore
      */
-    function setUp()
+    public function setUp()
     {
         $this->args = argParser::getArgs();
 
         $server = explode(':', $this->args['LOCALSERVER']);
-        if(count($server) > 1)
-        {
-            $this->client=new xmlrpc_client($this->args['URI'], $server[0], $server[1]);
+        if (count($server) > 1) {
+            $this->client = new xmlrpc_client($this->args['URI'], $server[0], $server[1]);
+        } else {
+            $this->client = new xmlrpc_client($this->args['URI'], $this->args['LOCALSERVER']);
         }
-        else
-        {
-            $this->client=new xmlrpc_client($this->args['URI'], $this->args['LOCALSERVER']);
-        }
-        if($this->args['DEBUG'])
-        {
+        if ($this->args['DEBUG']) {
             $this->client->setDebug($this->args['DEBUG']);
         }
         $this->client->request_compression = $this->request_compression;
         $this->client->accepted_compression = $this->accepted_compression;
     }
 
-    function send($msg, $errrorcode=0, $return_response=false)
+    public function send($msg, $errrorcode = 0, $return_response = false)
     {
         $r = $this->client->send($msg, $this->timeout, $this->method);
         // for multicall, return directly array of responses
-        if(is_array($r))
-        {
+        if (is_array($r)) {
             return $r;
         }
-        $this->assertEquals($r->faultCode(), $errrorcode, 'Error '.$r->faultCode().' connecting to server: '.$r->faultString());
-        if(!$r->faultCode())
-        {
-            if($return_response)
+        $this->assertEquals($r->faultCode(), $errrorcode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
+        if (!$r->faultCode()) {
+            if ($return_response) {
                 return $r;
-            else
+            } else {
                 return $r->value();
-        }
-        else
-        {
-            return null;
+            }
+        } else {
+            return;
         }
     }
 
-    function testString()
+    public function testString()
     {
-        $sendstring="here are 3 \"entities\": < > & " .
+        $sendstring = "here are 3 \"entities\": < > & " .
             "and here's a dollar sign: \$pretendvarname and a backslash too: " . chr(92) .
             " - isn't that great? \\\"hackery\\\" at it's best " .
-            " also don't want to miss out on \$item[0]. ".
-            "The real weird stuff follows: CRLF here".chr(13).chr(10).
-            "a simple CR here".chr(13).
-            "a simple LF here".chr(10).
-            "and then LFCR".chr(10).chr(13).
-            "last but not least weird names: G".chr(252)."nter, El".chr(232)."ne, and an xml comment closing tag: -->";
-        $f=new xmlrpcmsg('examples.stringecho', array(
-            new xmlrpcval($sendstring, 'string')
+            " also don't want to miss out on \$item[0]. " .
+            "The real weird stuff follows: CRLF here" . chr(13) . chr(10) .
+            "a simple CR here" . chr(13) .
+            "a simple LF here" . chr(10) .
+            "and then LFCR" . chr(10) . chr(13) .
+            "last but not least weird names: G" . chr(252) . "nter, El" . chr(232) . "ne, and an xml comment closing tag: -->";
+        $f = new xmlrpcmsg('examples.stringecho', array(
+            new xmlrpcval($sendstring, 'string'),
         ));
-        $v=$this->send($f);
-        if($v)
-        {
+        $v = $this->send($f);
+        if ($v) {
             // when sending/receiving non-US-ASCII encoded strings, XML says cr-lf can be normalized.
             // so we relax our tests...
             $l1 = strlen($sendstring);
             $l2 = strlen($v->scalarval());
-            if ($l1 == $l2)
+            if ($l1 == $l2) {
                 $this->assertEquals($sendstring, $v->scalarval());
-            else
+            } else {
                 $this->assertEquals(str_replace(array("\r\n", "\r"), array("\n", "\n"), $sendstring), $v->scalarval());
+            }
         }
     }
 
-    function testAddingDoubles()
+    public function testAddingDoubles()
     {
         // note that rounding errors mean we
         // keep precision to sensible levels here ;-)
-        $a=12.13; $b=-23.98;
-        $f=new xmlrpcmsg('examples.addtwodouble',array(
+        $a = 12.13;
+        $b = -23.98;
+        $f = new xmlrpcmsg('examples.addtwodouble', array(
             new xmlrpcval($a, 'double'),
-            new xmlrpcval($b, 'double')
+            new xmlrpcval($b, 'double'),
         ));
-        $v=$this->send($f);
-        if($v)
-        {
-            $this->assertEquals($a+$b,$v->scalarval());
+        $v = $this->send($f);
+        if ($v) {
+            $this->assertEquals($a + $b, $v->scalarval());
         }
     }
 
-    function testAdding()
+    public function testAdding()
     {
-        $f=new xmlrpcmsg('examples.addtwo',array(
+        $f = new xmlrpcmsg('examples.addtwo', array(
             new xmlrpcval(12, 'int'),
-            new xmlrpcval(-23, 'int')
+            new xmlrpcval(-23, 'int'),
         ));
-        $v=$this->send($f);
-        if($v)
-        {
-            $this->assertEquals(12-23, $v->scalarval());
+        $v = $this->send($f);
+        if ($v) {
+            $this->assertEquals(12 - 23, $v->scalarval());
         }
     }
 
-    function testInvalidNumber()
+    public function testInvalidNumber()
     {
-        $f=new xmlrpcmsg('examples.addtwo',array(
+        $f = new xmlrpcmsg('examples.addtwo', array(
             new xmlrpcval('fred', 'int'),
-            new xmlrpcval("\"; exec('ls')", 'int')
+            new xmlrpcval("\"; exec('ls')", 'int'),
         ));
-        $v=$this->send($f);
+        $v = $this->send($f);
         /// @todo a fault condition should be generated here
         /// by the server, which we pick up on
-        if($v)
-        {
+        if ($v) {
             $this->assertEquals(0, $v->scalarval());
         }
     }
 
-    function testBoolean()
+    public function testBoolean()
     {
-        $f=new xmlrpcmsg('examples.invertBooleans', array(
+        $f = new xmlrpcmsg('examples.invertBooleans', array(
             new xmlrpcval(array(
                 new xmlrpcval(true, 'boolean'),
                 new xmlrpcval(false, 'boolean'),
@@ -164,33 +152,28 @@ class LocalhostTest extends PHPUnit_Framework_TestCase
                 //new xmlrpcval('true', 'boolean'),
                 //new xmlrpcval('false', 'boolean')
             ),
-            'array'
-            )));
-        $answer='0101';
-        $v=$this->send($f);
-        if($v)
-        {
-            $sz=$v->arraysize();
-            $got='';
-            for($i=0; $i<$sz; $i++)
-            {
-                $b=$v->arraymem($i);
-                if($b->scalarval())
-                {
-                    $got.='1';
-                }
-                else
-                {
-                    $got.='0';
+                'array'
+            ),));
+        $answer = '0101';
+        $v = $this->send($f);
+        if ($v) {
+            $sz = $v->arraysize();
+            $got = '';
+            for ($i = 0; $i < $sz; $i++) {
+                $b = $v->arraymem($i);
+                if ($b->scalarval()) {
+                    $got .= '1';
+                } else {
+                    $got .= '0';
                 }
             }
             $this->assertEquals($answer, $got);
         }
     }
 
-    function testBase64()
+    public function testBase64()
     {
-        $sendstring='Mary had a little lamb,
+        $sendstring = 'Mary had a little lamb,
 Whose fleece was white as snow,
 And everywhere that Mary went
 the lamb was sure to go.
@@ -199,51 +182,47 @@ Mary had a little lamb
 She tied it to a pylon
 Ten thousand volts went down its back
 And turned it into nylon';
-        $f=new xmlrpcmsg('examples.decode64',array(
-            new xmlrpcval($sendstring, 'base64')
+        $f = new xmlrpcmsg('examples.decode64', array(
+            new xmlrpcval($sendstring, 'base64'),
         ));
-        $v=$this->send($f);
-        if($v)
-        {
-            if (strlen($sendstring) == strlen($v->scalarval()))
+        $v = $this->send($f);
+        if ($v) {
+            if (strlen($sendstring) == strlen($v->scalarval())) {
                 $this->assertEquals($sendstring, $v->scalarval());
-            else
+            } else {
                 $this->assertEquals(str_replace(array("\r\n", "\r"), array("\n", "\n"), $sendstring), $v->scalarval());
+            }
         }
     }
 
-    function testDateTime()
+    public function testDateTime()
     {
         $time = time();
         $t1 = new xmlrpcval($time, 'dateTime.iso8601');
         $t2 = new xmlrpcval(iso8601_encode($time), 'dateTime.iso8601');
         $this->assertEquals($t1->serialize(), $t2->serialize());
-        if (class_exists('DateTime'))
-        {
+        if (class_exists('DateTime')) {
             $datetime = new DateTime();
             // skip this test for php 5.2. It is a bit harder there to build a DateTime from unix timestamp with proper TZ info
-            if(is_callable(array($datetime,'setTimestamp')))
-            {
+            if (is_callable(array($datetime, 'setTimestamp'))) {
                 $t3 = new xmlrpcval($datetime->setTimestamp($time), 'dateTime.iso8601');
                 $this->assertEquals($t1->serialize(), $t3->serialize());
             }
         }
     }
 
-    function testCountEntities()
+    public function testCountEntities()
     {
         $sendstring = "h'fd>onc>>l>>rw&bpu>q>e<v&gxs<ytjzkami<";
-        $f = new xmlrpcmsg('validator1.countTheEntities',array(
-            new xmlrpcval($sendstring, 'string')
+        $f = new xmlrpcmsg('validator1.countTheEntities', array(
+            new xmlrpcval($sendstring, 'string'),
         ));
         $v = $this->send($f);
-        if($v)
-        {
+        if ($v) {
             $got = '';
             $expected = '37210';
-            $expect_array = array('ctLeftAngleBrackets','ctRightAngleBrackets','ctAmpersands','ctApostrophes','ctQuotes');
-            while(list(,$val) = each($expect_array))
-            {
+            $expect_array = array('ctLeftAngleBrackets', 'ctRightAngleBrackets', 'ctAmpersands', 'ctApostrophes', 'ctQuotes');
+            while (list(, $val) = each($expect_array)) {
                 $b = $v->structmem($val);
                 $got .= $b->me['int'];
             }
@@ -251,14 +230,15 @@ And turned it into nylon';
         }
     }
 
-    function _multicall_msg($method, $params)
+    public function _multicall_msg($method, $params)
     {
         $struct['methodName'] = new xmlrpcval($method, 'string');
         $struct['params'] = new xmlrpcval($params, 'array');
+
         return new xmlrpcval($struct, 'struct');
     }
 
-    function testServerMulticall()
+    public function testServerMulticall()
     {
         // We manually construct a system.multicall() call to ensure
         // that the server supports it.
@@ -285,8 +265,7 @@ And turned it into nylon';
 
         $f = new xmlrpcmsg('system.multicall', array($arg));
         $v = $this->send($f);
-        if($v)
-        {
+        if ($v) {
             //$this->assertTrue($r->faultCode() == 0, "fault from system.multicall");
             $this->assertTrue($v->arraysize() == 4, "bad number of return values");
 
@@ -316,7 +295,7 @@ And turned it into nylon';
         }
     }
 
-    function testClientMulticall1()
+    public function testClientMulticall1()
     {
         // NB: This test will NOT pass if server does not support system.multicall.
 
@@ -333,14 +312,12 @@ And turned it into nylon';
         );
 
         $r = $this->send(array($good1, $bad, $recursive, $good2));
-        if($r)
-        {
+        if ($r) {
             $this->assertTrue(count($r) == 4, "wrong number of return values");
         }
 
         $this->assertTrue($r[0]->faultCode() == 0, "fault from good1");
-        if(!$r[0]->faultCode())
-        {
+        if (!$r[0]->faultCode()) {
             $val = $r[0]->value();
             $this->assertTrue(
                 $val->kindOf() == 'scalar' && $val->scalartyp() == 'string',
@@ -350,8 +327,7 @@ And turned it into nylon';
         $this->assertTrue($r[1]->faultCode() != 0, "no fault from bad");
         $this->assertTrue($r[2]->faultCode() != 0, "no fault from recursive system.multicall");
         $this->assertTrue($r[3]->faultCode() == 0, "fault from good2");
-        if(!$r[3]->faultCode())
-        {
+        if (!$r[3]->faultCode()) {
             $val = $r[3]->value();
             $this->assertTrue($val->kindOf() == 'array', "good2 did not return array");
         }
@@ -362,7 +338,7 @@ And turned it into nylon';
         );
     }
 
-    function testClientMulticall2()
+    public function testClientMulticall2()
     {
         // NB: This test will NOT pass if server does not support system.multicall.
 
@@ -379,14 +355,12 @@ And turned it into nylon';
         );
 
         $r = $this->send(array($good1, $bad, $recursive, $good2));
-        if($r)
-        {
+        if ($r) {
             $this->assertTrue(count($r) == 4, "wrong number of return values");
         }
 
         $this->assertTrue($r[0]->faultCode() == 0, "fault from good1");
-        if(!$r[0]->faultCode())
-        {
+        if (!$r[0]->faultCode()) {
             $val = $r[0]->value();
             $this->assertTrue(
                 $val->kindOf() == 'scalar' && $val->scalartyp() == 'string',
@@ -395,14 +369,13 @@ And turned it into nylon';
         $this->assertTrue($r[1]->faultCode() != 0, "no fault from bad");
         $this->assertTrue($r[2]->faultCode() == 0, "fault from (non recursive) system.multicall");
         $this->assertTrue($r[3]->faultCode() == 0, "fault from good2");
-        if(!$r[3]->faultCode())
-        {
+        if (!$r[3]->faultCode()) {
             $val = $r[3]->value();
             $this->assertTrue($val->kindOf() == 'array', "good2 did not return array");
         }
     }
 
-    function testClientMulticall3()
+    public function testClientMulticall3()
     {
         // NB: This test will NOT pass if server does not support system.multicall.
 
@@ -420,190 +393,169 @@ And turned it into nylon';
         );
 
         $r = $this->send(array($good1, $bad, $recursive, $good2));
-        if($r)
-        {
+        if ($r) {
             $this->assertTrue(count($r) == 4, "wrong number of return values");
         }
         $this->assertTrue($r[0]->faultCode() == 0, "fault from good1");
-        if(!$r[0]->faultCode())
-        {
+        if (!$r[0]->faultCode()) {
             $val = $r[0]->value();
             $this->assertTrue(
-                is_string($val) , "good1 did not return string");
+                is_string($val), "good1 did not return string");
         }
         $this->assertTrue($r[1]->faultCode() != 0, "no fault from bad");
         $this->assertTrue($r[2]->faultCode() != 0, "no fault from recursive system.multicall");
         $this->assertTrue($r[3]->faultCode() == 0, "fault from good2");
-        if(!$r[3]->faultCode())
-        {
+        if (!$r[3]->faultCode()) {
             $val = $r[3]->value();
             $this->assertTrue(is_array($val), "good2 did not return array");
         }
         $this->client->return_type = 'xmlrpcvals';
     }
 
-    function testCatchWarnings()
+    public function testCatchWarnings()
     {
         $f = new xmlrpcmsg('examples.generatePHPWarning', array(
-            new xmlrpcval('whatever', 'string')
+            new xmlrpcval('whatever', 'string'),
         ));
         $v = $this->send($f);
-        if($v)
-        {
+        if ($v) {
             $this->assertEquals($v->scalarval(), true);
         }
     }
 
-    function testCatchExceptions()
+    public function testCatchExceptions()
     {
         $f = new xmlrpcmsg('examples.raiseException', array(
-            new xmlrpcval('whatever', 'string')
+            new xmlrpcval('whatever', 'string'),
         ));
         $v = $this->send($f, $GLOBALS['xmlrpcerr']['server_error']);
-        $this->client->path = $this->args['URI'].'?EXCEPTION_HANDLING=1';
+        $this->client->path = $this->args['URI'] . '?EXCEPTION_HANDLING=1';
         $v = $this->send($f, 1);
-        $this->client->path = $this->args['URI'].'?EXCEPTION_HANDLING=2';
+        $this->client->path = $this->args['URI'] . '?EXCEPTION_HANDLING=2';
         $v = $this->send($f, $GLOBALS['xmlrpcerr']['invalid_return']);
     }
 
-    function testZeroParams()
+    public function testZeroParams()
     {
         $f = new xmlrpcmsg('system.listMethods');
         $v = $this->send($f);
     }
 
-    function testCodeInjectionServerSide()
+    public function testCodeInjectionServerSide()
     {
         $f = new xmlrpcmsg('system.MethodHelp');
         $f->payload = "<?xml version=\"1.0\"?><methodCall><methodName>validator1.echoStructTest</methodName><params><param><value><struct><member><name>','')); echo('gotcha!'); die(); //</name></member></struct></value></param></params></methodCall>";
         $v = $this->send($f);
         //$v = $r->faultCode();
-        if ($v)
-        {
+        if ($v) {
             $this->assertEquals(0, $v->structsize());
         }
     }
 
-    function testAutoRegisteredFunction()
+    public function testAutoRegisteredFunction()
     {
-        $f=new xmlrpcmsg('examples.php.getStateName',array(
-            new xmlrpcval(23, 'int')
+        $f = new xmlrpcmsg('examples.php.getStateName', array(
+            new xmlrpcval(23, 'int'),
         ));
-        $v=$this->send($f);
-        if($v)
-        {
+        $v = $this->send($f);
+        if ($v) {
             $this->assertEquals('Michigan', $v->scalarval());
-        }
-        else
-        {
+        } else {
             $this->fail('Note: server can only auto register functions if running with PHP 5.0.3 and up');
         }
     }
 
-    function testAutoRegisteredClass()
+    public function testAutoRegisteredClass()
     {
-        $f=new xmlrpcmsg('examples.php2.getStateName',array(
-            new xmlrpcval(23, 'int')
+        $f = new xmlrpcmsg('examples.php2.getStateName', array(
+            new xmlrpcval(23, 'int'),
         ));
-        $v=$this->send($f);
-        if($v)
-        {
+        $v = $this->send($f);
+        if ($v) {
             $this->assertEquals('Michigan', $v->scalarval());
-            $f=new xmlrpcmsg('examples.php3.getStateName',array(
-            new xmlrpcval(23, 'int')
-        ));
-            $v=$this->send($f);
-            if($v)
-            {
+            $f = new xmlrpcmsg('examples.php3.getStateName', array(
+                new xmlrpcval(23, 'int'),
+            ));
+            $v = $this->send($f);
+            if ($v) {
                 $this->assertEquals('Michigan', $v->scalarval());
             }
-        }
-        else
-        {
+        } else {
             $this->fail('Note: server can only auto register class methods if running with PHP 5.0.3 and up');
         }
     }
 
-    function testAutoRegisteredMethod()
+    public function testAutoRegisteredMethod()
     {
         // make a 'deep client copy' as the original one might have many properties set
-        $func=wrap_xmlrpc_method($this->client, 'examples.getStateName', array('simple_client_copy' => 1));
-        if($func == '')
-        {
+        $func = wrap_xmlrpc_method($this->client, 'examples.getStateName', array('simple_client_copy' => 1));
+        if ($func == '') {
             $this->fail('Registration of examples.getStateName failed');
-        }
-        else
-        {
-            $v=$func(23);
+        } else {
+            $v = $func(23);
             // work around bug in current version of phpunit
-            if(is_object($v))
-            {
+            if (is_object($v)) {
                 $v = var_export($v, true);
             }
             $this->assertEquals('Michigan', $v);
         }
     }
 
-    function testGetCookies()
+    public function testGetCookies()
     {
         // let server set to us some cookies we tell it
         $cookies = array(
             //'c1' => array(),
             'c2' => array('value' => 'c2'),
-            'c3' => array('value' => 'c3', 'expires' => time()+60*60*24*30),
-            'c4' => array('value' => 'c4', 'expires' => time()+60*60*24*30, 'path' => '/'),
-            'c5' => array('value' => 'c5', 'expires' => time()+60*60*24*30, 'path' => '/', 'domain' => 'localhost'),
+            'c3' => array('value' => 'c3', 'expires' => time() + 60 * 60 * 24 * 30),
+            'c4' => array('value' => 'c4', 'expires' => time() + 60 * 60 * 24 * 30, 'path' => '/'),
+            'c5' => array('value' => 'c5', 'expires' => time() + 60 * 60 * 24 * 30, 'path' => '/', 'domain' => 'localhost'),
         );
         $cookiesval = php_xmlrpc_encode($cookies);
-        $f=new xmlrpcmsg('examples.setcookies',array($cookiesval));
-        $r=$this->send($f, 0, true);
-        if($r)
-        {
+        $f = new xmlrpcmsg('examples.setcookies', array($cookiesval));
+        $r = $this->send($f, 0, true);
+        if ($r) {
             $v = $r->value();
             $this->assertEquals(1, $v->scalarval());
             // now check if we decoded the cookies as we had set them
             $rcookies = $r->cookies();
             // remove extra cookies which might have been set by proxies
-            foreach($rcookies as $c => $v)
-                if(!in_array($c, array('c2', 'c3', 'c4', 'c5')))
+            foreach ($rcookies as $c => $v) {
+                if (!in_array($c, array('c2', 'c3', 'c4', 'c5'))) {
                     unset($rcookies[$c]);
-            foreach($cookies as $c => $v)
-                // format for date string in cookies: 'Mon, 31 Oct 2005 13:50:56 GMT'
+                }
+            }
+            foreach ($cookies as $c => $v) {// format for date string in cookies: 'Mon, 31 Oct 2005 13:50:56 GMT'
                 // but PHP versions differ on that, some use 'Mon, 31-Oct-2005 13:50:56 GMT'...
-                if(isset($v['expires']))
-                {
-                    if (isset($rcookies[$c]['expires']) && strpos($rcookies[$c]['expires'], '-'))
-                    {
-                        $cookies[$c]['expires'] = gmdate('D, d\-M\-Y H:i:s \G\M\T' ,$cookies[$c]['expires']);
-                    }
-                    else
-                    {
-                        $cookies[$c]['expires'] = gmdate('D, d M Y H:i:s \G\M\T' ,$cookies[$c]['expires']);
+                if (isset($v['expires'])) {
+                    if (isset($rcookies[$c]['expires']) && strpos($rcookies[$c]['expires'], '-')) {
+                        $cookies[$c]['expires'] = gmdate('D, d\-M\-Y H:i:s \G\M\T', $cookies[$c]['expires']);
+                    } else {
+                        $cookies[$c]['expires'] = gmdate('D, d M Y H:i:s \G\M\T', $cookies[$c]['expires']);
                     }
                 }
-            $this->assertEquals($cookies, $rcookies);
+                $this->assertEquals($cookies, $rcookies);
+            }
         }
     }
 
-    function testSetCookies()
+    public function testSetCookies()
     {
         // let server set to us some cookies we tell it
         $cookies = array(
             'c0' => null,
             'c1' => 1,
             'c2' => '2 3',
-            'c3' => '!@#$%^&*()_+|}{":?><,./\';[]\\=-'
+            'c3' => '!@#$%^&*()_+|}{":?><,./\';[]\\=-',
         );
-        $f=new xmlrpcmsg('examples.getcookies',array());
-        foreach ($cookies as $cookie => $val)
-        {
+        $f = new xmlrpcmsg('examples.getcookies', array());
+        foreach ($cookies as $cookie => $val) {
             $this->client->setCookie($cookie, $val);
-            $cookies[$cookie] = (string) $cookies[$cookie];
+            $cookies[$cookie] = (string)$cookies[$cookie];
         }
         $r = $this->client->send($f, $this->timeout, $this->method);
-        $this->assertEquals($r->faultCode(), 0, 'Error '.$r->faultCode().' connecting to server: '.$r->faultString());
-        if(!$r->faultCode())
-        {
+        $this->assertEquals($r->faultCode(), 0, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
+        if (!$r->faultCode()) {
             $v = $r->value();
             $v = php_xmlrpc_decode($v);
             // on IIS and Apache getallheaders returns something slightly different...
@@ -611,17 +563,16 @@ And turned it into nylon';
         }
     }
 
-    function testSendTwiceSameMsg()
+    public function testSendTwiceSameMsg()
     {
-        $f=new xmlrpcmsg('examples.stringecho', array(
-            new xmlrpcval('hello world', 'string')
+        $f = new xmlrpcmsg('examples.stringecho', array(
+            new xmlrpcval('hello world', 'string'),
         ));
         $v1 = $this->send($f);
         $v2 = $this->send($f);
         //$v = $r->faultCode();
-        if ($v1 && $v2)
-        {
+        if ($v1 && $v2) {
             $this->assertEquals($v2, $v1);
         }
     }
-}
\ No newline at end of file
+}
index 93626c7..db03a47 100644 (file)
@@ -1,22 +1,22 @@
 <?php
 /**
- * NB: do not let your IDE fool you. The correct encoding for this file is NOT UTF8
+ * NB: do not let your IDE fool you. The correct encoding for this file is NOT UTF8.
  */
-
-include_once(__DIR__.'/../lib/xmlrpc.inc');
-include_once(__DIR__.'/../lib/xmlrpcs.inc');
+include_once __DIR__ . '/../lib/xmlrpc.inc';
+include_once __DIR__ . '/../lib/xmlrpcs.inc';
 
 class ParsingBugsTests extends PHPUnit_Framework_TestCase
 {
-    function testMinusOneString()
+    public function testMinusOneString()
     {
         $v = new xmlrpcval('-1');
         $u = new xmlrpcval('-1', 'string');
         $this->assertEquals($u->scalarval(), $v->scalarval());
     }
 
-    function testUnicodeInMemberName(){
-        $str = "G".chr(252)."nter, El".chr(232)."ne";
+    public function testUnicodeInMemberName()
+    {
+        $str = "G" . chr(252) . "nter, El" . chr(232) . "ne";
         $v = array($str => new xmlrpcval(1));
         $r = new xmlrpcresp(new xmlrpcval($v, 'struct'));
         $r = $r->serialize();
@@ -26,14 +26,14 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $this->assertEquals($v->structmemexists($str), true);
     }
 
-    function testUnicodeInErrorString()
+    public function testUnicodeInErrorString()
     {
         $response = utf8_encode(
             '<?xml version="1.0"?>
 <!-- $Id -->
 <!-- found by G. giunta, covers what happens when lib receives
   UTF8 chars in response text and comments -->
-<!-- '.chr(224).chr(252).chr(232).'&#224;&#252;&#232; -->
+<!-- ' . chr(224) . chr(252) . chr(232) . '&#224;&#252;&#232; -->
 <methodResponse>
 <fault>
 <value>
@@ -44,7 +44,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
 </member>
 <member>
 <name>faultString</name>
-<value><string>'.chr(224).chr(252).chr(232).'&#224;&#252;&#232;</string></value>
+<value><string>' . chr(224) . chr(252) . chr(232) . '&#224;&#252;&#232;</string></value>
 </member>
 </struct>
 </value>
@@ -53,13 +53,13 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $m = new xmlrpcmsg('dummy');
         $r = $m->parseResponse($response);
         $v = $r->faultString();
-        $this->assertEquals(chr(224).chr(252).chr(232).chr(224).chr(252).chr(232), $v);
+        $this->assertEquals(chr(224) . chr(252) . chr(232) . chr(224) . chr(252) . chr(232), $v);
     }
 
-    function testValidNumbers()
+    public function testValidNumbers()
     {
         $m = new xmlrpcmsg('dummy');
-        $fp=
+        $fp =
             '<?xml version="1.0"?>
 <methodResponse>
 <params>
@@ -91,13 +91,13 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
 </param>
 </params>
 </methodResponse>';
-        $r=$m->parseResponse($fp);
-        $v=$r->value();
-        $s=$v->structmem('integer1');
-        $t=$v->structmem('float1');
-        $u=$v->structmem('integer2');
-        $w=$v->structmem('float2');
-        $x=$v->structmem('float3');
+        $r = $m->parseResponse($fp);
+        $v = $r->value();
+        $s = $v->structmem('integer1');
+        $t = $v->structmem('float1');
+        $u = $v->structmem('integer2');
+        $w = $v->structmem('float2');
+        $x = $v->structmem('float3');
         $this->assertEquals(1, $s->scalarval());
         $this->assertEquals(1.1, $t->scalarval());
         $this->assertEquals(1, $u->scalarval());
@@ -105,15 +105,15 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $this->assertEquals(-110.0, $x->scalarval());
     }
 
-    function testAddScalarToStruct()
+    public function testAddScalarToStruct()
     {
         $v = new xmlrpcval(array('a' => 'b'), 'struct');
         // use @ operator in case error_log gets on screen
-        $r =  @$v->addscalar('c');
+        $r = @$v->addscalar('c');
         $this->assertEquals(0, $r);
     }
 
-    function testAddStructToStruct()
+    public function testAddStructToStruct()
     {
         $v = new xmlrpcval(array('a' => new xmlrpcval('b')), 'struct');
         $r = $v->addstruct(array('b' => new xmlrpcval('c')));
@@ -123,7 +123,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $this->assertEquals(2, $v->structsize());
     }
 
-    function testAddArrayToArray()
+    public function testAddArrayToArray()
     {
         $v = new xmlrpcval(array(new xmlrpcval('a'), new xmlrpcval('b')), 'array');
         $r = $v->addarray(array(new xmlrpcval('b'), new xmlrpcval('c')));
@@ -131,20 +131,20 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $this->assertEquals(1, $r);
     }
 
-    function testEncodeArray()
+    public function testEncodeArray()
     {
         $r = range(1, 100);
         $v = php_xmlrpc_encode($r);
         $this->assertEquals('array', $v->kindof());
     }
 
-    function testEncodeRecursive()
+    public function testEncodeRecursive()
     {
         $v = php_xmlrpc_encode(php_xmlrpc_encode('a simple string'));
         $this->assertEquals('scalar', $v->kindof());
     }
 
-    function testBrokenRequests()
+    public function testBrokenRequests()
     {
         $s = new xmlrpc_server();
         // omitting the 'params' tag: not tolerated by the lib anymore
@@ -179,7 +179,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $this->assertEquals(15, $r->faultCode());
     }
 
-    function testBrokenResponses()
+    public function testBrokenResponses()
     {
         $m = new xmlrpcmsg('dummy');
         //$m->debug = 1;
@@ -212,7 +212,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $this->assertEquals(2, $r->faultCode());
     }
 
-    function testBuggyHttp()
+    public function testBuggyHttp()
     {
         $s = new xmlrpcmsg('dummy');
         $f = 'HTTP/1.1 100 Welcome to the jungle
@@ -239,7 +239,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
     }
 
-    function testStringBug()
+    public function testStringBug()
     {
         $s = new xmlrpcmsg('dummy');
         $f = '<?xml version="1.0"?>
@@ -275,7 +275,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals('S300510007I', $s->scalarval());
     }
 
-    function testWhiteSpace()
+    public function testWhiteSpace()
     {
         $s = new xmlrpcmsg('dummy');
         $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
@@ -290,7 +290,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
     }
 
-    function testDoubleDataInArrayTag()
+    public function testDoubleDataInArrayTag()
     {
         $s = new xmlrpcmsg('dummy');
         $f = '<?xml version="1.0"?><methodResponse><params><param><value><array>
@@ -311,7 +311,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals(2, $v);
     }
 
-    function testDoubleStuffInValueTag()
+    public function testDoubleStuffInValueTag()
     {
         $s = new xmlrpcmsg('dummy');
         $f = '<?xml version="1.0"?><methodResponse><params><param><value>
@@ -340,7 +340,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals(2, $v);
     }
 
-    function testAutodecodeResponse()
+    public function testAutodecodeResponse()
     {
         $s = new xmlrpcmsg('dummy');
         $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
@@ -355,7 +355,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s);
     }
 
-    function testNoDecodeResponse()
+    public function testNoDecodeResponse()
     {
         $s = new xmlrpcmsg('dummy');
         $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
@@ -368,7 +368,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals($f, $v);
     }
 
-    function testAutoCoDec()
+    public function testAutoCoDec()
     {
         $data1 = array(1, 1.0, 'hello world', true, '20051021T23:43:00', -1, 11.0, '~!@#$%^&*()_+|', false, '20051021T23:43:00');
         $data2 = array('zero' => $data1, 'one' => $data1, 'two' => $data1, 'three' => $data1, 'four' => $data1, 'five' => $data1, 'six' => $data1, 'seven' => $data1, 'eight' => $data1, 'nine' => $data1);
@@ -387,9 +387,9 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals($m1, $m2);
     }
 
-    function testUTF8Request()
+    public function testUTF8Request()
     {
-        $sendstring='κόσμε'; // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
+        $sendstring = 'κόσμε'; // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
         $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
         \PhpXmlRpc\PhpXmlRpc::importGlobals();
         $f = new xmlrpcval($sendstring, 'string');
@@ -399,18 +399,18 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         \PhpXmlRpc\PhpXmlRpc::importGlobals();
     }
 
-    function testUTF8Response()
+    public function testUTF8Response()
     {
         $s = new xmlrpcmsg('dummy');
-        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>'.utf8_encode('àüèàüè').'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
+        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode('àüèàüè') . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
 ';
         $r = $s->parseResponse($f, false, 'phpvals');
         $v = $r->value();
         $v = $v['content'];
         $this->assertEquals("àüèàüè", $v);
         $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>'.utf8_encode('àüèàüè').'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode('àüèàüè') . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
 ';
         $r = $s->parseResponse($f, false, 'phpvals');
         $v = $r->value();
@@ -418,21 +418,21 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertEquals("àüèàüè", $v);
     }
 
-    function testUTF8IntString()
+    public function testUTF8IntString()
     {
         $v = new xmlrpcval(100, 'int');
         $s = $v->serialize('UTF-8');
         $this->assertequals("<value><int>100</int></value>\n", $s);
     }
 
-    function testStringInt()
+    public function testStringInt()
     {
         $v = new xmlrpcval('hello world', 'int');
         $s = $v->serialize();
         $this->assertequals("<value><int>0</int></value>\n", $s);
     }
 
-    function testStructMemExists()
+    public function testStructMemExists()
     {
         $v = php_xmlrpc_encode(array('hello' => 'world'));
         $b = $v->structmemexists('hello');
@@ -441,7 +441,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertequals(false, $b);
     }
 
-    function testNilvalue()
+    public function testNilvalue()
     {
         // default case: we do not accept nil values received
         $v = new xmlrpcval('hello', 'null');
@@ -462,7 +462,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         // serialization
         $v = new xmlrpcval('hello', 'null');
         $s = $v->serialize();
-        $this->assertequals(1, preg_match( '#<value><ex:nil/></value>#', $s ));
+        $this->assertequals(1, preg_match('#<value><ex:nil/></value>#', $s));
         // deserialization
         $r = new xmlrpcresp($v);
         $s = $r->serialize();
@@ -475,27 +475,21 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $this->assertequals(2, $r->faultCode());
     }
 
-    function TestLocale()
+    public function TestLocale()
     {
         $locale = setlocale(LC_NUMERIC, 0);
         /// @todo on php 5.3/win setting locale to german does not seem to set decimal separator to comma...
-        if (setlocale(LC_NUMERIC,'deu', 'de_DE@euro', 'de_DE', 'de', 'ge') !== false)
-        {
+        if (setlocale(LC_NUMERIC, 'deu', 'de_DE@euro', 'de_DE', 'de', 'ge') !== false) {
             $v = new xmlrpcval(1.1, 'double');
-            if (strpos($v->scalarval(), ',') == 1)
-            {
+            if (strpos($v->scalarval(), ',') == 1) {
                 $r = $v->serialize();
                 $this->assertequals(false, strpos($r, ','));
                 setlocale(LC_NUMERIC, $locale);
-            }
-            else
-            {
+            } else {
                 setlocale(LC_NUMERIC, $locale);
                 $this->markTestSkipped('did not find a locale which sets decimal separator to comma');
             }
-        }
-        else
-        {
+        } else {
             $this->markTestSkipped('did not find a locale which sets decimal separator to comma');
         }
     }
index 59a9cb8..62d6ef6 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
- * Benchmarking suite for the PHP-XMLRPC lib
+ * Benchmarking suite for the PHP-XMLRPC lib.
+ *
  * @author Gaetano Giunta
  * @copyright (c) 2005-2014 G. Giunta
  * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
@@ -16,16 +17,17 @@ use PhpXmlRpc\Client;
 use PhpXmlRpc\Response;
 use PhpXmlRpc\Encoder;
 
-include_once(__DIR__.'/../vendor/autoload.php');
+include_once __DIR__ . '/../vendor/autoload.php';
 
-include(__DIR__.'/parse_args.php');
+include __DIR__ . '/parse_args.php';
 $args = argParser::getArgs();
 
 function begin_test($test_name, $test_case)
 {
     global $test_results;
-    if (!isset($test_results[$test_name]))
-        $test_results[$test_name]=array();
+    if (!isset($test_results[$test_name])) {
+        $test_results[$test_name] = array();
+    }
     $test_results[$test_name][$test_case] = array();
     $test_results[$test_name][$test_case]['time'] = microtime(true);
 }
@@ -34,8 +36,9 @@ function end_test($test_name, $test_case, $test_result)
 {
     global $test_results;
     $end = microtime(true);
-    if (!isset($test_results[$test_name][$test_case]))
+    if (!isset($test_results[$test_name][$test_case])) {
         trigger_error('ending test that was not started');
+    }
     $test_results[$test_name][$test_case]['time'] = $end - $test_results[$test_name][$test_case]['time'];
     $test_results[$test_name][$test_case]['result'] = $test_result;
     echo '.';
@@ -52,48 +55,44 @@ $keys = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'ei
 
 // Begin execution
 
-$test_results=array();
+$test_results = array();
 $is_web = isset($_SERVER['REQUEST_METHOD']);
 $xd = extension_loaded('xdebug') && ini_get('xdebug.profiler_enable');
-if ($xd)
+if ($xd) {
     $num_tests = 1;
-else
+} else {
     $num_tests = 10;
+}
 
 $title = 'XML-RPC Benchmark Tests';
 
-if($is_web)
-{
+if ($is_web) {
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n<head>\n<title>$title</title>\n</head>\n<body>\n<h1>$title</h1>\n<pre>\n";
-}
-else
-{
+} else {
     echo "$title\n\n";
 }
 
-if($is_web)
-{
-    echo "<h3>Using lib version: ".PhpXmlRpc::$xmlrpcVersion." on PHP version: ".phpversion()."</h3>\n";
-    if ($xd) echo "<h4>XDEBUG profiling enabled: skipping remote tests. Trace file is: ".htmlspecialchars(xdebug_get_profiler_filename())."</h4>\n";
+if ($is_web) {
+    echo "<h3>Using lib version: " . PhpXmlRpc::$xmlrpcVersion . " on PHP version: " . phpversion() . "</h3>\n";
+    if ($xd) {
+        echo "<h4>XDEBUG profiling enabled: skipping remote tests. Trace file is: " . htmlspecialchars(xdebug_get_profiler_filename()) . "</h4>\n";
+    }
     flush();
     ob_flush();
-}
-else
-{
-    echo "Using lib version: ".PhpXmlRpc::$xmlrpcVersion." on PHP version: ".phpversion()."\n";
-    if ($xd) echo "XDEBUG profiling enabled: skipping remote tests\nTrace file is: ".xdebug_get_profiler_filename()."\n";
+} else {
+    echo "Using lib version: " . PhpXmlRpc::$xmlrpcVersion . " on PHP version: " . phpversion() . "\n";
+    if ($xd) {
+        echo "XDEBUG profiling enabled: skipping remote tests\nTrace file is: " . xdebug_get_profiler_filename() . "\n";
+    }
 }
 
 // test 'old style' data encoding vs. 'automatic style' encoding
 begin_test('Data encoding (large array)', 'manual encoding');
-for ($i = 0; $i < $num_tests; $i++)
-{
+for ($i = 0; $i < $num_tests; $i++) {
     $vals = array();
-    for ($j = 0; $j < 10; $j++)
-    {
+    for ($j = 0; $j < 10; $j++) {
         $valarray = array();
-        foreach ($data[$j] as $key => $val)
-        {
+        foreach ($data[$j] as $key => $val) {
             $values = array();
             $values[] = new Value($val[0], 'int');
             $values[] = new Value($val[1], 'double');
@@ -116,24 +115,21 @@ end_test('Data encoding (large array)', 'manual encoding', $out);
 
 begin_test('Data encoding (large array)', 'automatic encoding');
 $encoder = new Encoder();
-for ($i = 0; $i < $num_tests; $i++)
-{
+for ($i = 0; $i < $num_tests; $i++) {
     $value = $encoder->encode($data, array('auto_dates'));
     $out = $value->serialize();
 }
 end_test('Data encoding (large array)', 'automatic encoding', $out);
 
-if (function_exists('xmlrpc_set_type'))
-{
+if (function_exists('xmlrpc_set_type')) {
     begin_test('Data encoding (large array)', 'xmlrpc-epi encoding');
-    for ($i = 0; $i < $num_tests; $i++)
-    {
-        for ($j = 0; $j < 10; $j++)
-            foreach ($keys as $k)
-            {
+    for ($i = 0; $i < $num_tests; $i++) {
+        for ($j = 0; $j < 10; $j++) {
+            foreach ($keys as $k) {
                 xmlrpc_set_type($data[$j][$k][4], 'datetime');
                 xmlrpc_set_type($data[$j][$k][8], 'datetime');
             }
+        }
         $out = xmlrpc_encode($data);
     }
     end_test('Data encoding (large array)', 'xmlrpc-epi encoding', $out);
@@ -142,23 +138,19 @@ if (function_exists('xmlrpc_set_type'))
 // test 'old style' data decoding vs. 'automatic style' decoding
 $dummy = new Request('');
 $out = new Response($value);
-$in = '<?xml version="1.0" ?>'."\n".$out->serialize();
+$in = '<?xml version="1.0" ?>' . "\n" . $out->serialize();
 
 begin_test('Data decoding (large array)', 'manual decoding');
-for ($i = 0; $i < $num_tests; $i++)
-{
+for ($i = 0; $i < $num_tests; $i++) {
     $response = $dummy->ParseResponse($in, true);
     $value = $response->value();
     $result = array();
-    for ($k = 0; $k < $value->arraysize(); $k++)
-    {
+    for ($k = 0; $k < $value->arraysize(); $k++) {
         $val1 = $value->arraymem($k);
         $out = array();
-        while (list($name, $val) = $val1->structeach())
-        {
+        while (list($name, $val) = $val1->structeach()) {
             $out[$name] = array();
-            for ($j = 0; $j < $val->arraysize(); $j++)
-            {
+            for ($j = 0; $j < $val->arraysize(); $j++) {
                 $data = $val->arraymem($j);
                 $out[$name][] = $data->scalarval();
             }
@@ -169,42 +161,36 @@ for ($i = 0; $i < $num_tests; $i++)
 end_test('Data decoding (large array)', 'manual decoding', $result);
 
 begin_test('Data decoding (large array)', 'automatic decoding');
-for ($i = 0; $i < $num_tests; $i++)
-{
+for ($i = 0; $i < $num_tests; $i++) {
     $response = $dummy->ParseResponse($in, true, 'phpvals');
     $value = $response->value();
 }
 end_test('Data decoding (large array)', 'automatic decoding', $value);
 
-if (function_exists('xmlrpc_decode'))
-{
+if (function_exists('xmlrpc_decode')) {
     begin_test('Data decoding (large array)', 'xmlrpc-epi decoding');
-    for ($i = 0; $i < $num_tests; $i++)
-    {
+    for ($i = 0; $i < $num_tests; $i++) {
         $response = $dummy->ParseResponse($in, true, 'xml');
         $value = xmlrpc_decode($response->value());
     }
     end_test('Data decoding (large array)', 'xmlrpc-epi decoding', $value);
 }
 
-if (!$xd)
-{
+if (!$xd) {
 
     /// test multicall vs. many calls vs. keep-alives
     $encoder = new Encoder();
     $value = $encoder->encode($data1, array('auto_dates'));
     $req = new Request('interopEchoTests.echoValue', array($value));
     $reqs = array();
-    for ($i = 0; $i < 25; $i++)
+    for ($i = 0; $i < 25; $i++) {
         $reqs[] = $req;
+    }
     $server = explode(':', $args['LOCALSERVER']);
-    if(count($server) > 1)
-    {
+    if (count($server) > 1) {
         $srv = $server[1] . '://' . $server[0] . $args['URI'];
         $c = new Client($args['URI'], $server[0], $server[1]);
-    }
-    else
-    {
+    } else {
         $srv = $args['LOCALSERVER'] . $args['URI'];
         $c = new Client($args['URI'], $args['LOCALSERVER']);
     }
@@ -219,19 +205,16 @@ if (!$xd)
     }
     begin_test($testName, 'http 10');
     $response = array();
-    for ($i = 0; $i < 25; $i++)
-    {
+    for ($i = 0; $i < 25; $i++) {
         $resp = $c->send($req);
         $response[] = $resp->value();
     }
     end_test($testName, 'http 10', $response);
 
-    if (function_exists('curl_init'))
-    {
+    if (function_exists('curl_init')) {
         begin_test($testName, 'http 11 w. keep-alive');
         $response = array();
-        for ($i = 0; $i < 25; $i++)
-        {
+        for ($i = 0; $i < 25; $i++) {
             $resp = $c->send($req, 10, 'http11');
             $response[] = $resp->value();
         }
@@ -240,8 +223,7 @@ if (!$xd)
         $c->keepalive = false;
         begin_test($testName, 'http 11');
         $response = array();
-        for ($i = 0; $i < 25; $i++)
-        {
+        for ($i = 0; $i < 25; $i++) {
             $resp = $c->send($req, 10, 'http11');
             $response[] = $resp->value();
         }
@@ -250,32 +232,27 @@ if (!$xd)
 
     begin_test($testName, 'multicall');
     $response = $c->send($reqs);
-    foreach ($response as $key =>& $val)
-    {
+    foreach ($response as $key => & $val) {
         $val = $val->value();
     }
     end_test($testName, 'multicall', $response);
 
-    if (function_exists('gzinflate'))
-    {
+    if (function_exists('gzinflate')) {
         $c->accepted_compression = array('gzip');
         $c->request_compression = 'gzip';
 
         begin_test($testName, 'http 10 w. compression');
         $response = array();
-        for ($i = 0; $i < 25; $i++)
-        {
+        for ($i = 0; $i < 25; $i++) {
             $resp = $c->send($req);
             $response[] = $resp->value();
         }
         end_test($testName, 'http 10 w. compression', $response);
 
-        if (function_exists('curl_init'))
-        {
+        if (function_exists('curl_init')) {
             begin_test($testName, 'http 11 w. keep-alive and compression');
             $response = array();
-            for ($i = 0; $i < 25; $i++)
-            {
+            for ($i = 0; $i < 25; $i++) {
                 $resp = $c->send($req, 10, 'http11');
                 $response[] = $resp->value();
             }
@@ -284,8 +261,7 @@ if (!$xd)
             $c->keepalive = false;
             begin_test($testName, 'http 11 w. compression');
             $response = array();
-            for ($i = 0; $i < 25; $i++)
-            {
+            for ($i = 0; $i < 25; $i++) {
                 $resp = $c->send($req, 10, 'http11');
                 $response[] = $resp->value();
             }
@@ -294,26 +270,22 @@ if (!$xd)
 
         begin_test($testName, 'multicall w. compression');
         $response = $c->send($reqs);
-        foreach ($response as $key =>& $val)
-        {
+        foreach ($response as $key => & $val) {
             $val = $val->value();
         }
         end_test($testName, 'multicall w. compression', $response);
     }
-
 } // end of 'if no xdebug profiling'
 
 
 echo "\n";
-foreach($test_results as $test => $results)
-{
+foreach ($test_results as $test => $results) {
     echo "\nTEST: $test\n";
-    foreach ($results as $case => $data)
-        echo "  $case: {$data['time']} secs - Output data CRC: ".crc32(serialize($data['result']))."\n";
+    foreach ($results as $case => $data) {
+        echo "  $case: {$data['time']} secs - Output data CRC: " . crc32(serialize($data['result'])) . "\n";
+    }
 }
 
-
-if($is_web)
-{
+if ($is_web) {
     echo "\n</pre>\n</body>\n</html>\n";
 }
index 18b6bc3..4397e64 100644 (file)
@@ -1,6 +1,7 @@
 <?php
+
 /**
- * Common parameter parsing for benchmarks and tests scripts
+ * Common parameter parsing for benchmarks and tests scripts.
  *
  * @param integer DEBUG
  * @param string  LOCALSERVER
  * @copyright (C) 2007-20014 G. Giunta
  * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
  **/
-
 class argParser
 {
-    static public function getArgs()
+    public static function getArgs()
     {
         global $argv;
 
@@ -28,116 +28,86 @@ class argParser
             'HTTPSIGNOREPEER' => false,
             'PROXYSERVER' => null,
             'NOPROXY' => false,
-            'LOCALPATH' => __DIR__
+            'LOCALPATH' => __DIR__,
         );
 
         // check for command line vs web page input params
-        if(!isset($_SERVER['REQUEST_METHOD']))
-        {
-            if(isset($argv))
-            {
-                foreach($argv as $param)
-                {
+        if (!isset($_SERVER['REQUEST_METHOD'])) {
+            if (isset($argv)) {
+                foreach ($argv as $param) {
                     $param = explode('=', $param);
-                    if(count($param) > 1)
-                    {
+                    if (count($param) > 1) {
                         $pname = strtoupper(ltrim($param[0], '-'));
-                        $$pname=$param[1];
+                        $$pname = $param[1];
                     }
                 }
             }
-        }
-        else
-        {
+        } else {
             // NB: we might as well consider using $_GET stuff later on...
             extract($_GET);
             extract($_POST);
         }
 
-        if(isset($DEBUG))
-        {
+        if (isset($DEBUG)) {
             $args['DEBUG'] = intval($DEBUG);
         }
-        if(isset($LOCALSERVER))
-        {
+        if (isset($LOCALSERVER)) {
             $args['LOCALSERVER'] = $LOCALSERVER;
-        }
-        else
-        {
-            if(isset($HTTP_HOST))
-            {
+        } else {
+            if (isset($HTTP_HOST)) {
                 $args['LOCALSERVER'] = $HTTP_HOST;
-            }
-            elseif(isset($_SERVER['HTTP_HOST']))
-            {
+            } elseif (isset($_SERVER['HTTP_HOST'])) {
                 $args['LOCALSERVER'] = $_SERVER['HTTP_HOST'];
             }
         }
-        if(isset($HTTPSSERVER))
-        {
+        if (isset($HTTPSSERVER)) {
             $args['HTTPSSERVER'] = $HTTPSSERVER;
         }
-        if(isset($HTTPSURI))
-        {
+        if (isset($HTTPSURI)) {
             $args['HTTPSURI'] = $HTTPSURI;
         }
-        if(isset($HTTPSIGNOREPEER))
-        {
+        if (isset($HTTPSIGNOREPEER)) {
             $args['HTTPSIGNOREPEER'] = bool($HTTPSIGNOREPEER);
         }
-        if(isset($PROXY))
-        {
+        if (isset($PROXY)) {
             $arr = explode(':', $PROXY);
             $args['PROXYSERVER'] = $arr[0];
-            if(count($arr) > 1)
-            {
+            if (count($arr) > 1) {
                 $args['PROXYPORT'] = $arr[1];
-            }
-            else
-            {
+            } else {
                 $args['PROXYPORT'] = 8080;
             }
         }
         // used to silence testsuite warnings about proxy code not being tested
-        if(isset($NOPROXY))
-        {
+        if (isset($NOPROXY)) {
             $args['NOPROXY'] = true;
         }
-        if(!isset($URI))
-        {
+        if (!isset($URI)) {
             // GUESTIMATE the url of local demo server
             // play nice to php 3 and 4-5 in retrieving URL of server.php
             /// @todo filter out query string from REQUEST_URI
-            if(isset($REQUEST_URI))
-            {
+            if (isset($REQUEST_URI)) {
                 $URI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $REQUEST_URI);
                 $URI = str_replace('/testsuite.php', '/server.php', $URI);
                 $URI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $URI);
                 $URI = str_replace('/benchmark.php', '/server.php', $URI);
-            }
-            elseif(isset($_SERVER['PHP_SELF']) && isset($_SERVER['REQUEST_METHOD']))
-            {
+            } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['REQUEST_METHOD'])) {
                 $URI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $_SERVER['PHP_SELF']);
                 $URI = str_replace('/testsuite.php', '/server.php', $URI);
                 $URI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $URI);
                 $URI = str_replace('/benchmark.php', '/server.php', $URI);
-            }
-            else
-            {
+            } else {
                 $URI = '/demo/server/server.php';
             }
         }
-        if($URI[0] != '/')
-        {
-            $URI = '/'.$URI;
+        if ($URI[0] != '/') {
+            $URI = '/' . $URI;
         }
         $args['URI'] = $URI;
-        if(isset($LOCALPATH))
-        {
-            $args['LOCALPATH'] =$LOCALPATH;
+        if (isset($LOCALPATH)) {
+            $args['LOCALPATH'] = $LOCALPATH;
         }
 
         return $args;
     }
-
-}
\ No newline at end of file
+}
index c9c4ad2..85dee62 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Verify compatibility level of current php install with php-xmlrpc lib
+ * Verify compatibility level of current php install with php-xmlrpc lib.
  *
  * @author Gaetano Giunta
  * @copyright (C) 2006-2014 G. Giunta
  * @todo add a test for php output buffering?
  */
 
-function phpxmlrpc_verify_compat($mode='client')
+function phpxmlrpc_verify_compat($mode = 'client')
 {
-  $tests = array();
-
-  if ($mode == 'server')
-  {
-    // test for php version
-    $ver = phpversion();
-    $tests['php_version'] = array();
-    $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
-    if (version_compare($ver, '5.3.0') < 0)
-    {
-      $tests['php_version']['status'] = 0;
-      $tests['php_version']['description'] .= 'This version of PHP is not compatible with this release of the PHP XMLRPC library. Please upgrade to php 5.1.0 or later';
-    }
-    else
-    {
-      $tests['php_version']['status'] = 2;
-      $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
-    }
+    $tests = array();
 
-    // test for zlib
-    $tests['zlib'] = array();
-    if (!function_exists('gzinflate'))
-    {
-      $tests['zlib']['status'] = 0;
-      $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to receive compressed requests or send compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)";
-    }
-    else
-    {
-      $tests['zlib']['status'] = 2;
-      $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to receive compressed requests and send compressed responses for the 'HTTP' protocol";
-    }
+    if ($mode == 'server') {
+        // test for php version
+        $ver = phpversion();
+        $tests['php_version'] = array();
+        $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n";
+        if (version_compare($ver, '5.3.0') < 0) {
+            $tests['php_version']['status'] = 0;
+            $tests['php_version']['description'] .= 'This version of PHP is not compatible with this release of the PHP XMLRPC library. Please upgrade to php 5.1.0 or later';
+        } else {
+            $tests['php_version']['status'] = 2;
+            $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
+        }
 
-    // test for dispaly of php errors in xml reponse
-    if (ini_get('display_errors'))
-    {
-      if (intval(ini_get('error_reporting')) && E_NOTICE )
-      {
-        $tests['display_errors']['status'] = 1;
-        $tests['display_errors']['description'] = "Error reporting level includes E_NOTICE errors, and display_errors is set to ON.\n\nAny error, warning or notice raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response";
-      }
-      else
-      {
-        $tests['display_errors']['status'] = 1;
-        $tests['display_errors']['description'] = "display_errors is set to ON.\n\nAny error raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response";
-      }
-    }
+        // test for zlib
+        $tests['zlib'] = array();
+        if (!function_exists('gzinflate')) {
+            $tests['zlib']['status'] = 0;
+            $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to receive compressed requests or send compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)";
+        } else {
+            $tests['zlib']['status'] = 2;
+            $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to receive compressed requests and send compressed responses for the 'HTTP' protocol";
+        }
 
-  }
-  else
-  {
-
-    // test for php version
-    $ver = phpversion();
-    $tests['php_version'] = array();
-    $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
-    if (version_compare($ver, '5.3.0') < 0)
-    {
-      $tests['php_version']['status'] = 0;
-      $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.1.0 or later';
-    }
-    else
-    {
-      $tests['php_version']['status'] = 2;
-      $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
-    }
+        // test for dispaly of php errors in xml reponse
+        if (ini_get('display_errors')) {
+            if (intval(ini_get('error_reporting')) && E_NOTICE) {
+                $tests['display_errors']['status'] = 1;
+                $tests['display_errors']['description'] = "Error reporting level includes E_NOTICE errors, and display_errors is set to ON.\n\nAny error, warning or notice raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response";
+            } else {
+                $tests['display_errors']['status'] = 1;
+                $tests['display_errors']['description'] = "display_errors is set to ON.\n\nAny error raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response";
+            }
+        }
+    } else {
 
-    // test for zlib
-    $tests['zlib'] = array();
-    if (!function_exists('gzinflate'))
-    {
-      $tests['zlib']['status'] = 0;
-      $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to send compressed requests or receive compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)";
-    }
-    else
-    {
-      $tests['zlib']['status'] = 2;
-      $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to send compressed requests and receive compressed responses for the 'HTTP' protocol";
-    }
+        // test for php version
+        $ver = phpversion();
+        $tests['php_version'] = array();
+        $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n";
+        if (version_compare($ver, '5.3.0') < 0) {
+            $tests['php_version']['status'] = 0;
+            $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.1.0 or later';
+        } else {
+            $tests['php_version']['status'] = 2;
+            $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
+        }
 
-    // test for CURL
-    $tests['curl'] = array();
-    if (!extension_loaded('curl'))
-    {
-      $tests['curl']['status'] = 0;
-      $tests['curl']['description'] = "The cURL extension is not enabled.\n\nYou will not be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols";
-    }
-    else
-    {
-      $info = curl_version();
-      $tests['curl']['status'] = 2;
-      $tests['curl']['description'] = "The cURL extension is enabled.\n\nYou will be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols";
-      if (version_compare($ver, '4.3.8') < 0)
-      {
-        $tests['curl']['status'] = 1;
-        $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
-      }
-      if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
-      {
-        $tests['curl']['status'] = 1;
-        $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
-      }
-      if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version'])))
-      {
-        $tests['curl']['status'] = 1;
-        $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
-      }
+        // test for zlib
+        $tests['zlib'] = array();
+        if (!function_exists('gzinflate')) {
+            $tests['zlib']['status'] = 0;
+            $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to send compressed requests or receive compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)";
+        } else {
+            $tests['zlib']['status'] = 2;
+            $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to send compressed requests and receive compressed responses for the 'HTTP' protocol";
+        }
+
+        // test for CURL
+        $tests['curl'] = array();
+        if (!extension_loaded('curl')) {
+            $tests['curl']['status'] = 0;
+            $tests['curl']['description'] = "The cURL extension is not enabled.\n\nYou will not be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols";
+        } else {
+            $info = curl_version();
+            $tests['curl']['status'] = 2;
+            $tests['curl']['description'] = "The cURL extension is enabled.\n\nYou will be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols";
+            if (version_compare($ver, '4.3.8') < 0) {
+                $tests['curl']['status'] = 1;
+                $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
+            }
+            if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) {
+                $tests['curl']['status'] = 1;
+                $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
+            }
+            if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version']))) {
+                $tests['curl']['status'] = 1;
+                $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
+            }
+        }
     }
 
-  }
-  return $tests;
+    return $tests;
 }
 
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
-<title>PHP XMLRPC compatibility assessment</title>
-<style type="text/css">
-body, html {background-color: white; font-family: Arial, Verdana, Geneva, sans-serif; font-size: small; }
-table { border: 1px solid gray; padding: 0;}
-thead { background-color: silver; color: black; }
-td { margin: 0; padding: 0.5em; }
-tbody td { border-top: 1px solid gray; }
-.res0 { background-color: red; color: black; border-right: 1px solid gray; }
-.res1 { background-color: yellow; color: black; border-right: 1px solid gray; }
-.res2 { background-color: green; color: black; border-right: 1px solid gray; }
-.result { white-space: pre; }
-</style>
+    <title>PHP XMLRPC compatibility assessment</title>
+    <style type="text/css">
+        body, html {
+            background-color: white;
+            font-family: Arial, Verdana, Geneva, sans-serif;
+            font-size: small;
+        }
+
+        table {
+            border: 1px solid gray;
+            padding: 0;
+        }
+
+        thead {
+            background-color: silver;
+            color: black;
+        }
+
+        td {
+            margin: 0;
+            padding: 0.5em;
+        }
+
+        tbody td {
+            border-top: 1px solid gray;
+        }
+
+        .res0 {
+            background-color: red;
+            color: black;
+            border-right: 1px solid gray;
+        }
+
+        .res1 {
+            background-color: yellow;
+            color: black;
+            border-right: 1px solid gray;
+        }
+
+        .res2 {
+            background-color: green;
+            color: black;
+            border-right: 1px solid gray;
+        }
+
+        .result {
+            white-space: pre;
+        }
+    </style>
 </head>
 <body>
 <h1>PHPXMLRPC compatibility assessment with the current PHP install</h1>
 <h4>For phpxmlrpc version 4.0 or later</h4>
+
 <h3>Server usage</h3>
 <table cellspacing="0">
-<thead>
-<tr><td>Test</td><td>Result</td></tr>
-</thead>
-<tbody>
-<?php
-  $res = phpxmlrpc_verify_compat('server');
-  foreach($res as $test => $result)
-  {
-      echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
-  }
-?>
-</tbody>
+    <thead>
+    <tr>
+        <td>Test</td>
+        <td>Result</td>
+    </tr>
+    </thead>
+    <tbody>
+    <?php
+    $res = phpxmlrpc_verify_compat('server');
+    foreach ($res as $test => $result) {
+        echo '<tr><td class="res' . $result['status'] . '">' . htmlspecialchars($test) . '</td><td class="result">' . htmlspecialchars($result['description']) . "</td></tr>\n";
+    }
+    ?>
+    </tbody>
 </table>
 <h3>Client usage</h3>
 <table cellspacing="0">
-<thead>
-<tr><td>Test</td><td>Result</td></tr>
-</thead>
-<tbody>
-<?php
-  $res = phpxmlrpc_verify_compat('client');
-  foreach($res as $test => $result)
-  {
-      echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
-  }
-?>
-</tbody>
+    <thead>
+    <tr>
+        <td>Test</td>
+        <td>Result</td>
+    </tr>
+    </thead>
+    <tbody>
+    <?php
+    $res = phpxmlrpc_verify_compat('client');
+    foreach ($res as $test => $result) {
+        echo '<tr><td class="res' . $result['status'] . '">' . htmlspecialchars($test) . '</td><td class="result">' . htmlspecialchars($result['description']) . "</td></tr>\n";
+    }
+    ?>
+    </tbody>
 </table>
 </body>
-</html>
\ No newline at end of file
+</html>